summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fpdftext/fpdf_text.h2
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp11
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp33
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp7
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp22
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp20
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp9
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp89
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp150
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp18
-rw-r--r--core/src/fpdfdoc/doc_action.cpp27
-rw-r--r--core/src/fpdfdoc/doc_ap.cpp14
-rw-r--r--core/src/fpdfdoc/doc_basic.cpp11
-rw-r--r--core/src/fpdfdoc/doc_form.cpp208
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp33
-rw-r--r--core/src/fpdfdoc/doc_formfield.cpp5
-rw-r--r--core/src/fpdfdoc/doc_metadata.cpp16
-rw-r--r--core/src/fpdfdoc/doc_ocg.cpp11
-rw-r--r--core/src/fpdfdoc/doc_utils.cpp8
-rw-r--r--core/src/fpdfdoc/doc_vt.cpp120
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp190
-rw-r--r--core/src/fpdftext/text_int.h3
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp3
-rw-r--r--core/src/fxcodec/codec/fx_codec_jbig.cpp51
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp6
-rw-r--r--core/src/fxcrt/fx_basic_array.cpp3
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp11
-rw-r--r--core/src/fxcrt/fx_basic_util.cpp24
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp9
-rw-r--r--core/src/fxge/agg/src/fx_agg_driver.cpp9
-rw-r--r--core/src/fxge/dib/fx_dib_composite.cpp12
-rw-r--r--core/src/fxge/dib/fx_dib_convert.cpp24
-rw-r--r--core/src/fxge/dib/fx_dib_engine.cpp9
-rw-r--r--core/src/fxge/dib/fx_dib_main.cpp7
-rw-r--r--core/src/fxge/dib/fx_dib_transform.cpp6
-rw-r--r--core/src/fxge/ge/fx_ge_device.cpp9
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp27
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp12
-rw-r--r--core/src/fxge/ge/fx_ge_linux.cpp9
-rw-r--r--core/src/fxge/ge/fx_ge_path.cpp6
-rw-r--r--core/src/fxge/ge/fx_ge_text.cpp57
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.cpp3061
-rw-r--r--core/src/fxge/win32/fx_win32_device.cpp80
-rw-r--r--core/src/fxge/win32/fx_win32_dib.cpp3
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp20
-rw-r--r--core/src/fxge/win32/fx_win32_gdipext.cpp8
-rw-r--r--core/src/fxge/win32/fx_win32_print.cpp42
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp556
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp1347
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp531
-rw-r--r--fpdfsdk/src/fpdf_ext.cpp330
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp367
-rw-r--r--fpdfsdk/src/fpdfppo.cpp36
-rw-r--r--fpdfsdk/src/fpdfsave.cpp98
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp75
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp1407
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp4458
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp34
-rw-r--r--fpdfsdk/src/fsdk_rendercontext.cpp26
-rw-r--r--fpdfsdk/src/fxedit/fxet_edit.cpp4921
-rw-r--r--fpdfsdk/src/javascript/Document.cpp2459
-rw-r--r--fpdfsdk/src/javascript/Field.cpp6345
-rw-r--r--fpdfsdk/src/javascript/JS_EventHandler.cpp755
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.cpp845
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp445
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp3949
-rw-r--r--fpdfsdk/src/javascript/global.cpp872
-rw-r--r--fpdfsdk/src/javascript/util.cpp1035
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp864
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp876
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_FontMap.cpp730
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Wnd.cpp1385
78 files changed, 19384 insertions, 19905 deletions
diff --git a/core/include/fpdftext/fpdf_text.h b/core/include/fpdftext/fpdf_text.h
index ad5888eb78..04922c4b7f 100644
--- a/core/include/fpdftext/fpdf_text.h
+++ b/core/include/fpdftext/fpdf_text.h
@@ -100,8 +100,6 @@ public:
virtual int GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const = 0;
- virtual int GetOrderByDirection(int index, int direction) const = 0;
-
virtual CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const = 0;
virtual void GetRectsArrayByRect(const CFX_FloatRect& rect, CFX_RectArray& resRectArray) const = 0;
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
index c37e92d832..5a5fb94ef3 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
@@ -521,7 +521,8 @@ static FX_WORD FX_GetCsFromLangCode(uint32_t uCode)
const FX_LANG2CS &charset = gs_FXLang2CharsetTable[iMid];
if (uCode == charset.uLang) {
return charset.uCharset;
- } else if (uCode < charset.uLang) {
+ }
+ if (uCode < charset.uLang) {
iEnd = iMid - 1;
} else {
iStart = iMid + 1;
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 9ed5d8ff1c..8037a8c674 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -555,13 +555,12 @@ static FX_DWORD _StringToCode(const CFX_ByteStringC& str)
result = result * 16 + digit;
}
return result;
- } else {
- for (int i = 0; i < len; i ++) {
- if (buf[i] < '0' || buf[i] > '9') {
- break;
- }
- result = result * 10 + buf[i] - '0';
+ }
+ for (int i = 0; i < len; i ++) {
+ if (buf[i] < '0' || buf[i] > '9') {
+ break;
}
+ result = result * 10 + buf[i] - '0';
}
return result;
}
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 7a01bba97a..f70b9ecfc4 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -641,22 +641,23 @@ int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const
}
str[iSize - 1] = (uint8_t)charcode;
return iSize;
- } else if (charcode < 0x10000) {
+ }
+ if (charcode < 0x10000) {
str[0] = (uint8_t)(charcode >> 8);
str[1] = (uint8_t)charcode;
return 2;
- } else if (charcode < 0x1000000) {
+ }
+ if (charcode < 0x1000000) {
str[0] = (uint8_t)(charcode >> 16);
str[1] = (uint8_t)(charcode >> 8);
str[2] = (uint8_t)charcode;
return 3;
- } else {
- str[0] = (uint8_t)(charcode >> 24);
- str[1] = (uint8_t)(charcode >> 16);
- str[2] = (uint8_t)(charcode >> 8);
- str[3] = (uint8_t)charcode;
- return 4;
}
+ str[0] = (uint8_t)(charcode >> 24);
+ str[1] = (uint8_t)(charcode >> 16);
+ str[2] = (uint8_t)(charcode >> 8);
+ str[3] = (uint8_t)charcode;
+ return 4;
}
return 0;
}
@@ -794,9 +795,8 @@ FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const
#endif
if (m_pCMap->m_pEmbedMap) {
return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, charcode);
- } else {
- return 0;
}
+ return 0;
}
return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode));
}
@@ -826,7 +826,8 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const
if (unicode < 0x80) {
return static_cast<FX_DWORD>(unicode);
- } else if (m_pCMap->m_Coding == CIDCODING_CID) {
+ }
+ if (m_pCMap->m_Coding == CIDCODING_CID) {
return 0;
}
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -834,14 +835,15 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const
int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, (char*)buffer, 4, NULL, NULL);
if (ret == 1) {
return buffer[0];
- } else if (ret == 2) {
+ }
+ if (ret == 2) {
return buffer[0] * 256 + buffer[1];
}
- return 0;
-#endif
+#else
if (m_pCMap->m_pEmbedMap) {
return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, unicode);
}
+#endif
return 0;
}
static void FT_UseCIDCharmap(FXFT_Face face, int coding)
@@ -1234,9 +1236,8 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph)
}
if (index == 0 || index == 0xffff) {
return charcode == 0 ? -1 : (int)charcode;
- } else {
- return index;
}
+ return index;
}
if (m_Charset == CIDSET_JAPAN1) {
if (unicode == '\\') {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index db3966ec17..c0cdb228f4 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -754,18 +754,17 @@ void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause)
}
int CPDF_PageObjects::EstimateParseProgress() const
{
- if (m_pParser == NULL) {
+ if (!m_pParser) {
return m_ParseState == PDF_CONTENT_PARSED ? 100 : 0;
}
return m_pParser->EstimateProgress();
}
FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject)
{
- if (posInsertAfter == NULL) {
+ if (!posInsertAfter) {
return m_ObjectList.AddHead(pNewObject);
- } else {
- return m_ObjectList.InsertAfter(posInsertAfter, pNewObject);
}
+ return m_ObjectList.InsertAfter(posInsertAfter, pNewObject);
}
int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const
{
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index 101a197968..198054ef7e 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -103,14 +103,15 @@ FX_BOOL CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B
pBuf[1] = G;
pBuf[2] = B;
return TRUE;
- } else if (m_Family == PDFCS_DEVICEGRAY) {
+ }
+ if (m_Family == PDFCS_DEVICEGRAY) {
if (R == G && R == B) {
*pBuf = R;
return TRUE;
- } else {
- return FALSE;
}
- } else if (m_Family == PDFCS_DEVICECMYK) {
+ return FALSE;
+ }
+ if (m_Family == PDFCS_DEVICECMYK) {
sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]);
return TRUE;
}
@@ -121,9 +122,8 @@ FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOA
if (m_Family == PDFCS_DEVICERGB) {
AdobeCMYK_to_sRGB(c, m, y, k, pBuf[0], pBuf[1], pBuf[2]);
return TRUE;
- } else if (m_Family == PDFCS_DEVICEGRAY) {
- return FALSE;
- } else if (m_Family == PDFCS_DEVICECMYK) {
+ }
+ if (m_Family == PDFCS_DEVICECMYK) {
pBuf[0] = c;
pBuf[1] = m;
pBuf[2] = y;
@@ -314,9 +314,8 @@ FX_BOOL CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B)
if (R == G && R == B) {
*pBuf = R;
return TRUE;
- } else {
- return FALSE;
}
+ return FALSE;
}
void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const
{
@@ -993,10 +992,9 @@ FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_F
if (m_pAltCS) {
m_pAltCS->GetRGB(results, R, G, B);
return TRUE;
- } else {
- R = G = B = 0;
- return FALSE;
}
+ R = G = B = 0;
+ return FALSE;
}
void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled)
{
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 5b5703b868..892e2153b7 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -337,7 +337,8 @@ FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op)
if (compare == 0) {
(this->*g_OpCodes[middle].m_OpHandler)();
return TRUE;
- } else if (compare < 0) {
+ }
+ if (compare < 0) {
high = middle - 1;
} else {
low = middle + 1;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index ebd4d83310..37ffea9742 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -288,19 +288,25 @@ FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, FX_DWORD limit,
if (decoder == FX_BSTRC("CCITTFaxDecode") || decoder == FX_BSTRC("CCF")) {
ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam);
return _DecodeAllScanlines(pDecoder, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) {
+ }
+ if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) {
return _A85Decode(src_buf, limit, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) {
+ }
+ if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) {
return _HexDecode(src_buf, limit, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) {
+ }
+ if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) {
return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) {
+ }
+ if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) {
return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) {
+ }
+ if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) {
ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
- src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1);
+ src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1);
return _DecodeAllScanlines(pDecoder, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) {
+ }
+ if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) {
return RunLengthDecode(src_buf, limit, dest_buf, dest_size);
}
dest_size = 0;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 9736c3dc8e..47c08fb4a3 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -311,9 +311,8 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic
dest_size = last_size;
pImageParms = pParam;
return TRUE;
- } else {
- offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size);
}
+ offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size);
} else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) {
offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam, estimated_size, new_buf, new_size);
} else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
index 0471250fd9..f630ea52da 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
@@ -181,10 +181,9 @@ CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec)
result += ':';
result += ChangeSlash(wsFileName.c_str() + 2);
return result;
- } else {
- CFX_WideString result;
- result += '\\';
- result += ChangeSlash(wsFileName.c_str());
- return result;
}
+ CFX_WideString result;
+ result += '\\';
+ result += ChangeSlash(wsFileName.c_str());
+ return result;
}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index a3e409df57..c7d1dece25 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -160,8 +160,8 @@ CPDF_Array* CPDF_Object::GetArray() const
{
if (m_Type == PDFOBJ_ARRAY)
return (CPDF_Array*)this;
- else
- return NULL;
+
+ return NULL;
}
void CPDF_Object::SetString(const CFX_ByteString& str)
{
@@ -201,7 +201,8 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const
if (pOther->m_Type != m_Type) {
if (m_Type == PDFOBJ_REFERENCE && GetDirect()) {
return GetDirect()->IsIdentical(pOther);
- } else if (pOther->m_Type == PDFOBJ_REFERENCE) {
+ }
+ if (pOther->m_Type == PDFOBJ_REFERENCE) {
return IsIdentical(pOther->GetDirect());
}
return FALSE;
@@ -285,27 +286,22 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite
CPDF_StreamAcc acc;
acc.LoadAllData(pThis, TRUE);
FX_DWORD streamSize = acc.GetSize();
- CPDF_Stream* pObj;
- if (pThis->GetDict())
- pObj = new CPDF_Stream(acc.DetachData(), streamSize, (CPDF_Dictionary*)((CPDF_Object*)pThis->GetDict())->CloneInternal(bDirect, visited));
- else
- pObj = new CPDF_Stream(acc.DetachData(), streamSize, NULL);
- return pObj;
+ CPDF_Dictionary* pDict = pThis->GetDict();
+ if (pDict)
+ pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict)->CloneInternal(bDirect, visited);
+ return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
}
case PDFOBJ_REFERENCE: {
CPDF_Reference* pRef = (CPDF_Reference*)this;
FX_DWORD obj_num = pRef->m_RefObjNum;
if (bDirect && !visited->GetValueAt((void*)(uintptr_t)obj_num)) {
visited->SetAt((void*)(uintptr_t)obj_num, (void*)1);
- CPDF_Object* ret;
- if (pRef->GetDirect())
- ret = pRef->GetDirect()->CloneInternal(TRUE, visited);
- else
- ret = NULL;
- return ret;
- } else {
- return new CPDF_Reference(pRef->m_pObjList, obj_num);
+ if (!pRef->GetDirect())
+ return nullptr;
+
+ return pRef->GetDirect()->CloneInternal(TRUE, visited);
}
+ return new CPDF_Reference(pRef->m_pObjList, obj_num);
}
}
return NULL;
@@ -321,12 +317,14 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const
{
if (m_Type == PDFOBJ_STRING) {
return PDF_DecodeText(((CPDF_String*)this)->m_String, pCharMap);
- } else if (m_Type == PDFOBJ_STREAM) {
+ }
+ if (m_Type == PDFOBJ_STREAM) {
CPDF_StreamAcc stream;
stream.LoadAllData((CPDF_Stream*)this, FALSE);
CFX_WideString result = PDF_DecodeText(stream.GetData(), stream.GetSize(), pCharMap);
return result;
- } else if (m_Type == PDFOBJ_NAME) {
+ }
+ if (m_Type == PDFOBJ_NAME) {
return PDF_DecodeText(((CPDF_Name*)this)->m_Name, pCharMap);
}
return CFX_WideString();
@@ -427,8 +425,7 @@ CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const
CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i);
return p->GetString();
}
- else
- return CFX_ByteString();
+ return CFX_ByteString();
}
CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const
{
@@ -436,8 +433,7 @@ CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const
CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i);
return p->GetConstString();
}
- else
- return CFX_ByteStringC();
+ return CFX_ByteStringC();
}
int CPDF_Array::GetInteger(FX_DWORD i) const
{
@@ -458,11 +454,13 @@ FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const
CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const
{
CPDF_Object* p = GetElementValue(i);
- if (p == NULL) {
+ if (!p) {
return NULL;
- } else if (p->GetType() == PDFOBJ_DICTIONARY) {
+ }
+ if (p->GetType() == PDFOBJ_DICTIONARY) {
return (CPDF_Dictionary*)p;
- } else if (p->GetType() == PDFOBJ_STREAM) {
+ }
+ if (p->GetType() == PDFOBJ_STREAM) {
return ((CPDF_Stream*)p)->GetDict();
}
return NULL;
@@ -604,19 +602,19 @@ CFX_ByteString CPDF_Dictionary::GetString(const CFX_ByteStringC& key) const
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p)
+ if (p) {
return p->GetString();
- else
- return CFX_ByteString();
+ }
+ return CFX_ByteString();
}
CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key) const
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p)
+ if (p) {
return p->GetConstString();
- else
- return CFX_ByteStringC();
+ }
+ return CFX_ByteStringC();
}
CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, CFX_CharMap* pCharMap) const
{
@@ -647,10 +645,10 @@ CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key, cons
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p)
+ if (p) {
return p->GetConstString();
- else
- return CFX_ByteStringC(def);
+ }
+ return CFX_ByteStringC(def);
}
int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key) const
{
@@ -691,14 +689,16 @@ FX_BOOL CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, FX_BOOL bDefault
CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const
{
CPDF_Object* p = GetElementValue(key);
- if (p == NULL) {
- return NULL;
- } else if (p->GetType() == PDFOBJ_DICTIONARY) {
+ if (!p) {
+ return nullptr;
+ }
+ if (p->GetType() == PDFOBJ_DICTIONARY) {
return (CPDF_Dictionary*)p;
- } else if (p->GetType() == PDFOBJ_STREAM) {
+ }
+ if (p->GetType() == PDFOBJ_STREAM) {
return ((CPDF_Stream*)p)->GetDict();
}
- return NULL;
+ return nullptr;
}
CPDF_Array* CPDF_Dictionary::GetArray(const CFX_ByteStringC& key) const
{
@@ -1269,12 +1269,11 @@ void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pO
}
void* value = NULL;
if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) {
- if (value)
- {
- if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum())
+ if (value) {
+ if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) {
return;
- else
- ((CPDF_Object*)value)->Destroy();
+ }
+ ((CPDF_Object*)value)->Destroy();
}
}
pObj->m_ObjNum = objnum;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index f7174f7a72..854be75ad4 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1993,21 +1993,16 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString()
void CPDF_SyntaxParser::ToNextLine()
{
uint8_t ch;
- while (1) {
- if (!GetNextChar(ch)) {
- return;
- }
+ while (GetNextChar(ch)) {
if (ch == '\n') {
- return;
+ break;
}
if (ch == '\r') {
GetNextChar(ch);
- if (ch == '\n') {
- return;
- } else {
- m_Pos --;
- return;
+ if (ch != '\n') {
+ --m_Pos;
}
+ break;
}
}
}
@@ -2079,20 +2074,13 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
return (CPDF_Object*)PDFOBJ_REFERENCE;
}
return new CPDF_Reference(pObjList, objnum);
- } else {
- m_Pos = SavedPos;
- if (bTypeOnly) {
- return (CPDF_Object*)PDFOBJ_NUMBER;
- }
- return CPDF_Number::Create(word);
}
- } else {
- m_Pos = SavedPos;
- if (bTypeOnly) {
- return (CPDF_Object*)PDFOBJ_NUMBER;
- }
- return CPDF_Number::Create(word);
}
+ m_Pos = SavedPos;
+ if (bTypeOnly) {
+ return (CPDF_Object*)PDFOBJ_NUMBER;
+ }
+ return CPDF_Number::Create(word);
}
if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) {
if (bTypeOnly) {
@@ -2252,25 +2240,18 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList
if (bIsNumber) {
CFX_ByteString nextword2 = GetNextWord(bIsNumber);
if (nextword2 == FX_BSTRC("R")) {
- FX_DWORD objnum = FXSYS_atoi(word);
if (bTypeOnly) {
return (CPDF_Object*)PDFOBJ_REFERENCE;
}
+ FX_DWORD objnum = FXSYS_atoi(word);
return new CPDF_Reference(pObjList, objnum);
- } else {
- m_Pos = SavedPos;
- if (bTypeOnly) {
- return (CPDF_Object*)PDFOBJ_NUMBER;
- }
- return CPDF_Number::Create(word);
}
- } else {
- m_Pos = SavedPos;
- if (bTypeOnly) {
- return (CPDF_Object*)PDFOBJ_NUMBER;
- }
- return CPDF_Number::Create(word);
}
+ m_Pos = SavedPos;
+ if (bTypeOnly) {
+ return (CPDF_Object*)PDFOBJ_NUMBER;
+ }
+ return CPDF_Number::Create(word);
}
if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) {
if (bTypeOnly) {
@@ -3140,21 +3121,20 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints)
m_objs_array.RemoveAll();
}
return bRet;
- } else {
- CFX_PtrArray new_objs_array;
- FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
- if (bRet) {
- int32_t iSize = m_arrayAcroforms.GetSize();
- for (int32_t i = 0; i < iSize; ++i) {
- ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release();
- }
- m_arrayAcroforms.RemoveAll();
- } else {
- m_objs_array.RemoveAll();
- m_objs_array.Append(new_objs_array);
+ }
+ CFX_PtrArray new_objs_array;
+ FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
+ if (bRet) {
+ int32_t iSize = m_arrayAcroforms.GetSize();
+ for (int32_t i = 0; i < iSize; ++i) {
+ ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release();
}
- return bRet;
+ m_arrayAcroforms.RemoveAll();
+ } else {
+ m_objs_array.RemoveAll();
+ m_objs_array.Append(new_objs_array);
}
+ return bRet;
}
FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints)
{
@@ -3208,16 +3188,14 @@ FX_BOOL CPDF_DataAvail::CheckDocStatus(IFX_DownloadHints *pHints)
case PDF_DATAAVAIL_PAGETREE:
if (m_bTotalLoadPageTree) {
return CheckPages(pHints);
- } else {
- return LoadDocPages(pHints);
}
+ return LoadDocPages(pHints);
case PDF_DATAAVAIL_PAGE:
if (m_bTotalLoadPageTree) {
return CheckPage(pHints);
- } else {
- m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD;
- return TRUE;
}
+ m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD;
+ return TRUE;
case PDF_DATAAVAIL_ERROR:
return LoadAllFile(pHints);
case PDF_DATAAVAIL_PAGE_LATERLOAD:
@@ -3761,10 +3739,9 @@ FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints)
SetStartOffset(m_dwXRefOffset);
m_docStatus = PDF_DATAAVAIL_CROSSREF;
return TRUE;
- } else {
- m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
- return TRUE;
}
+ m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
+ return TRUE;
}
pHints->AddSegment(req_pos, dwSize);
return FALSE;
@@ -3799,9 +3776,6 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI
xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev"));
pObj->Release();
return 1;
- } else {
- pObj->Release();
- return -1;
}
}
pObj->Release();
@@ -3955,7 +3929,8 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints)
m_Pos = xref_offset;
}
return TRUE;
- } else if (nRet == -1) {
+ }
+ if (nRet == -1) {
m_docStatus = PDF_DATAAVAIL_ERROR;
}
return FALSE;
@@ -4058,11 +4033,10 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints)
}
}
return TRUE;
- } else {
- m_dwPrevXRefOffset = 0;
- m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
- pTrailer->Release();
}
+ m_dwPrevXRefOffset = 0;
+ m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
+ pTrailer->Release();
return TRUE;
}
pHints->AddSegment(m_Pos, iTrailerSize);
@@ -4295,9 +4269,8 @@ FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints)
if (CheckPageCount(pHints)) {
m_docStatus = PDF_DATAAVAIL_PAGE;
return TRUE;
- } else {
- m_bTotalLoadPageTree = TRUE;
}
+ m_bTotalLoadPageTree = TRUE;
return FALSE;
}
FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints)
@@ -4363,15 +4336,14 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, IFX_DownloadHints* pHints
m_objs_array.RemoveAll();
}
return bRet;
- } else {
- CFX_PtrArray new_objs_array;
- FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
- m_objs_array.RemoveAll();
- if (!bRet) {
- m_objs_array.Append(new_objs_array);
- }
- return bRet;
}
+ CFX_PtrArray new_objs_array;
+ FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
+ m_objs_array.RemoveAll();
+ if (!bRet) {
+ m_objs_array.Append(new_objs_array);
+ }
+ return bRet;
}
FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHints* pHints)
{
@@ -4381,10 +4353,10 @@ FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint
}
m_bAnnotsLoad = TRUE;
}
- if (m_bAnnotsLoad)
- if (!CheckLinearizedData(pHints)) {
+ if (m_bAnnotsLoad) {
+ if (!CheckLinearizedData(pHints))
return FALSE;
- }
+ }
m_bPageLoadedOK = FALSE;
return TRUE;
}
@@ -4539,15 +4511,14 @@ FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints)
m_objs_array.RemoveAll();
}
return bRet;
- } else {
- CFX_PtrArray new_objs_array;
- FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
- m_objs_array.RemoveAll();
- if (!bRet) {
- m_objs_array.Append(new_objs_array);
- }
- return bRet;
}
+ CFX_PtrArray new_objs_array;
+ FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
+ m_objs_array.RemoveAll();
+ if (!bRet) {
+ m_objs_array.Append(new_objs_array);
+ }
+ return bRet;
}
void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize)
{
@@ -4604,16 +4575,15 @@ FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum)
}
FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext)
{
- int32_t iLen = m_number_array.GetSize();
int32_t iLow = 0;
- int32_t iHigh = iLen - 1;
- int32_t iMid = 0;
+ int32_t iHigh = m_number_array.GetSize() - 1;
while (iLow <= iHigh) {
- iMid = (iLow + iHigh) / 2;
+ int32_t iMid = (iLow + iHigh) / 2;
if (m_number_array.GetAt(iMid) == value) {
iNext = iMid;
return TRUE;
- } else if (m_number_array.GetAt(iMid) > value) {
+ }
+ if (m_number_array.GetAt(iMid) > value) {
iHigh = iMid - 1;
} else if (m_number_array.GetAt(iMid) < value) {
iLow = iMid + 1;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index 6d425de6f8..4903312645 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -165,7 +165,8 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord()
m_dwCurPos ++;
}
return CFX_ByteStringC(pStart, (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
- } else if (dwSize == 1 && pStart[0] == '(') {
+ }
+ if (dwSize == 1 && pStart[0] == '(') {
int level = 1;
while (m_dwCurPos < m_dwSize) {
if (m_pData[m_dwCurPos] == ')') {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 12f60632fc..f8b59913e4 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -551,7 +551,8 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bTyp
CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState;
if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && (!pColorData || pColorData->m_FillColor.IsNull())))) {
return m_T3FillColor;
- } else if (!pColorData || pColorData->m_FillColor.IsNull()) {
+ }
+ if (!pColorData || pColorData->m_FillColor.IsNull()) {
pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState;
}
FX_COLORREF rgb = pColorData->m_FillRGB;
@@ -580,7 +581,8 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const
CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState;
if (m_pType3Char && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && (!pColorData || pColorData->m_StrokeColor.IsNull())))) {
return m_T3FillColor;
- } else if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
+ }
+ if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState;
}
FX_COLORREF rgb = pColorData->m_StrokeRGB;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 0730206e23..fa9325a4d2 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -761,7 +761,8 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause)
m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft,
m_pQuickStretcher->m_ResultTop, m_BlendType);
return FALSE;
- } else if (m_Status == 2) {
+ }
+ if (m_Status == 2) {
if (m_pTransformer->Continue(pPause)) {
return TRUE;
}
@@ -784,16 +785,17 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause)
}
delete pBitmap;
return FALSE;
- } else if (m_Status == 3) {
+ }
+ if (m_Status == 3) {
return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
- } else if (m_Status == 4) {
+ }
+ if (m_Status == 4) {
if (m_Loader.Continue(m_LoadHandle, pPause)) {
return TRUE;
}
if (StartRenderDIBSource()) {
return Continue(pPause);
}
- return FALSE;
}
return FALSE;
}
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index ce29baf738..7d17e78e24 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -21,13 +21,17 @@ unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits)
unsigned int byte = pData[bitpos / 8];
if (nbits == 8) {
return byte;
- } else if (nbits == 4) {
+ }
+ if (nbits == 4) {
return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4);
- } else if (nbits == 2) {
+ }
+ if (nbits == 2) {
return (byte >> (6 - bitpos % 8)) & 0x03;
- } else if (nbits == 1) {
+ }
+ if (nbits == 1) {
return (byte >> (7 - bitpos % 8)) & 0x01;
- } else if (nbits == 16) {
+ }
+ if (nbits == 16) {
return byte * 256 + pData[bitpos / 8 + 1];
}
return 0;
@@ -462,7 +466,8 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause)
m_pColorSpace->EnableStdConversion(FALSE);
}
return ret1;
- } else if (m_Status == 2) {
+ }
+ if (m_Status == 2) {
return ContinueLoadMaskDIB(pPause);
}
return 0;
@@ -1008,7 +1013,8 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* s
break;
}
return;
- } else if (m_bpc == 8) {
+ }
+ if (m_bpc == 8) {
if (m_nComponents == m_pColorSpace->CountComponents())
m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height,
m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK);
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index da2e05af2e..851b2d6709 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -112,9 +112,11 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const
int iType = pFields->GetType();
if (iType == PDFOBJ_DICTIONARY) {
return 1;
- } else if (iType == PDFOBJ_STRING) {
+ }
+ if (iType == PDFOBJ_STRING) {
return 1;
- } else if (iType == PDFOBJ_ARRAY) {
+ }
+ if (iType == PDFOBJ_ARRAY) {
return ((CPDF_Array*)pFields)->GetCount();
}
return 0;
@@ -207,16 +209,17 @@ CFX_WideString CPDF_Action::GetJavaScript() const
}
CPDF_Dictionary* CPDF_Action::GetAnnot() const
{
- if (m_pDict == NULL) {
- return NULL;
+ if (!m_pDict) {
+ return nullptr;
}
CFX_ByteString csType = m_pDict->GetString("S");
if (csType == FX_BSTRC("Rendition")) {
return m_pDict->GetDict("AN");
- } else if (csType == FX_BSTRC("Movie")) {
+ }
+ if (csType == FX_BSTRC("Movie")) {
return m_pDict->GetDict("Annotation");
}
- return NULL;
+ return nullptr;
}
int32_t CPDF_Action::GetOperationType() const
{
@@ -226,15 +229,19 @@ int32_t CPDF_Action::GetOperationType() const
CFX_ByteString csType = m_pDict->GetString("S");
if (csType == FX_BSTRC("Rendition")) {
return m_pDict->GetInteger("OP");
- } else if (csType == FX_BSTRC("Movie")) {
+ }
+ if (csType == FX_BSTRC("Movie")) {
CFX_ByteString csOP = m_pDict->GetString("Operation");
if (csOP == FX_BSTRC("Play")) {
return 0;
- } else if (csOP == FX_BSTRC("Stop")) {
+ }
+ if (csOP == FX_BSTRC("Stop")) {
return 1;
- } else if (csOP == FX_BSTRC("Pause")) {
+ }
+ if (csOP == FX_BSTRC("Pause")) {
return 2;
- } else if (csOP == FX_BSTRC("Resume")) {
+ }
+ if (csOP == FX_BSTRC("Resume")) {
return 3;
}
}
diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
index 2d991b39c2..f94a4d60e0 100644
--- a/core/src/fpdfdoc/doc_ap.cpp
+++ b/core/src/fpdfdoc/doc_ap.cpp
@@ -17,13 +17,13 @@ FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
if (field_type == "Tx") {
return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict);
- } else if (field_type == "Ch") {
- if (flags & (1 << 17)) {
- return CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict);
- } else {
- return CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict);
- }
- } else if (field_type == "Btn") {
+ }
+ if (field_type == "Ch") {
+ return (flags & (1 << 17)) ?
+ CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict) :
+ CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict);
+ }
+ if (field_type == "Btn") {
if (!(flags & (1 << 16))) {
if (!pAnnotDict->KeyExist("AS")) {
if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDict("Parent")) {
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp
index 9d31d15624..3ba109b016 100644
--- a/core/src/fpdfdoc/doc_basic.cpp
+++ b/core/src/fpdfdoc/doc_basic.cpp
@@ -148,13 +148,12 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, int nIndex, int& nCur
if (nIndex >= nCurIndex + nCount) {
nCurIndex += nCount;
return NULL;
- } else {
- if (ppFind != NULL) {
- *ppFind = pNames;
- }
- csName = pNames->GetString((nIndex - nCurIndex) * 2);
- return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1);
}
+ if (ppFind != NULL) {
+ *ppFind = pNames;
+ }
+ csName = pNames->GetString((nIndex - nCurIndex) * 2);
+ return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1);
}
CPDF_Array* pKids = pNode->GetArray(FX_BSTRC("Kids"));
if (pKids == NULL) {
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 2b59bee6ee..735231cc1d 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -354,12 +354,11 @@ static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe,
{
if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) {
return 1;
- } else {
- LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
- memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
- pData->bFind = TRUE;
- return 0;
}
+ LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
+ memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
+ pData->bFind = TRUE;
+ return 0;
}
static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf)
{
@@ -697,41 +696,39 @@ int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte
{
const FX_CHAR* ptr1 = name1;
const FX_CHAR* ptr2 = name2;
- if (name1.GetLength() != name2.GetLength()) {
- int i = 0;
- while (ptr1[i] == ptr2[i]) {
- i ++;
- }
- if (i == name1.GetLength()) {
- return 2;
- }
- if (i == name2.GetLength()) {
- return 3;
- }
- return 0;
- } else {
+ if (name1.GetLength() == name2.GetLength()) {
return name1 == name2 ? 1 : 0;
}
+ int i = 0;
+ while (ptr1[i] == ptr2[i]) {
+ i ++;
+ }
+ if (i == name1.GetLength()) {
+ return 2;
+ }
+ if (i == name2.GetLength()) {
+ return 3;
+ }
+ return 0;
}
int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2)
{
const FX_WCHAR* ptr1 = name1.c_str();
const FX_WCHAR* ptr2 = name2.c_str();
- if (name1.GetLength() != name2.GetLength()) {
- int i = 0;
- while (ptr1[i] == ptr2[i]) {
- i ++;
- }
- if (i == name1.GetLength()) {
- return 2;
- }
- if (i == name2.GetLength()) {
- return 3;
- }
- return 0;
- } else {
+ if (name1.GetLength() == name2.GetLength()) {
return name1 == name2 ? 1 : 0;
}
+ int i = 0;
+ while (ptr1[i] == ptr2[i]) {
+ i ++;
+ }
+ if (i == name1.GetLength()) {
+ return 2;
+ }
+ if (i == name2.GetLength()) {
+ return 3;
+ }
+ return 0;
}
FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString &csFieldName)
{
@@ -900,115 +897,104 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict)
}
FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName) const
{
- if (m_pFormDict == NULL) {
+ if (!m_pFormDict) {
return 0;
}
CPDF_Array* pArray = m_pFormDict->GetArray("Fields");
- if (pArray == NULL) {
+ if (!pArray) {
return 0;
}
if (csFieldName.IsEmpty()) {
return pArray->GetCount();
- } else {
- int iLength = csFieldName.GetLength();
- int iPos = 0;
- CPDF_Dictionary* pDict = NULL;
- while (pArray != NULL) {
- CFX_WideString csSub;
- if (iPos < iLength && csFieldName[iPos] == L'.') {
- iPos ++;
- }
- while (iPos < iLength && csFieldName[iPos] != L'.') {
- csSub += csFieldName[iPos ++];
- }
- int iCount = pArray->GetCount();
- FX_BOOL bFind = FALSE;
- for (int i = 0; i < iCount; i ++) {
- pDict = pArray->GetDict(i);
- if (pDict == NULL) {
- continue;
- }
- CFX_WideString csT = pDict->GetUnicodeText("T");
- if (csT == csSub) {
- bFind = TRUE;
- break;
- }
- }
- if (!bFind) {
- return 0;
+ }
+ int iLength = csFieldName.GetLength();
+ int iPos = 0;
+ CPDF_Dictionary* pDict = NULL;
+ while (pArray != NULL) {
+ CFX_WideString csSub;
+ if (iPos < iLength && csFieldName[iPos] == L'.') {
+ iPos ++;
+ }
+ while (iPos < iLength && csFieldName[iPos] != L'.') {
+ csSub += csFieldName[iPos ++];
+ }
+ int iCount = pArray->GetCount();
+ FX_BOOL bFind = FALSE;
+ for (int i = 0; i < iCount; i ++) {
+ pDict = pArray->GetDict(i);
+ if (pDict == NULL) {
+ continue;
}
- if (iPos >= iLength) {
+ CFX_WideString csT = pDict->GetUnicodeText("T");
+ if (csT == csSub) {
+ bFind = TRUE;
break;
}
- pArray = pDict->GetArray("Kids");
}
- if (pDict == NULL) {
+ if (!bFind) {
return 0;
- } else {
- pArray = pDict->GetArray("Kids");
- if (pArray == NULL) {
- return 1;
- } else {
- return pArray->GetCount();
- }
}
+ if (iPos >= iLength) {
+ break;
+ }
+ pArray = pDict->GetArray("Kids");
+ }
+ if (!pDict) {
+ return 0;
}
+ pArray = pDict->GetArray("Kids");
+ return pArray ? pArray->GetCount() : 1;
}
+
CPDF_Dictionary* CPDF_InterForm::GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName) const
{
- if (m_pFormDict == NULL) {
- return NULL;
+ if (!m_pFormDict) {
+ return nullptr;
}
CPDF_Array* pArray = m_pFormDict->GetArray("Fields");
- if (pArray == NULL) {
- return 0;
+ if (!pArray) {
+ return nullptr;
}
if (csFieldName.IsEmpty()) {
return pArray->GetDict(index);
- } else {
- int iLength = csFieldName.GetLength();
- int iPos = 0;
- CPDF_Dictionary* pDict = NULL;
- while (pArray != NULL) {
- CFX_WideString csSub;
- if (iPos < iLength && csFieldName[iPos] == L'.') {
- iPos ++;
- }
- while (iPos < iLength && csFieldName[iPos] != L'.') {
- csSub += csFieldName[iPos ++];
- }
- int iCount = pArray->GetCount();
- FX_BOOL bFind = FALSE;
- for (int i = 0; i < iCount; i ++) {
- pDict = pArray->GetDict(i);
- if (pDict == NULL) {
- continue;
- }
- CFX_WideString csT = pDict->GetUnicodeText("T");
- if (csT == csSub) {
- bFind = TRUE;
- break;
- }
- }
- if (!bFind) {
- return NULL;
+ }
+ int iLength = csFieldName.GetLength();
+ int iPos = 0;
+ CPDF_Dictionary* pDict = NULL;
+ while (pArray != NULL) {
+ CFX_WideString csSub;
+ if (iPos < iLength && csFieldName[iPos] == L'.') {
+ iPos ++;
+ }
+ while (iPos < iLength && csFieldName[iPos] != L'.') {
+ csSub += csFieldName[iPos ++];
+ }
+ int iCount = pArray->GetCount();
+ FX_BOOL bFind = FALSE;
+ for (int i = 0; i < iCount; i ++) {
+ pDict = pArray->GetDict(i);
+ if (pDict == NULL) {
+ continue;
}
- if (iPos >= iLength) {
+ CFX_WideString csT = pDict->GetUnicodeText("T");
+ if (csT == csSub) {
+ bFind = TRUE;
break;
}
- pArray = pDict->GetArray("Kids");
}
- if (pDict == NULL) {
+ if (!bFind) {
return NULL;
- } else {
- pArray = pDict->GetArray("Kids");
- if (pArray == NULL) {
- return pDict;
- } else {
- return pArray->GetDict(index);
- }
}
+ if (iPos >= iLength) {
+ break;
+ }
+ pArray = pDict->GetArray("Kids");
+ }
+ if (!pDict) {
+ return nullptr;
}
+ pArray = pDict->GetArray("Kids");
+ return pArray ? pArray->GetDict(index) : pDict;
}
FX_BOOL CPDF_InterForm::NeedConstructAP()
{
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index 7fa17b8ffa..87eee92c2e 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -262,29 +262,27 @@ CPDF_Action CPDF_FormControl::GetAction()
}
CPDF_AAction CPDF_FormControl::GetAdditionalAction()
{
- if (m_pWidgetDict == NULL) {
- return NULL;
+ if (!m_pWidgetDict) {
+ return nullptr;
}
if (m_pWidgetDict->KeyExist("AA")) {
return m_pWidgetDict->GetDict("AA");
- } else {
- return m_pField->GetAdditionalAction();
}
+ return m_pField->GetAdditionalAction();
}
CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance()
{
- if (m_pWidgetDict == NULL) {
+ if (!m_pWidgetDict) {
return CFX_ByteString();
}
if (m_pWidgetDict->KeyExist("DA")) {
return m_pWidgetDict->GetString("DA");
- } else {
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA");
- if (pObj == NULL) {
- return m_pField->m_pForm->GetDefaultAppearance();
- }
- return pObj->GetString();
}
+ CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA");
+ if (!pObj) {
+ return m_pField->m_pForm->GetDefaultAppearance();
+ }
+ return pObj->GetString();
}
CPDF_Font* CPDF_FormControl::GetDefaultControlFont()
@@ -333,18 +331,17 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont()
int CPDF_FormControl::GetControlAlignment()
{
- if (m_pWidgetDict == NULL) {
+ if (!m_pWidgetDict) {
return 0;
}
if (m_pWidgetDict->KeyExist("Q")) {
return m_pWidgetDict->GetInteger("Q", 0);
- } else {
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q");
- if (pObj == NULL) {
- return m_pField->m_pForm->GetFormAlignment();
- }
- return pObj->GetInteger();
}
+ CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q");
+ if (pObj == NULL) {
+ return m_pField->m_pForm->GetFormAlignment();
+ }
+ return pObj->GetInteger();
}
FX_BOOL CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry)
{
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp
index d1acab8e81..087eba8aa4 100644
--- a/core/src/fpdfdoc/doc_formfield.cpp
+++ b/core/src/fpdfdoc/doc_formfield.cpp
@@ -472,14 +472,15 @@ int CPDF_FormField::GetSelectedIndex(int index)
return -1;
}
}
+ if (pValue->GetType() == PDFOBJ_NUMBER) {
+ return pValue->GetInteger();
+ }
CFX_WideString sel_value;
if (pValue->GetType() == PDFOBJ_STRING) {
if (index != 0) {
return -1;
}
sel_value = pValue->GetUnicodeText();
- } else if (pValue->GetType() == PDFOBJ_NUMBER) {
- return pValue->GetInteger();
} else {
if (pValue->GetType() != PDFOBJ_ARRAY) {
return -1;
diff --git a/core/src/fpdfdoc/doc_metadata.cpp b/core/src/fpdfdoc/doc_metadata.cpp
index 211bc25329..aeeb1d1f60 100644
--- a/core/src/fpdfdoc/doc_metadata.cpp
+++ b/core/src/fpdfdoc/doc_metadata.cpp
@@ -112,7 +112,8 @@ int32_t CPDF_Metadata::GetString(const CFX_ByteStringC& bsItem, CFX_WideString &
}
wsStr = pElmnt->GetContent(0);
return wsStr.GetLength();
- } else if (bsItem == FX_BSTRC("Author")) {
+ }
+ if (bsItem == FX_BSTRC("Author")) {
CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag);
if (!pElmnt) {
continue;
@@ -127,14 +128,13 @@ int32_t CPDF_Metadata::GetString(const CFX_ByteStringC& bsItem, CFX_WideString &
}
wsStr = pElmnt->GetContent(0);
return wsStr.GetLength();
- } else {
- CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag);
- if (!pElmnt) {
- continue;
- }
- wsStr = pElmnt->GetContent(0);
- return wsStr.GetLength();
}
+ CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag);
+ if (!pElmnt) {
+ continue;
+ }
+ wsStr = pElmnt->GetContent(0);
+ return wsStr.GetLength();
}
return -1;
}
diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp
index 8477cb85d0..d525227219 100644
--- a/core/src/fpdfdoc/doc_ocg.cpp
+++ b/core/src/fpdfdoc/doc_ocg.cpp
@@ -207,11 +207,11 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, i
}
if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) {
return !(bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) : GetOCGVisible((CPDF_Dictionary*)pOCGObj));
- } else if (pOCGObj->GetType() == PDFOBJ_ARRAY) {
+ }
+ if (pOCGObj->GetType() == PDFOBJ_ARRAY) {
return !GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1);
- } else {
- return FALSE;
}
+ return FALSE;
}
if (csOperator == FX_BSTRC("Or") || csOperator == FX_BSTRC("And")) {
FX_BOOL bValue = FALSE;
@@ -286,15 +286,14 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL
}
FX_BOOL CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary *pOCGDict)
{
- if (pOCGDict == NULL) {
+ if (!pOCGDict) {
return TRUE;
}
CFX_ByteString csType = pOCGDict->GetString(FX_BSTRC("Type"), FX_BSTRC("OCG"));
if (csType == FX_BSTRC("OCG")) {
return GetOCGVisible(pOCGDict);
- } else {
- return LoadOCMDState(pOCGDict, FALSE);
}
+ return LoadOCMDState(pOCGDict, FALSE);
}
void CPDF_OCContext::ResetOCContext()
{
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index 10ca14697d..96d2ccf689 100644
--- a/core/src/fpdfdoc/doc_utils.cpp
+++ b/core/src/fpdfdoc/doc_utils.cpp
@@ -655,15 +655,17 @@ CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pD
}
CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod()
{
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return Always;
}
CFX_ByteString csSW = m_pDict->GetString("SW", "A");
if (csSW == "B") {
return Bigger;
- } else if (csSW == "S") {
+ }
+ if (csSW == "S") {
return Smaller;
- } else if (csSW == "N") {
+ }
+ if (csSW == "N") {
return Never;
}
return Always;
diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp
index c6fdf0e3e7..230ba764e4 100644
--- a/core/src/fpdfdoc/doc_vt.cpp
+++ b/core/src/fpdfdoc/doc_vt.cpp
@@ -95,9 +95,8 @@ CPVT_FloatRect CSection::Rearrange()
ASSERT(m_pVT != NULL);
if (m_pVT->m_nCharArray > 0) {
return CTypeset(this).CharArray();
- } else {
- return CTypeset(this).Typeset();
}
+ return CTypeset(this).Typeset();
}
CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize)
{
@@ -107,17 +106,15 @@ CPVT_WordPlace CSection::GetBeginWordPlace() const
{
if (CLine * pLine = m_LineArray.GetAt(0)) {
return pLine->GetBeginWordPlace();
- } else {
- return SecPlace;
}
+ return SecPlace;
}
CPVT_WordPlace CSection::GetEndWordPlace() const
{
if (CLine * pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) {
return pLine->GetEndWordPlace();
- } else {
- return SecPlace;
}
+ return SecPlace;
}
CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const
{
@@ -130,7 +127,8 @@ CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const
if (CLine * pLine = m_LineArray.GetAt(place.nLineIndex)) {
if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) {
return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1);
- } else if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
+ }
+ if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
if (CLine * pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) {
return pPrevLine->GetEndWordPlace();
}
@@ -571,17 +569,23 @@ static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord)
{
if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit(curWord))) {
return FALSE;
- } else if (IsSpace(curWord) || IsPunctuation(curWord)) {
+ }
+ if (IsSpace(curWord) || IsPunctuation(curWord)) {
return FALSE;
- } else if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) {
+ }
+ if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) {
return FALSE;
- } else if (IsSpace(prevWord) || IsPunctuation(prevWord)) {
+ }
+ if (IsSpace(prevWord) || IsPunctuation(prevWord)) {
return TRUE;
- } else if (IsPrefixSymbol(prevWord)) {
+ }
+ if (IsPrefixSymbol(prevWord)) {
return FALSE;
- } else if (IsPrefixSymbol(curWord) || IsCJK(curWord)) {
+ }
+ if (IsPrefixSymbol(curWord) || IsCJK(curWord)) {
return TRUE;
- } else if (IsCJK(prevWord)) {
+ }
+ if (IsCJK(prevWord)) {
return TRUE;
}
return FALSE;
@@ -868,11 +872,9 @@ CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO
CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps) : new CPVT_WordProps();
pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFontIndex);
return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps));
- } else {
- int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex());
- return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL));
}
- return place;
+ int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex());
+ return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL));
}
CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps,
const CPVT_WordProps * pWordProps)
@@ -1120,12 +1122,10 @@ CPVT_WordPlace CPDF_VariableText::GetPrevWordPlace(const CPVT_WordPlace & place)
if (place.WordCmp(pSection->GetBeginWordPlace()) <= 0) {
if (CSection * pPrevSection = m_SectionArray.GetAt(place.nSecIndex - 1)) {
return pPrevSection->GetEndWordPlace();
- } else {
- return GetBeginWordPlace();
}
- } else {
- return pSection->GetPrevWordPlace(place);
+ return GetBeginWordPlace();
}
+ return pSection->GetPrevWordPlace(place);
}
return place;
}
@@ -1141,12 +1141,10 @@ CPVT_WordPlace CPDF_VariableText::GetNextWordPlace(const CPVT_WordPlace & place)
if (place.WordCmp(pSection->GetEndWordPlace()) >= 0) {
if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) {
return pNextSection->GetBeginWordPlace();
- } else {
- return GetEndWordPlace();
}
- } else {
- return pSection->GetNextWordPlace(place);
+ return GetEndWordPlace();
}
+ return pSection->GetNextWordPlace(place);
}
return place;
}
@@ -1201,12 +1199,11 @@ CPVT_WordPlace CPDF_VariableText::GetUpWordPlace(const CPVT_WordPlace & place, c
CPDF_Point pt = OutToIn(point);
if (temp.nLineIndex-- > 0) {
return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp);
- } else {
- if (temp.nSecIndex-- > 0) {
- if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex)) {
- temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1;
- return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecInfo.rcSection.left, temp);
- }
+ }
+ if (temp.nSecIndex-- > 0) {
+ if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex)) {
+ temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1;
+ return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecInfo.rcSection.left, temp);
}
}
}
@@ -1219,12 +1216,11 @@ CPVT_WordPlace CPDF_VariableText::GetDownWordPlace(const CPVT_WordPlace & place,
CPDF_Point pt = OutToIn(point);
if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) {
return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp);
- } else {
- if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) {
- if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex)) {
- temp.nLineIndex = 0;
- return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp);
- }
+ }
+ if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) {
+ if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex)) {
+ temp.nLineIndex = 0;
+ return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp);
}
}
}
@@ -1236,10 +1232,10 @@ CPVT_WordPlace CPDF_VariableText::GetLineBeginPlace(const CPVT_WordPlace & place
}
CPVT_WordPlace CPDF_VariableText::GetLineEndPlace(const CPVT_WordPlace & place) const
{
- if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex))
- if (CLine * pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) {
+ if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) {
+ if (CLine* pLine = pSection->m_LineArray.GetAt(place.nLineIndex))
return pLine->GetEndWordPlace();
- }
+ }
return place;
}
CPVT_WordPlace CPDF_VariableText::GetSectionBeginPlace(const CPVT_WordPlace & place) const
@@ -1436,11 +1432,7 @@ void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place)
CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const
{
if (place.nWordIndex < 0 && place.nLineIndex > 0) {
- if (bPrevOrNext) {
- return GetPrevWordPlace(place);
- } else {
- return GetNextWordPlace(place);
- }
+ return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place);
}
return place;
}
@@ -1636,14 +1628,13 @@ CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place
}
int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord, int32_t nWordStyle)
{
- if (m_pVTProvider) {
- if (SubWord > 0) {
- return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle);
- } else {
- return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle);
- }
+ if (!m_pVTProvider) {
+ return 0;
+ }
+ if (SubWord > 0) {
+ return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle);
}
- return 0;
+ return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle);
}
int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex)
{
@@ -1698,7 +1689,6 @@ void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place)
}
FX_BOOL CPDF_VariableText_Iterator::NextWord()
{
- ASSERT(m_pVT != NULL);
if (m_CurPos == m_pVT->GetEndWordPlace()) {
return FALSE;
}
@@ -1707,7 +1697,6 @@ FX_BOOL CPDF_VariableText_Iterator::NextWord()
}
FX_BOOL CPDF_VariableText_Iterator::PrevWord()
{
- ASSERT(m_pVT != NULL);
if (m_CurPos == m_pVT->GetBeginWordPlace()) {
return FALSE;
}
@@ -1716,33 +1705,29 @@ FX_BOOL CPDF_VariableText_Iterator::PrevWord()
}
FX_BOOL CPDF_VariableText_Iterator::NextLine()
{
- ASSERT(m_pVT != NULL);
if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) {
m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1);
return TRUE;
- } else {
- if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) {
- m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1);
- return TRUE;
- }
+ }
+ if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) {
+ m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1);
+ return TRUE;
}
}
return FALSE;
}
FX_BOOL CPDF_VariableText_Iterator::PrevLine()
{
- ASSERT(m_pVT != NULL);
if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
if (m_CurPos.nLineIndex > 0) {
m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1);
return TRUE;
- } else {
- if (m_CurPos.nSecIndex > 0) {
- if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) {
- m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->m_LineArray.GetSize() - 1, -1);
- return TRUE;
- }
+ }
+ if (m_CurPos.nSecIndex > 0) {
+ if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) {
+ m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->m_LineArray.GetSize() - 1, -1);
+ return TRUE;
}
}
}
@@ -1750,7 +1735,6 @@ FX_BOOL CPDF_VariableText_Iterator::PrevLine()
}
FX_BOOL CPDF_VariableText_Iterator::NextSection()
{
- ASSERT(m_pVT != NULL);
if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) {
m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1);
return TRUE;
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 6755939ca2..c1aaad8b5c 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -42,9 +42,11 @@ FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold)
{
if (threshold < 300) {
return threshold / 2.0f;
- } else if (threshold < 500) {
+ }
+ if (threshold < 500) {
return threshold / 4.0f;
- } else if (threshold < 700) {
+ }
+ if (threshold < 700) {
return threshold / 5.0f;
}
return threshold / 6.0f;
@@ -159,12 +161,9 @@ void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize)
{
m_ParseOptions.m_bNormalizeObjs = bNormalize;
}
-FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo)
+bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo)
{
- if(!pCharInfo) {
- return FALSE;
- }
- switch(pCharInfo->m_Unicode) {
+ switch (charInfo.m_Unicode) {
case 0x2:
case 0x3:
case 0x93:
@@ -173,13 +172,9 @@ FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo)
case 0x97:
case 0x98:
case 0xfffe:
- if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) {
- return FALSE;
- } else {
- return TRUE;
- }
+ return charInfo.m_Flag != FPDFTEXT_CHAR_HYPHEN;
default:
- return FALSE;
+ return false;
}
}
FX_BOOL CPDF_TextPage::ParseTextPage()
@@ -207,7 +202,7 @@ FX_BOOL CPDF_TextPage::ParseTextPage()
if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
bNormal = TRUE;
}
- else if(charinfo.m_Unicode == 0 || IsControlChar(&charinfo))
+ else if(charinfo.m_Unicode == 0 || IsControlChar(charinfo))
bNormal = FALSE;
else {
bNormal = TRUE;
@@ -492,141 +487,6 @@ int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance, FX
CPDF_Point point(x, y);
return GetIndexAtPos(point, xTorelance, yTorelance);
}
-int CPDF_TextPage::GetOrderByDirection(int order, int direction) const
-{
- if(m_ParseOptions.m_bGetCharCodeOnly) {
- return -3;
- }
- if (!m_IsParsered) {
- return -3;
- }
- if (direction == FPDFTEXT_RIGHT || direction == FPDFTEXT_LEFT) {
- order += direction;
- while(order >= 0 && order < m_charList.GetSize()) {
- PAGECHAR_INFO cinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order);
- if (cinfo.m_Flag != FPDFTEXT_CHAR_GENERATED) {
- break;
- } else {
- if (cinfo.m_Unicode == TEXT_LINEFEED_CHAR || cinfo.m_Unicode == TEXT_RETURN_CHAR) {
- order += direction;
- } else {
- break;
- }
- }
- }
- if (order >= m_charList.GetSize()) {
- order = -2;
- }
- return order;
- }
- PAGECHAR_INFO charinfo;
- charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order);
- CPDF_Point curPos(charinfo.m_OriginX, charinfo.m_OriginY);
- FX_FLOAT difPosY = 0.0, minXdif = 1000;
- int minIndex = -2;
- int index = order;
- FX_FLOAT height = charinfo.m_CharBox.Height();
- if (direction == FPDFTEXT_UP) {
- minIndex = -1;
- while (1) {
- if (--index < 0) {
- return -1;
- }
- charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
- if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, charinfo.m_CharBox.Height()) / 2) {
- difPosY = charinfo.m_OriginY;
- minIndex = index;
- break;
- }
- }
- FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x;
- minXdif = PreXdif;
- if (PreXdif == 0) {
- return index;
- }
- FX_FLOAT curXdif = 0;
- while (--index >= 0) {
- charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
- if (difPosY != charinfo.m_OriginY) {
- break;
- }
- curXdif = charinfo.m_OriginX - curPos.x;
- if (curXdif == 0) {
- return index;
- }
- int signflag = 0;
- if (curXdif > 0) {
- signflag = 1;
- } else {
- signflag = -1;
- }
- if (signflag * PreXdif < 0) {
- if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) {
- return index + 1;
- } else {
- return index;
- }
- }
- if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) {
- minIndex = index;
- minXdif = curXdif;
- }
- PreXdif = curXdif;
- if (difPosY != charinfo.m_OriginY) {
- break;
- }
- }
- return minIndex;
- } else if(FPDFTEXT_DOWN) {
- minIndex = -2;
- while (1) {
- if (++index > m_charList.GetSize() - 1) {
- return minIndex;
- }
- charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
- if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, charinfo.m_CharBox.Height()) / 2) {
- difPosY = charinfo.m_OriginY;
- minIndex = index;
- break;
- }
- }
- FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x;
- minXdif = PreXdif;
- if (PreXdif == 0) {
- return index;
- }
- FX_FLOAT curXdif = 0;
- while (++index < m_charList.GetSize()) {
- charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
- if (difPosY != charinfo.m_OriginY) {
- break;
- }
- curXdif = charinfo.m_OriginX - curPos.x;
- if (curXdif == 0) {
- return index;
- }
- int signflag = 0;
- if (curXdif > 0) {
- signflag = 1;
- } else {
- signflag = -1;
- }
- if (signflag * PreXdif < 0) {
- if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) {
- return index - 1;
- } else {
- return index;
- }
- }
- if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) {
- minXdif = curXdif;
- minIndex = index;
- }
- PreXdif = curXdif;
- }
- return minIndex;
- }
-}
void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const
{
if(m_ParseOptions.m_bGetCharCodeOnly) {
@@ -952,7 +812,6 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const
return breakPos;
}
}
- return breakPos;
} else if (direction == FPDFTEXT_RIGHT) {
while (++breakPos < m_charList.GetSize()) {
charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos);
@@ -960,7 +819,6 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const
return breakPos;
}
}
- return breakPos;
}
return breakPos;
}
@@ -1161,7 +1019,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i)
{
PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
FX_WCHAR wChar = str.GetAt(i);
- if(!IsControlChar(&Info)) {
+ if(!IsControlChar(Info)) {
Info.m_Index = m_TextBuf.GetLength();
if (wChar >= 0xFB00 && wChar <= 0xFB06) {
FX_WCHAR* pDst = NULL;
@@ -1193,7 +1051,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i)
void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i)
{
PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
- if(!IsControlChar(&Info)) {
+ if(!IsControlChar(Info)) {
Info.m_Index = m_TextBuf.GetLength();
FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE);
FX_WCHAR* pDst = NULL;
@@ -1212,9 +1070,8 @@ void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i)
}
FX_Free(pDst);
return;
- } else {
- Info.m_Unicode = wChar;
}
+ Info.m_Unicode = wChar;
m_TextBuf.AppendChar(Info.m_Unicode);
} else {
Info.m_Index = -1;
@@ -1915,11 +1772,9 @@ int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj)
v.Set(dX, dY);
v.Normalize();
if (v.y <= 0.0872f) {
- if (v.x <= 0.0872f) {
- return m_TextlineDir;
- }
- return 0;
- } else if (v.x <= 0.0872f) {
+ return v.x <= 0.0872f ? m_TextlineDir : 0;
+ }
+ if (v.x <= 0.0872f) {
return 1;
}
return m_TextlineDir;
@@ -2698,22 +2553,25 @@ FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck)
if (str.Find(L"http://www.") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www."));
return TRUE;
- } else if (str.Find(L"http://") != -1) {
+ }
+ if (str.Find(L"http://") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://"));
return TRUE;
- } else if (str.Find(L"https://www.") != -1) {
+ }
+ if (str.Find(L"https://www.") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www."));
return TRUE;
- } else if (str.Find(L"https://") != -1) {
+ }
+ if (str.Find(L"https://") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://"));
return TRUE;
- } else if (str.Find(L"www.") != -1) {
+ }
+ if (str.Find(L"www.") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www."));
strBeCheck = L"http://" + strBeCheck;
return TRUE;
- } else {
- return FALSE;
}
+ return FALSE;
}
FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str)
{
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index e2d6af6e98..ce52371df0 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -66,7 +66,6 @@ public:
FX_FLOAT yTorelance) const;
virtual CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const;
virtual void GetRectsArrayByRect(const CFX_FloatRect& rect, CFX_RectArray& resRectArray) const;
- virtual int GetOrderByDirection(int order, int direction) const;
virtual CFX_WideString GetPageText(int start = 0, int nCount = -1) const;
virtual int CountRects(int start, int nCount);
@@ -87,7 +86,7 @@ public:
static FX_BOOL IsLetter(FX_WCHAR unicode);
private:
FX_BOOL IsHyphen(FX_WCHAR curChar);
- FX_BOOL IsControlChar(PAGECHAR_INFO* pCharInfo);
+ bool IsControlChar(const PAGECHAR_INFO& charInfo);
FX_BOOL GetBaselineRotate(int start, int end, int& Rotate);
void ProcessObject();
void ProcessFormObject(CPDF_FormObject* pFormObj, const CFX_AffineMatrix& formMatrix);
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index da503c03fd..7507fe5d6d 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -44,7 +44,8 @@ FX_BOOL CheckComponents(cmsColorSpaceSignature cs, int nComponents, FX_BOOL bDst
case cmsSigGrayData:
if (bDst && nComponents != 1) {
return FALSE;
- } else if (!bDst && nComponents > 2) {
+ }
+ if (!bDst && nComponents > 2) {
return FALSE;
}
break;
diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp
index 7a69a24d40..51184306eb 100644
--- a/core/src/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp
@@ -172,35 +172,34 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, IFX_Pause
{
CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
int ret = m_pJbig2Context->m_pContext->Continue(pPause);
- if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECODE_FINISH) {
- if(m_pJbig2Context->m_bFileReader) {
- CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
- m_pJbig2Context->m_pContext = NULL;
- if (ret != JBIG2_SUCCESS) {
- if(m_pJbig2Context->m_src_buf) {
- FX_Free(m_pJbig2Context->m_src_buf);
- }
- m_pJbig2Context->m_src_buf = NULL;
- return FXCODEC_STATUS_ERROR;
- }
- delete m_pJbig2Context->m_dest_image;
- FX_Free(m_pJbig2Context->m_src_buf);
- return FXCODEC_STATUS_DECODE_FINISH;
- } else {
- CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
- m_pJbig2Context->m_pContext = NULL;
- if (ret != JBIG2_SUCCESS) {
- return FXCODEC_STATUS_ERROR;
- }
- int dword_size = m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4;
- FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf;
- for (int i = 0; i < dword_size; i ++) {
- dword_buf[i] = ~dword_buf[i];
+ if (m_pJbig2Context->m_pContext->GetProcessiveStatus() != FXCODEC_STATUS_DECODE_FINISH) {
+ return m_pJbig2Context->m_pContext->GetProcessiveStatus();
+ }
+ if (m_pJbig2Context->m_bFileReader) {
+ CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
+ m_pJbig2Context->m_pContext = NULL;
+ if (ret != JBIG2_SUCCESS) {
+ if(m_pJbig2Context->m_src_buf) {
+ FX_Free(m_pJbig2Context->m_src_buf);
}
- return FXCODEC_STATUS_DECODE_FINISH;
+ m_pJbig2Context->m_src_buf = NULL;
+ return FXCODEC_STATUS_ERROR;
}
+ delete m_pJbig2Context->m_dest_image;
+ FX_Free(m_pJbig2Context->m_src_buf);
+ return FXCODEC_STATUS_DECODE_FINISH;
}
- return m_pJbig2Context->m_pContext->GetProcessiveStatus();
+ CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
+ m_pJbig2Context->m_pContext = NULL;
+ if (ret != JBIG2_SUCCESS) {
+ return FXCODEC_STATUS_ERROR;
+ }
+ int dword_size = m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4;
+ FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf;
+ for (int i = 0; i < dword_size; i ++) {
+ dword_buf[i] = ~dword_buf[i];
+ }
+ return FXCODEC_STATUS_DECODE_FINISH;
}
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 7666ac6083..b7d9fbe512 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -420,9 +420,11 @@ extern "C" {
int ratio = (iratio_w > iratio_h) ? iratio_h : iratio_w;
if (ratio >= 8) {
return 8;
- } else if (ratio >= 4) {
+ }
+ if (ratio >= 4) {
return 4;
- } else if (ratio >= 2) {
+ }
+ if (ratio >= 2) {
return 2;
}
return 1;
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index 56b2f57f3c..4ab34bb022 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -243,7 +243,8 @@ void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const
ASSERT(m_IndexDepth != 0);
if (m_IndexDepth == 1) {
return (void**)m_pIndex;
- } else if (m_IndexDepth == 2) {
+ }
+ if (m_IndexDepth == 2) {
return (void**)((void**)m_pIndex)[seg_index / m_IndexSize];
}
int tree_size = 1;
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 9f54414110..5eeb33b049 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -132,10 +132,9 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc)
if (stringSrc.IsEmpty()) {
m_pData = NULL;
return;
- } else {
- m_pData = NULL;
- *this = stringSrc;
}
+ m_pData = NULL;
+ *this = stringSrc;
}
CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, const CFX_ByteStringC& str2)
{
@@ -971,13 +970,15 @@ int CFX_ByteString::Compare(const CFX_ByteStringC& str) const
for (int i = 0; i < min_len; i ++) {
if ((uint8_t)m_pData->m_String[i] < str.GetAt(i)) {
return -1;
- } else if ((uint8_t)m_pData->m_String[i] > str.GetAt(i)) {
+ }
+ if ((uint8_t)m_pData->m_String[i] > str.GetAt(i)) {
return 1;
}
}
if (this_len < that_len) {
return -1;
- } else if (this_len > that_len) {
+ }
+ if (this_len > that_len) {
return 1;
}
return 0;
diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp
index f23bf4bc27..26eeacce1b 100644
--- a/core/src/fxcrt/fx_basic_util.cpp
+++ b/core/src/fxcrt/fx_basic_util.cpp
@@ -457,18 +457,18 @@ CFX_Matrix_3by3 CFX_Matrix_3by3::Inverse()
FX_FLOAT det = a*(e*i - f*h) - b*(i*d - f*g) + c*(d*h - e*g);
if (FXSYS_fabs(det) < 0.0000001)
return CFX_Matrix_3by3();
- else
- return CFX_Matrix_3by3(
- (e*i - f*h) / det,
- -(b*i - c*h) / det,
- (b*f - c*e) / det,
- -(d*i - f*g) / det,
- (a*i - c*g) / det,
- -(a*f - c*d) / det,
- (d*h - e*g) / det,
- -(a*h - b*g) / det,
- (a*e - b*d) / det
- );
+
+ return CFX_Matrix_3by3(
+ (e*i - f*h) / det,
+ -(b*i - c*h) / det,
+ (b*f - c*e) / det,
+ -(d*i - f*g) / det,
+ (a*i - c*g) / det,
+ -(a*f - c*d) / det,
+ (d*h - e*g) / det,
+ -(a*h - b*g) / det,
+ (a*e - b*d) / det
+ );
}
CFX_Matrix_3by3 CFX_Matrix_3by3::Multiply(const CFX_Matrix_3by3 &m)
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 2442daed27..b6b595588d 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -485,7 +485,8 @@ int CFX_WideString::Compare(const CFX_WideString& str) const
return 0;
}
return -1;
- } else if (str.m_pData == NULL) {
+ }
+ if (str.m_pData == NULL) {
return 1;
}
int this_len = m_pData->m_nDataLength;
@@ -494,13 +495,15 @@ int CFX_WideString::Compare(const CFX_WideString& str) const
for (int i = 0; i < min_len; i ++) {
if (m_pData->m_String[i] < str.m_pData->m_String[i]) {
return -1;
- } else if (m_pData->m_String[i] > str.m_pData->m_String[i]) {
+ }
+ if (m_pData->m_String[i] > str.m_pData->m_String[i]) {
return 1;
}
}
if (this_len < that_len) {
return -1;
- } else if (this_len > that_len) {
+ }
+ if (this_len > that_len) {
return 1;
}
return 0;
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp
index 475e5f6442..118db7bf1f 100644
--- a/core/src/fxge/agg/src/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/src/fx_agg_driver.cpp
@@ -417,7 +417,8 @@ public:
}
}
return;
- } else if (Bpp == 3 || Bpp == 4) {
+ }
+ if (Bpp == 3 || Bpp == 4) {
for (int col = col_start; col < col_end; col ++) {
int src_alpha;
if (clip_scan) {
@@ -479,7 +480,8 @@ public:
}
}
return;
- } else if (Bpp == 3 || Bpp == 4) {
+ }
+ if (Bpp == 3 || Bpp == 4) {
for (int col = col_start; col < col_end; col ++) {
int src_alpha;
if (clip_scan) {
@@ -508,7 +510,8 @@ public:
continue;
}
return;
- } else if (Bpp == 1) {
+ }
+ if (Bpp == 1) {
for (int col = col_start; col < col_end; col ++) {
int src_alpha;
if (clip_scan) {
diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp
index 19a870ade3..cb99a37ff4 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -3938,7 +3938,8 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui
if (m_SrcFormat == FXDIB_1bppRgb) {
if (m_DestFormat == FXDIB_8bppRgb) {
return;
- } else if(m_DestFormat == FXDIB_Argb) {
+ }
+ if(m_DestFormat == FXDIB_Argb) {
_CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder(dest_scan, src_scan, src_left, width, m_pSrcPalette, clip_scan);
} else {
_CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_scan, src_left, m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan);
@@ -3946,7 +3947,8 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui
} else {
if (m_DestFormat == FXDIB_8bppRgb) {
return;
- } else if (m_DestFormat == FXDIB_Argb) {
+ }
+ if (m_DestFormat == FXDIB_Argb) {
_CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder(dest_scan, src_scan, width, m_pSrcPalette, clip_scan);
} else {
_CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_scan, m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan);
@@ -3957,7 +3959,8 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui
if (m_DestFormat == FXDIB_8bppMask) {
_CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan);
return;
- } else if ((m_DestFormat & 0xff) == 8) {
+ }
+ if ((m_DestFormat & 0xff) == 8) {
if (m_Transparency & 8) {
if (m_DestFormat & 0x0200) {
_CompositeRow_1bppPal2Graya(dest_scan, src_scan, src_left, (const uint8_t*)m_pSrcPalette, width, m_BlendType, clip_scan, dst_extra_alpha);
@@ -4208,7 +4211,8 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, int top, int width, int height, FX
}
}
return TRUE;
- } else if (m_bpp == 1) {
+ }
+ if (m_bpp == 1) {
ASSERT(!IsCmykImage() && (uint8_t)(alpha_flag >> 8) == 0);
int left_shift = rect.left % 8;
int right_shift = rect.right % 8;
diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp
index 8e96379d37..d7860aee19 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -843,12 +843,14 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc
return _ConvertBuffer_1bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return _ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top);
- } else if ((src_format & 0xff) == 8) {
+ }
+ if ((src_format & 0xff) == 8) {
if (pSrcBitmap->GetPalette()) {
return _ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return _ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top);
- } else if ((src_format & 0xff) >= 24) {
+ }
+ if ((src_format & 0xff) >= 24) {
return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return FALSE;
@@ -861,7 +863,8 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc
d_pal = FX_Alloc(FX_DWORD, 256);
if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pSrcBitmap->GetPalette()) {
return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
- } else if ((src_format & 0xff) >= 24) {
+ }
+ if ((src_format & 0xff) >= 24) {
return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
}
return FALSE;
@@ -873,14 +876,17 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc
return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top);
- } else if ((src_format & 0xff) == 8) {
+ }
+ if ((src_format & 0xff) == 8) {
if (pSrcBitmap->GetPalette()) {
return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top);
- } else if ((src_format & 0xff) == 24) {
+ }
+ if ((src_format & 0xff) == 24) {
return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
- } else if ((src_format & 0xff) == 32) {
+ }
+ if ((src_format & 0xff) == 32) {
return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return FALSE;
@@ -892,12 +898,14 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc
return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top);
- } else if ((src_format & 0xff) == 8) {
+ }
+ if ((src_format & 0xff) == 8) {
if (pSrcBitmap->GetPalette()) {
return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top);
- } else if ((src_format & 0xff) >= 24) {
+ }
+ if ((src_format & 0xff) >= 24) {
if (src_format & 0x0400) {
return _ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp
index 11e9a110cb..7390c431d9 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -346,9 +346,8 @@ FX_BOOL CStretchEngine::ContinueStretchHorz(IFX_Pause* pPause)
if (rows_to_go == 0) {
if (pPause && pPause->NeedToPauseNow()) {
return TRUE;
- } else {
- rows_to_go = FX_STRECH_PAUSE_ROWS;
}
+ rows_to_go = FX_STRECH_PAUSE_ROWS;
}
const uint8_t* src_scan = m_pSource->GetScanline(m_CurRow);
uint8_t* dest_scan = m_pInterBuf + (m_CurRow - m_SrcClip.top) * m_InterPitch;
@@ -745,17 +744,15 @@ FX_BOOL CFX_ImageStretcher::Start(IFX_ScanlineComposer* pDest,
}
if (flags & FXDIB_DOWNSAMPLE) {
return StartQuickStretch();
- } else {
- return StartStretch();
}
+ return StartStretch();
}
FX_BOOL CFX_ImageStretcher::Continue(IFX_Pause* pPause)
{
if (m_Flags & FXDIB_DOWNSAMPLE) {
return ContinueQuickStretch(pPause);
- } else {
- return ContinueStretch(pPause);
}
+ return ContinueStretch(pPause);
}
#define MAX_PROGRESSIVE_STRETCH_PIXELS 1000000
FX_BOOL CFX_ImageStretcher::StartStretch()
diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp
index 82a14974f4..8a864f10a1 100644
--- a/core/src/fxge/dib/fx_dib_main.cpp
+++ b/core/src/fxge/dib/fx_dib_main.cpp
@@ -1033,10 +1033,8 @@ FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const
case FXDIB_1bppRgb: {
if ((*pos) & (1 << (7 - x % 8))) {
return m_pPalette ? m_pPalette[1] : 0xffffffff;
- } else {
- return m_pPalette ? m_pPalette[0] : 0xff000000;
}
- break;
+ return m_pPalette ? m_pPalette[0] : 0xff000000;
}
case FXDIB_8bppMask:
return (*pos) << 24;
@@ -1588,7 +1586,8 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause)
{
if (m_Status == 1) {
return m_Stretcher.Continue(pPause);
- } else if (m_Status == 2) {
+ }
+ if (m_Status == 2) {
if (m_pTransformer->Continue(pPause)) {
return TRUE;
}
diff --git a/core/src/fxge/dib/fx_dib_transform.cpp b/core/src/fxge/dib/fx_dib_transform.cpp
index 423577977c..e34e715bf2 100644
--- a/core/src/fxge/dib/fx_dib_transform.cpp
+++ b/core/src/fxge/dib/fx_dib_transform.cpp
@@ -345,9 +345,11 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause)
m_Storer.Replace(m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0));
}
return FALSE;
- } else if (m_Status == 2) {
+ }
+ if (m_Status == 2) {
return m_Stretcher.Continue(pPause);
- } else if (m_Status != 3) {
+ }
+ if (m_Status != 3) {
return FALSE;
}
if (m_Stretcher.Continue(pPause)) {
diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp
index 793dfc5ee2..0baa99cdc7 100644
--- a/core/src/fxge/ge/fx_ge_device.cpp
+++ b/core/src/fxge/ge/fx_ge_device.cpp
@@ -64,13 +64,14 @@ FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width,
{
if (m_RenderCaps & FXRC_CMYK_OUTPUT) {
return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Cmyka : FXDIB_Cmyk);
- } else if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) {
+ }
+ if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) {
return pDIB->Create(width, height, FXDIB_8bppMask);
- } else
+ }
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32);
+ return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32);
#else
- return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb);
+ return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb);
#endif
}
FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index f88cbaacde..6a950bf20b 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -309,9 +309,8 @@ CFX_ByteString CFX_Font::GetFamilyName() const
}
if (m_Face) {
return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
- } else {
- return m_pSubstFont->m_Family;
}
+ return m_pSubstFont->m_Family;
}
CFX_ByteString CFX_Font::GetFaceName() const
{
@@ -329,9 +328,8 @@ CFX_ByteString CFX_Font::GetFaceName() const
facename += " " + style;
}
return facename;
- } else {
- return m_pSubstFont->m_Family;
}
+ return m_pSubstFont->m_Family;
}
FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox)
{
@@ -410,21 +408,20 @@ FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode)
}
FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encoding)
{
- FXFT_Face face = m_pFont->GetFace();
+ FXFT_Face face = m_pFont->GetFace();
if (!face) {
return charcode;
}
if (encoding == ENCODING_UNICODE) {
- return GlyphFromCharCode(charcode);
- } else {
- int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face);
- int i = 0;
- while (i < nmaps) {
- int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]);
- if (encoding != FXFT_ENCODING_UNICODE) {
- FXFT_Select_Charmap(face, encoding);
- break;
- }
+ return GlyphFromCharCode(charcode);
+ }
+ int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face);
+ int i = 0;
+ while (i < nmaps) {
+ int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]);
+ if (encoding != FXFT_ENCODING_UNICODE) {
+ FXFT_Select_Charmap(face, encoding);
+ break;
}
}
return FXFT_Get_Char_Index(face, charcode);
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index 8956cd1c88..4674589911 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -688,7 +688,8 @@ uint8_t _GetCharsetFromCodePage(FX_WORD codepage)
const CHARSET_MAP & cp = g_Codepage2CharsetTable[iMid];
if (codepage == cp.codepage) {
return cp.charset;
- } else if (codepage < cp.codepage) {
+ }
+ if (codepage < cp.codepage) {
iEnd = iMid - 1;
} else {
iStart = iMid + 1;
@@ -1159,14 +1160,10 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru
m_pFontMgr->GetStandardFont(pFontData, size, 12);
m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0);
return m_FoxitFaces[12];
- } else {
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL;
- return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont);
}
-#else
+#endif
pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL;
return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont);
-#endif
}
if (Charset == FXFONT_ANSI_CHARSET) {
pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
@@ -1175,9 +1172,8 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru
int index = m_CharsetArray.Find(Charset);
if (index < 0) {
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily);
- } else {
- hFont = m_pFontInfo->GetFont(m_FaceArray[index]);
}
+ hFont = m_pFontInfo->GetFont(m_FaceArray[index]);
}
}
pSubstFont->m_ExtHandle = m_pFontInfo->RetainFont(hFont);
diff --git a/core/src/fxge/ge/fx_ge_linux.cpp b/core/src/fxge/ge/fx_ge_linux.cpp
index 631ff8e93f..4e7334596b 100644
--- a/core/src/fxge/ge/fx_ge_linux.cpp
+++ b/core/src/fxge/ge/fx_ge_linux.cpp
@@ -63,15 +63,14 @@ static int32_t GetJapanesePreference(const FX_CHAR* facearr, int weight, int pic
if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
return 0;
- } else {
- return 1;
}
- } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
+ return 1;
+ }
+ if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) {
return 2;
- } else {
- return 3;
}
+ return 3;
}
if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
return 0;
diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp
index ea1d80390b..b1410b3911 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -55,7 +55,8 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, FX_RECT mask_rect, CFX_DIBitma
if (m_Box.IsEmpty()) {
m_Type = RectI;
return;
- } else if (m_Box == mask_rect) {
+ }
+ if (m_Box == mask_rect) {
m_Mask = Mask;
return;
}
@@ -229,7 +230,8 @@ static void _UpdateLineEndPoints(CFX_FloatRect& rect, FX_FLOAT start_x, FX_FLOAT
rect.UpdateRect(end_x + hw, point_y);
rect.UpdateRect(end_x - hw, point_y);
return;
- } else if (start_y == end_y) {
+ }
+ if (start_y == end_y) {
FX_FLOAT point_x;
if (end_x < start_x) {
point_x = end_x - hw;
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index 76c7cf429e..59a4cfb37d 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -1154,38 +1154,37 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
#else
if (text_flags & FXTEXT_NO_NATIVETEXT) {
return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias);
+ }
+ CFX_GlyphBitmap* pGlyphBitmap;
+ CFX_SizeGlyphCache* pSizeCache = NULL;
+ if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
+ if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGlyphBitmap)) {
+ return pGlyphBitmap;
+ }
+ pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias);
+ if (pGlyphBitmap) {
+ pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
+ return pGlyphBitmap;
+ }
} else {
- CFX_GlyphBitmap* pGlyphBitmap;
- CFX_SizeGlyphCache* pSizeCache = NULL;
- if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
- if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGlyphBitmap)) {
- return pGlyphBitmap;
- }
- pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias);
- if (pGlyphBitmap) {
- pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
- return pGlyphBitmap;
- }
- } else {
- pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias);
- if (pGlyphBitmap) {
- pSizeCache = new CFX_SizeGlyphCache;
- m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
- pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
- return pGlyphBitmap;
- }
+ pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias);
+ if (pGlyphBitmap) {
+ pSizeCache = new CFX_SizeGlyphCache;
+ m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
+ pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
+ return pGlyphBitmap;
}
- if (pFont->GetSubstFont())
- keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
- (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias,
- pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical());
- else
- keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
- (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias);
- CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
- text_flags |= FXTEXT_NO_NATIVETEXT;
- return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias);
}
+ if (pFont->GetSubstFont())
+ keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
+ (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias,
+ pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical());
+ else
+ keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
+ (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias);
+ CFX_ByteStringC FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen);
+ text_flags |= FXTEXT_NO_NATIVETEXT;
+ return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index, bFontStyle, dest_width, anti_alias);
#endif
}
CFX_SizeGlyphCache::~CFX_SizeGlyphCache()
diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp
index da9e6f28f1..3437eb497d 100644
--- a/core/src/fxge/skia/fx_skia_blitter_new.cpp
+++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp
@@ -8,1603 +8,1602 @@
#include "../../../include/fxcodec/fx_codec.h"
#include "SkBlitter.h"
#include "fx_skia_blitter_new.h"
- // We use our own renderer here to make it simple
- void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
- {
- FXSYS_assert(m_Alpha);
- if (m_pOriDevice == NULL && composite_span == NULL) return;
- if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return;
- while (1)
- {
- int width = runs[0];
- SkASSERT(width >= 0);
- if (width <= 0)
- return;
- unsigned aa = antialias[0];
- if (aa)
- (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
- runs += width;
- antialias += width;
- x += width;
- }
- }
+ // We use our own renderer here to make it simple
+ void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
+ {
+ FXSYS_assert(m_Alpha);
+ if (m_pOriDevice == NULL && composite_span == NULL) return;
+ if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return;
+ while (1)
+ {
+ int width = runs[0];
+ SkASSERT(width >= 0);
+ if (width <= 0)
+ return;
+ unsigned aa = antialias[0];
+ if (aa)
+ (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
+ runs += width;
+ antialias += width;
+ x += width;
+ }
+ }
- void CFX_SkiaRenderer::blitH(int x, int y, int width)
- {
- FXSYS_assert(m_Alpha && width);
- if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return;
- (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
- }
+ void CFX_SkiaRenderer::blitH(int x, int y, int width)
+ {
+ FXSYS_assert(m_Alpha && width);
+ if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return;
+ (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
+ }
- void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha)
- {
- FXSYS_assert(m_Alpha && alpha);
- if (alpha == 255) {
- blitRect(x, y, 1, height);
- } else {
- int16_t runs[2];
- runs[0] = 1;
- runs[1] = 0;
- while (--height >= 0) {
- if (y >= m_ClipBox.bottom)
- return;
- blitAntiH(x, y ++, &alpha, runs);
- }
- }
- }
- void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height)
- {
- FXSYS_assert(m_Alpha && width);
- while (--height >= 0){
- if (y >= m_ClipBox.bottom)
- return;
- blitH(x, y ++, width);
- }
- }
+ void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha)
+ {
+ FXSYS_assert(m_Alpha && alpha);
+ if (alpha == 255) {
+ blitRect(x, y, 1, height);
+ } else {
+ int16_t runs[2];
+ runs[0] = 1;
+ runs[1] = 0;
+ while (--height >= 0) {
+ if (y >= m_ClipBox.bottom)
+ return;
+ blitAntiH(x, y ++, &alpha, runs);
+ }
+ }
+ }
+ void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height)
+ {
+ FXSYS_assert(m_Alpha && width);
+ while (--height >= 0){
+ if (y >= m_ClipBox.bottom)
+ return;
+ blitH(x, y ++, width);
+ }
+ }
- void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height,
+ void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha)
- {
- blitV(x++, y, height, leftAlpha);
- if (width > 0) {
- blitRect(x, y, width, height);
- x += width;
- }
- blitV(x, y, height, rightAlpha);
- }
- /*---------------------------------------------------------------------------------------------------*/
- void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_bRgbByteOrder);
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start/8;
+ {
+ blitV(x++, y, height, leftAlpha);
+ if (width > 0) {
+ blitRect(x, y, width, height);
+ x += width;
+ }
+ blitV(x, y, height, rightAlpha);
+ }
+ /*---------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start/8;
- int index = 0;
- if (m_pDevice->GetPalette() == NULL)
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- else {
- for (int i = 0; i < 2; i ++)
- if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
- index = i;
- }
- uint8_t* dest_scan1 = dest_scan;
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- if (src_alpha) {
- if (!index)
- *dest_scan1 &= ~(1 << (7 - (col+span_left)%8));
- else
- *dest_scan1|= 1 << (7 - (col+span_left)%8);
- }
- dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8;
- }
- }
- void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_bRgbByteOrder);
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8;
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start/8;
+ int index = 0;
+ if (m_pDevice->GetPalette() == NULL)
+ index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
+ else {
+ for (int i = 0; i < 2; i ++)
+ if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
+ index = i;
+ }
+ uint8_t* dest_scan1 = dest_scan;
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ if (src_alpha) {
+ if (!index)
+ *dest_scan1 &= ~(1 << (7 - (col+span_left)%8));
+ else
+ *dest_scan1|= 1 << (7 - (col+span_left)%8);
+ }
+ dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8;
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start/8;
- int index = 0;
- if (m_pDevice->GetPalette() == NULL)
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- else {
- for (int i = 0; i < 2; i ++)
- if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
- index = i;
- }
- uint8_t* dest_scan1 = dest_scan;
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (src_alpha1) {
- if (!index)
- *dest_scan1 &= ~(1 << (7 - (col+span_left)%8));
- else
- *dest_scan1|= 1 << (7 - (col+span_left)%8);
- }
- dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8;
- }
- }
- /*-----------------------------------------------------------------------------------------------------*/
- void CFX_SkiaRenderer::CompositeSpanGray_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- ASSERT(!m_bRgbByteOrder);
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start;
- if (cover_scan == 255 && m_Alpha == 255) {
- FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
- return;
- }
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
- dest_scan++;
- }
- }
- void CFX_SkiaRenderer::CompositeSpanGray_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- ASSERT(!m_bRgbByteOrder);
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start;
- ori_scan += col_start;
- if (m_Alpha == 255 && cover_scan == 255) {
- FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
- } else {
- int src_alpha = m_Alpha;
+ int index = 0;
+ if (m_pDevice->GetPalette() == NULL)
+ index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
+ else {
+ for (int i = 0; i < 2; i ++)
+ if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
+ index = i;
+ }
+ uint8_t* dest_scan1 = dest_scan;
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (src_alpha1) {
+ if (!index)
+ *dest_scan1 &= ~(1 << (7 - (col+span_left)%8));
+ else
+ *dest_scan1|= 1 << (7 - (col+span_left)%8);
+ }
+ dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8;
+ }
+ }
+ /*-----------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpanGray_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ ASSERT(!m_bRgbByteOrder);
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ if (cover_scan == 255 && m_Alpha == 255) {
+ FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
+ return;
+ }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
+ dest_scan++;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanGray_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ ASSERT(!m_bRgbByteOrder);
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
+ ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ ori_scan += col_start;
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
+ } else {
+ int src_alpha = m_Alpha;
#if 1
- for (int col = col_start; col < col_end; col ++) {
- int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
- dest_scan ++;
- }
+ for (int col = col_start; col < col_end; col ++) {
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan ++;
+ }
#else
- if (m_bFullCover) {
- if (src_alpha == 255) {
- FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
- return;
- }
- for (int col = col_start; col < col_end; col ++)
- *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
- } else {
- for (int col = col_start; col < col_end; col ++) {
- int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
- dest_scan++;
- }
- }
+ if (m_bFullCover) {
+ if (src_alpha == 255) {
+ FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++)
+ *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan++;
+ }
+ }
#endif
- }
- }
+ }
+ }
- void CFX_SkiaRenderer::CompositeSpanGray_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_bRgbByteOrder);
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start;
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan ++;
- continue;
- }
- if (src_alpha1 == 255)
- *dest_scan++ = m_Gray;
- else {
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1);
- dest_scan ++;
- }
- }
- }
+ void CFX_SkiaRenderer::CompositeSpanGray_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan ++;
+ continue;
+ }
+ if (src_alpha1 == 255)
+ *dest_scan++ = m_Gray;
+ else {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1);
+ dest_scan ++;
+ }
+ }
+ }
- void CFX_SkiaRenderer::CompositeSpanGray_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left;
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start;
- ori_scan += col_start;
+ void CFX_SkiaRenderer::CompositeSpanGray_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
+ ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left;
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ ori_scan += col_start;
#if 1
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (src_alpha == 255 && cover_scan == 255) {
- *dest_scan++ = m_Gray;
- ori_scan++;
- continue;
- }
- int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
- dest_scan++;
- }
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Gray;
+ ori_scan++;
+ continue;
+ }
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan++;
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha) {
- dest_scan++;
- ori_scan++;
- continue;
- }
- if (src_alpha == 255){
- *dest_scan++ = m_Gray;
- ori_scan++;
- continue;
- }
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
- }
- } else {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (src_alpha == 255 && cover_scan == 255) {
- *dest_scan++ = m_Gray;
- ori_scan++;
- continue;
- }
- int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
- dest_scan++;
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan++;
+ ori_scan++;
+ continue;
+ }
+ if (src_alpha == 255){
+ *dest_scan++ = m_Gray;
+ ori_scan++;
+ continue;
+ }
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ }
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Gray;
+ ori_scan++;
+ continue;
+ }
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan++;
+ }
+ }
#endif
- }
- /*--------------------------------------------------------------------------------------------------*/
+ }
+ /*--------------------------------------------------------------------------------------------------*/
- void CFX_SkiaRenderer::CompositeSpanARGB_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start<<2;
- if (m_Alpha == 255 && cover_scan == 255) {
- FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
- return;
- }
- int src_alpha;
+ void CFX_SkiaRenderer::CompositeSpanARGB_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start<<2;
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ int src_alpha;
#if 0
- if (m_bFullCover) {
- if (m_Alpha == 255) {
- FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
- return;
- }
- }
- else
+ if (m_bFullCover) {
+ if (m_Alpha == 255) {
+ FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ }
+ else
#endif
- src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- // Dest format: Argb
- // calculate destination alpha (it's union of source and dest alpha)
- if (dest_scan[3] == 0) {
- dest_scan[3] = src_alpha;
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan = m_Red;
- dest_scan += 2;
- continue;
- }
- uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
- dest_scan[3] = dest_alpha;
- int alpha_ratio = src_alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan += 2;
- }
- }
+ src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
- void CFX_SkiaRenderer::CompositeSpanARGB_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start << 2;
- //ori_scan += col_start << 2;
+ void CFX_SkiaRenderer::CompositeSpanARGB_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ //ori_scan += col_start << 2;
- if (m_Alpha == 255 && cover_scan == 255){
- FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
- return;
- }
- if (cover_scan == 255) {
- int dst_color = (0x00ffffff&m_Color)|(m_Alpha<<24);
- FXSYS_memset(dest_scan, dst_color, (col_end - col_start)<<2);
- return;
- }
- // Do not need origin bitmap, because of merge in pure transparent background
- int src_alpha_covered = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++)
- {
- // shortcut
- if (dest_scan[3] == 0) {
- dest_scan[3] = src_alpha_covered;
- *dest_scan ++ = m_Blue;
- *dest_scan ++ = m_Green;
- *dest_scan = m_Red;
- dest_scan += 2;
- continue;
- }
- // We should do alpha transition and color transition
- // alpha fg color fg
- // alpha bg color bg
- // alpha cover color cover
- dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
- dest_scan += 2;
- }
- }
- void CFX_SkiaRenderer::CompositeSpanARGB_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start << 2;
+ if (m_Alpha == 255 && cover_scan == 255){
+ FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ if (cover_scan == 255) {
+ int dst_color = (0x00ffffff&m_Color)|(m_Alpha<<24);
+ FXSYS_memset(dest_scan, dst_color, (col_end - col_start)<<2);
+ return;
+ }
+ // Do not need origin bitmap, because of merge in pure transparent background
+ int src_alpha_covered = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++)
+ {
+ // shortcut
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha_covered;
+ *dest_scan ++ = m_Blue;
+ *dest_scan ++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ // We should do alpha transition and color transition
+ // alpha fg color fg
+ // alpha bg color bg
+ // alpha cover color cover
+ dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
+ dest_scan += 2;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanARGB_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
#if 1
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha* clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan += 4;
- continue;
- }
- if (src_alpha1 == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- } else {
- // Dest format: Argb
- // calculate destination alpha (it's union of source and dest alpha)
- if (dest_scan[3] == 0) {
- dest_scan[3] = src_alpha1;
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan = m_Red;
- dest_scan += 2;
- continue;
- }
- uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255;
- dest_scan[3] = dest_alpha;
- int alpha_ratio = src_alpha1*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan += 2;
- }
- }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha* clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha1;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha) {
- dest_scan += 4;
- continue;
- }
- if (src_alpha == 255){
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- continue;
- } else {
- // Dest format: Argb
- // calculate destination alpha (it's union of source and dest alpha)
- if (dest_scan[3] == 0) {
- dest_scan[3] = src_alpha;
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan = m_Red;
- dest_scan += 2;
- continue;
- }
- uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
- dest_scan[3] = dest_alpha;
- int alpha_ratio = src_alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan += 2;
- }
- }
- } else {
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha* clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan += 4;
- continue;
- }
- if (src_alpha1 == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- } else {
- // Dest format: Argb
- // calculate destination alpha (it's union of source and dest alpha)
- if (dest_scan[3] == 0) {
- dest_scan[3] = src_alpha1;
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan = m_Red;
- dest_scan += 2;
- continue;
- }
- uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255;
- dest_scan[3] = dest_alpha;
- int alpha_ratio = src_alpha1*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan += 2;
- }
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha == 255){
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ continue;
+ } else {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
+ } else {
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha* clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha1;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
+ }
#endif
- }
+ }
- void CFX_SkiaRenderer::CompositeSpanARGB_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start << 2;
- //ori_scan += col_start << 2;
- // Do not need origin bitmap, because of merge in pure transparent background
- for (int col = col_start; col < col_end; col ++)
- {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- int src_alpha_covered = src_alpha * cover_scan / 255;
- // shortcut
- if (src_alpha_covered == 0){
- dest_scan += 4;
- continue;
- }
- // shortcut
- if (cover_scan == 255 || dest_scan[3] == 0)
- {
- // origin alpha always zero, just get src alpha
- dest_scan[3] = src_alpha_covered;
- *dest_scan ++ = m_Blue;
- *dest_scan ++ = m_Green;
- *dest_scan = m_Red;
- dest_scan += 2;
- continue;
- }
- // We should do alpha transition and color transition
- // alpha fg color fg
- // alpha bg color bg
- // alpha cover color cover
- dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
- dest_scan += 2;
- }
- }
+ void CFX_SkiaRenderer::CompositeSpanARGB_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ //ori_scan += col_start << 2;
+ // Do not need origin bitmap, because of merge in pure transparent background
+ for (int col = col_start; col < col_end; col ++)
+ {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ int src_alpha_covered = src_alpha * cover_scan / 255;
+ // shortcut
+ if (src_alpha_covered == 0){
+ dest_scan += 4;
+ continue;
+ }
+ // shortcut
+ if (cover_scan == 255 || dest_scan[3] == 0)
+ {
+ // origin alpha always zero, just get src alpha
+ dest_scan[3] = src_alpha_covered;
+ *dest_scan ++ = m_Blue;
+ *dest_scan ++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ // We should do alpha transition and color transition
+ // alpha fg color fg
+ // alpha bg color bg
+ // alpha cover color cover
+ dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
+ dest_scan += 2;
+ }
+ }
- /*-----------------------------------------------------------------------------------------------------------*/
- void CFX_SkiaRenderer::CompositeSpanRGB32_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += (col_start << 2);
- if (m_Alpha == 255 && cover_scan == 255) {
- FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
- return;
- }
- int src_alpha;
+ /*-----------------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpanRGB32_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += (col_start << 2);
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ int src_alpha;
#if 0
- if (m_bFullCover)
- src_alpha = m_Alpha;
- else
+ if (m_bFullCover)
+ src_alpha = m_Alpha;
+ else
#endif
- src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- // Dest format: Rgb32
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
- dest_scan += 2;
- }
- }
- void CFX_SkiaRenderer::CompositeSpanRGB32_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start << 2;
- ori_scan += col_start << 2;
- if (m_Alpha == 255 && cover_scan == 255) {
- FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
- return;
- }
- int src_alpha = m_Alpha;
- for (int col = col_start; col < col_end; col ++) {
+ src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan += 2;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB32_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ ori_scan += col_start << 2;
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ int src_alpha = m_Alpha;
+ for (int col = col_start; col < col_end; col ++) {
#if 0
- if (m_bFullCover) {
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
- dest_scan += 2; ori_scan += 2;
- continue;
- }
+ if (m_bFullCover) {
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ dest_scan += 2; ori_scan += 2;
+ continue;
+ }
#endif
- int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
- ori_scan += 2;
- *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
- dest_scan += 2;
- }
- }
- void CFX_SkiaRenderer::CompositeSpanRGB32_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start << 2;
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ ori_scan += 2;
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan += 2;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB32_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
#if 1
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan += 4;
- continue;
- }
- if (src_alpha1 == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- } else {
- // Dest format: Rgb or Rgb32
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
- dest_scan += 2;
- }
- }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Rgb or Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan += 2;
+ }
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha) {
- dest_scan += 4;
- continue;
- }
- if (src_alpha == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- } else {
- // Dest format: Rgb or Rgb32
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
- dest_scan += 2;
- }
- }
- } else {
- // Rgb32
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan += 4;
- continue;
- }
- if (src_alpha1 == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- } else {
- // Dest format: Rgb or Rgb32
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
- dest_scan += 2;
- }
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Rgb or Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan += 2;
+ }
+ }
+ } else {
+ // Rgb32
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Rgb or Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan += 2;
+ }
+ }
+ }
#endif
- }
- void CFX_SkiaRenderer::CompositeSpanRGB32_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start << 2;
- ori_scan += col_start << 2;
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB32_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ ori_scan += col_start << 2;
#if 1
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (src_alpha == 255 && cover_scan == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- ori_scan += 4;
- continue;
- }
- int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
- ori_scan += 2;
- *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
- dest_scan += 2;
- }
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ ori_scan += 2;
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan += 2;
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha) {
- *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan;
- dest_scan += 4;
- ori_scan += 4;
- continue;
- }
- if (src_alpha == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- ori_scan += 4;
- continue;
- }
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
- dest_scan += 2; ori_scan += 2;
- }
- } else {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (src_alpha == 255 && cover_scan == 255) {
- *(FX_DWORD*)dest_scan = m_Color;
- dest_scan += 4;
- ori_scan += 4;
- continue;
- }
- int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
- ori_scan += 2;
- *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
- dest_scan += 2;
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ dest_scan += 2; ori_scan += 2;
+ }
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ ori_scan += 2;
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan += 2;
+ }
+ }
#endif
- }
- /*-----------------------------------------------------------------------------------------------------*/
- void CFX_SkiaRenderer::CompositeSpanRGB24_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1);
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += (col_start<<1)+col_start;
- int src_alpha;
+ }
+ /*-----------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpanRGB24_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += (col_start<<1)+col_start;
+ int src_alpha;
#if 0
- if (m_bFullCover)
- src_alpha = m_Alpha;
- else
+ if (m_bFullCover)
+ src_alpha = m_Alpha;
+ else
#endif
- src_alpha = m_Alpha * cover_scan / 255;
- if (src_alpha == 255) {
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- }
- return;
- }
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
- dest_scan ++;
- }
- }
- void CFX_SkiaRenderer::CompositeSpanRGB24_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1);
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left + (span_left<<1);
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += (col_start<<1) + col_start;
- ori_scan += (col_start<<1) + col_start;
- if (m_Alpha == 255&&cover_scan == 255) {
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan ++ = m_Blue;
- *dest_scan ++ = m_Green;
- *dest_scan ++ = m_Red;
- }
- return;
- }
- for (int col = col_start; col < col_end; col ++) {
+ src_alpha = m_Alpha * cover_scan / 255;
+ if (src_alpha == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ }
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan ++;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1);
+ ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left + (span_left<<1);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += (col_start<<1) + col_start;
+ ori_scan += (col_start<<1) + col_start;
+ if (m_Alpha == 255&&cover_scan == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan ++ = m_Blue;
+ *dest_scan ++ = m_Green;
+ *dest_scan ++ = m_Red;
+ }
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++) {
#if 0
- if (m_bFullCover) {
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
- continue;
- }
+ if (m_bFullCover) {
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
+ continue;
+ }
#endif
- int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
- int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
- int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
- *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
- dest_scan ++;
- }
- }
- void CFX_SkiaRenderer::CompositeSpanRGB24_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start + (col_start << 1);
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan ++;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start + (col_start << 1);
#if 1
- int src_alpha = m_Alpha * cover_scan /255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan += 3;
- continue;
- }
- if (src_alpha1 == 255) {
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- } else {
- // Dest format: Rgb
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
- dest_scan ++;
- }
- }
+ int src_alpha = m_Alpha * cover_scan /255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ } else {
+ // Dest format: Rgb
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan ++;
+ }
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha) {
- dest_scan += 3;
- continue;
- }
- if (src_alpha == 255) {
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- } else {
- // Dest format: Rgb
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
- dest_scan ++;
- }
- }
- } else {
- int src_alpha = m_Alpha * cover_scan /255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_scan += 3;
- continue;
- }
- if (src_alpha1 == 255) {
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- } else {
- // Dest format: Rgb
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
- dest_scan ++;
- }
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ } else {
+ // Dest format: Rgb
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan ++;
+ }
+ }
+ } else {
+ int src_alpha = m_Alpha * cover_scan /255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ } else {
+ // Dest format: Rgb
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan ++;
+ }
+ }
+ }
#endif
- }
- void CFX_SkiaRenderer::CompositeSpanRGB24_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left+(span_left<<1);
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start + (col_start<<1);
- ori_scan += col_start + (col_start<<1);
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start + (col_start<<1);
+ ori_scan += col_start + (col_start<<1);
#if 1
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (src_alpha == 255 && cover_scan == 255) {
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- ori_scan += 3;
- continue;
- }
- int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
- dest_scan ++;
- }
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ ori_scan += 3;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan ++;
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha){
- *dest_scan++ = *ori_scan++;
- *dest_scan++ = *ori_scan++;
- *dest_scan++ = *ori_scan++;
- continue;
- }
- if (src_alpha == 255){
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- ori_scan += 3;
- continue;
- }
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
- }
- } else {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (src_alpha == 255 && cover_scan == 255) {
- *dest_scan++ = m_Blue;
- *dest_scan++ = m_Green;
- *dest_scan++ = m_Red;
- ori_scan += 3;
- continue;
- }
- int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
- int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
- int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
- *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
- dest_scan ++;
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha){
+ *dest_scan++ = *ori_scan++;
+ *dest_scan++ = *ori_scan++;
+ *dest_scan++ = *ori_scan++;
+ continue;
+ }
+ if (src_alpha == 255){
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ ori_scan += 3;
+ continue;
+ }
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
+ }
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ ori_scan += 3;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan ++;
+ }
+ }
#endif
- }
- void CFX_SkiaRenderer::CompositeSpanRGB24_10(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
- dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start+(col_start<<1);
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_10(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start+(col_start<<1);
#if 1
- if (m_Alpha == 255 && cover_scan == 255) {
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = 255;
- }
- return;
- }
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
- (*dest_extra_alpha_scan) * src_alpha / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = src_alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- }
+ if (m_Alpha == 255 && cover_scan == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = (uint8_t)m_Blue;
+ *dest_scan++ = (uint8_t)m_Green;
+ *dest_scan++ = (uint8_t)m_Red;
+ *dest_extra_alpha_scan++ = 255;
+ }
+ return;
+ }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
#else
- if (m_bFullCover) {
- if (m_Alpha == 255) {
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = 255;
- }
- return;
- }
- for (int col = col_start; col < col_end; col ++) {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + m_Alpha -
- (*dest_extra_alpha_scan) * m_Alpha / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = m_Alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- }
- } else {
- if (m_Alpha == 255 && cover_scan == 255) {
- for (int col = col_start; col < col_end; col ++) {
- *dest_scan++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = 255;
- }
- return;
- }
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
- (*dest_extra_alpha_scan) * src_alpha / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = src_alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- }
- }
+ if (m_bFullCover) {
+ if (m_Alpha == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = (uint8_t)m_Blue;
+ *dest_scan++ = (uint8_t)m_Green;
+ *dest_scan++ = (uint8_t)m_Red;
+ *dest_extra_alpha_scan++ = 255;
+ }
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + m_Alpha -
+ (*dest_extra_alpha_scan) * m_Alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = m_Alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ } else {
+ if (m_Alpha == 255 && cover_scan == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = (uint8_t)m_Blue;
+ *dest_scan++ = (uint8_t)m_Green;
+ *dest_scan++ = (uint8_t)m_Red;
+ *dest_extra_alpha_scan++ = 255;
+ }
+ return;
+ }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
#endif
- }
- void CFX_SkiaRenderer::CompositeSpanRGB24_14(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
- dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left;
- clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start + (col_start << 1);
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_14(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left;
+ clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start + (col_start << 1);
#if 1
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = src_alpha * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_extra_alpha_scan++;
- dest_scan += 3;
- continue;
- }
- if (src_alpha1 == 255) {
- *dest_scan++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
- } else {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
- (*dest_extra_alpha_scan) * src_alpha1 / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = src_alpha1*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- }
- }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_extra_alpha_scan++;
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = (uint8_t)m_Blue;
+ *dest_scan++ = (uint8_t)m_Green;
+ *dest_scan++ = (uint8_t)m_Red;
+ *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
+ } else {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
+ (*dest_extra_alpha_scan) * src_alpha1 / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
#else
- if (m_bFullCover) {
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha = m_Alpha * clip_scan[col] / 255;
- if (!src_alpha) {
- dest_extra_alpha_scan++;
- dest_scan += 3;
- continue;
- }
- if (src_alpha == 255) {
- *dest_scan++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
- } else {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
- (*dest_extra_alpha_scan) * src_alpha / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = src_alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- }
- }
- } else {
- int src_alpha = m_Alpha * cover_scan / 255;
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255;
- if (!src_alpha1) {
- dest_extra_alpha_scan++;
- dest_scan += 3;
- continue;
- }
- if (src_alpha1 == 255) {
- *dest_scan++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
- } else {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
- (*dest_extra_alpha_scan) * src_alpha1 / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = src_alpha1*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- }
- }
- }
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_extra_alpha_scan++;
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *dest_scan++ = (uint8_t)m_Blue;
+ *dest_scan++ = (uint8_t)m_Green;
+ *dest_scan++ = (uint8_t)m_Red;
+ *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
+ } else {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
+ } else {
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_extra_alpha_scan++;
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = (uint8_t)m_Blue;
+ *dest_scan++ = (uint8_t)m_Green;
+ *dest_scan++ = (uint8_t)m_Red;
+ *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
+ } else {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
+ (*dest_extra_alpha_scan) * src_alpha1 / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
+ }
#endif
- }
- /*-----------------------------------------------------------------------------------------------------*/
+ }
+ /*-----------------------------------------------------------------------------------------------------*/
- // A general alpha merge function (with clipping mask). Cmyka/Cmyk device.
- void CFX_SkiaRenderer::CompositeSpanCMYK(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
- int span_left, int span_len, int span_top, uint8_t cover_scan,
- int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan)
- {
- ASSERT(!m_bRgbByteOrder);
- // Cmyk(a)
- int col_start = span_left < clip_left ? clip_left - span_left : 0;
- int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
- if (col_end < col_start) return; // do nothing.
- dest_scan += col_start * 4;
- Bpp; // for avoid compile warning.
+ // A general alpha merge function (with clipping mask). Cmyka/Cmyk device.
+ void CFX_SkiaRenderer::CompositeSpanCMYK(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, uint8_t cover_scan,
+ int clip_top, int clip_left, int clip_right, uint8_t* clip_scan,
+ uint8_t* dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ // Cmyk(a)
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start * 4;
+ Bpp; // for avoid compile warning.
- if (dest_extra_alpha_scan) {
- // CMYKa
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha;
- if (m_bFullCover) {
- if (clip_scan)
- src_alpha = m_Alpha * clip_scan[col] / 255;
- else
- src_alpha = m_Alpha;
- } else {
- if (clip_scan)
- src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
- else
- src_alpha = m_Alpha * cover_scan / 255;
- }
+ if (dest_extra_alpha_scan) {
+ // CMYKa
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha;
+ if (m_bFullCover) {
+ if (clip_scan)
+ src_alpha = m_Alpha * clip_scan[col] / 255;
+ else
+ src_alpha = m_Alpha;
+ } else {
+ if (clip_scan)
+ src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
+ else
+ src_alpha = m_Alpha * cover_scan / 255;
+ }
- if (src_alpha) {
- if (src_alpha == 255) {
- *(FX_CMYK*)dest_scan = m_Color;
- *dest_extra_alpha_scan = (uint8_t)m_Alpha;
- } else {
- // Dest format: Cmyka
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
- (*dest_extra_alpha_scan) * src_alpha / 255;
- *dest_extra_alpha_scan++ = dest_alpha;
- int alpha_ratio = src_alpha*255/dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_ratio);
- dest_scan ++;
- continue;
- }
- }
- dest_extra_alpha_scan++;
- dest_scan += 4;
- }
- } else {
- // CMYK
- for (int col = col_start; col < col_end; col ++) {
- int src_alpha;
- if (clip_scan)
- src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
- else
- src_alpha = m_Alpha * cover_scan / 255;
+ if (src_alpha) {
+ if (src_alpha == 255) {
+ *(FX_CMYK*)dest_scan = m_Color;
+ *dest_extra_alpha_scan = (uint8_t)m_Alpha;
+ } else {
+ // Dest format: Cmyka
+ // calculate destination alpha (it's union of source and dest alpha)
+ uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_ratio);
+ dest_scan ++;
+ continue;
+ }
+ }
+ dest_extra_alpha_scan++;
+ dest_scan += 4;
+ }
+ } else {
+ // CMYK
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha;
+ if (clip_scan)
+ src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
+ else
+ src_alpha = m_Alpha * cover_scan / 255;
- if (src_alpha) {
- if (src_alpha == 255) {
- *(FX_CMYK*)dest_scan = m_Color;
- } else {
- // Dest format: cmyk
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
- dest_scan ++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
- dest_scan ++;
- continue;
- }
- }
- dest_scan += 4;
- }
- }
- }
+ if (src_alpha) {
+ if (src_alpha == 255) {
+ *(FX_CMYK*)dest_scan = m_Color;
+ } else {
+ // Dest format: cmyk
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
+ dest_scan ++;
+ continue;
+ }
+ }
+ dest_scan += 4;
+ }
+ }
+ }
- //--------------------------------------------------------------------
- FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder,
- int alpha_flag, void* pIccTransform) //The alpha flag must be fill_flag if exist.
- {
- m_pDevice = pDevice;
- m_pClipRgn = pClipRgn;
- m_bRgbByteOrder = bRgbByteOrder;
- m_pOriDevice = pOriDevice;
- m_pDestScan = NULL;
- m_pDestExtraAlphaScan = NULL;
- m_pOriScan = NULL;
- m_pClipScan = NULL;
- composite_span = NULL;
- if (m_pClipRgn)
- m_ClipBox = m_pClipRgn->GetBox();
- else {
- m_ClipBox.left = m_ClipBox.top = 0;
- m_ClipBox.right = m_pDevice->GetWidth();
- m_ClipBox.bottom = m_pDevice->GetHeight();
- }
- m_pClipMask = NULL;
- if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF)
- {
- m_pClipMask = m_pClipRgn->GetMask();
- m_pClipScan = m_pClipMask->GetBuffer();
- }
- if (m_pDevice->m_pAlphaMask)
- m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer();
- if (m_pOriDevice)
- m_pOriScan = m_pOriDevice->GetBuffer();
- m_pDestScan = m_pDevice->GetBuffer();
+ //--------------------------------------------------------------------
+ FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder,
+ int alpha_flag, void* pIccTransform) //The alpha flag must be fill_flag if exist.
+ {
+ m_pDevice = pDevice;
+ m_pClipRgn = pClipRgn;
+ m_bRgbByteOrder = bRgbByteOrder;
+ m_pOriDevice = pOriDevice;
+ m_pDestScan = NULL;
+ m_pDestExtraAlphaScan = NULL;
+ m_pOriScan = NULL;
+ m_pClipScan = NULL;
+ composite_span = NULL;
+ if (m_pClipRgn)
+ m_ClipBox = m_pClipRgn->GetBox();
+ else {
+ m_ClipBox.left = m_ClipBox.top = 0;
+ m_ClipBox.right = m_pDevice->GetWidth();
+ m_ClipBox.bottom = m_pDevice->GetHeight();
+ }
+ m_pClipMask = NULL;
+ if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF)
+ {
+ m_pClipMask = m_pClipRgn->GetMask();
+ m_pClipScan = m_pClipMask->GetBuffer();
+ }
+ if (m_pDevice->m_pAlphaMask)
+ m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer();
+ if (m_pOriDevice)
+ m_pOriScan = m_pOriDevice->GetBuffer();
+ m_pDestScan = m_pDevice->GetBuffer();
- m_bFullCover = bFullCover;
+ m_bFullCover = bFullCover;
- FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
- FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
+ FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
+ FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
- m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
+ m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
- ICodec_IccModule* pIccModule = NULL;
- // No lcms engine, we skip the transform
- if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule())
- pIccTransform = NULL;
- else
- pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
+ ICodec_IccModule* pIccModule = NULL;
+ // No lcms engine, we skip the transform
+ if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule())
+ pIccTransform = NULL;
+ else
+ pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
- if (m_pDevice->GetBPP() == 8) { // Gray(a) device
- ASSERT(!m_bRgbByteOrder);
- if (m_pDevice->IsAlphaMask()) {
- //Alpha Mask
- m_Gray = 255;
- } else {
- //Gray(a) device
- if (pIccTransform) {
- uint8_t gray;
- color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, &gray, (const uint8_t*)&color, 1);
- m_Gray = gray;
- } else {
- if (bObjectCMYK) {
- uint8_t r, g, b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
- r, g, b);
- m_Gray = FXRGB2GRAY(r, g, b);
- } else {
- m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color));
- }
- }
- }
- } else {
- if (bDeviceCMYK) { // Cmyk(a) Device
- ASSERT(!m_bRgbByteOrder);
- //TODO... opt for cmyk
- composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK;
- if (bObjectCMYK) {
- m_Color = FXCMYK_TODIB(color);
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&m_Color, 1);
- } else { // Object RGB
- if (!pIccTransform)
- return FALSE;
- color = FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1);
- }
- m_Red = ((uint8_t*)&m_Color)[0];
- m_Green = ((uint8_t*)&m_Color)[1];
- m_Blue = ((uint8_t*)&m_Color)[2];
- m_Gray = ((uint8_t*)&m_Color)[3];
- return TRUE;
- } else {
- if (pIccTransform) {
- color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1);
- ((uint8_t*)&m_Color)[3] = m_Alpha;
- m_Red = ((uint8_t*)&m_Color)[2];
- m_Green = ((uint8_t*)&m_Color)[1];
- m_Blue = ((uint8_t*)&m_Color)[0];
- // Need Johnson to improvement it.
- if (m_bRgbByteOrder) {
- // swap
- m_Red = ((uint8_t*)&m_Color)[0];
- m_Blue = ((uint8_t*)&m_Color)[2];
- m_Color = FXARGB_TODIB(m_Color);
- m_Color = FXARGB_TOBGRORDERDIB(m_Color);
- }
- } else {
- if (bObjectCMYK) {
- uint8_t r, g, b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
- r, g, b);
- m_Color = FXARGB_MAKE(m_Alpha, r, g, b);
- if (m_bRgbByteOrder){
- m_Color = FXARGB_TOBGRORDERDIB(m_Color);
- m_Red = b; m_Green = g; m_Blue = r;//
- }else {
- m_Color = FXARGB_TODIB(m_Color);
- m_Red = r; m_Green = g; m_Blue = b;//
- }
- } else {
- if (m_bRgbByteOrder){
- m_Color = FXARGB_TOBGRORDERDIB(color);
- ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); //
- }else {
- m_Color = FXARGB_TODIB(color);
- ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue);
- }
- }
- }
- }
- }
- // Get palette transparency selector
- m_ProcessFilter = (m_pOriDevice? 1 : 0) /* has Ori Device flag */
- + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */
- + (m_pClipMask? 4 : 0) /* has clip region flag */
- + (m_pDevice->m_pAlphaMask? 8 : 0); /* has Alpha Mask chanel flag */
- switch(m_ProcessFilter) {
- case 0:
- composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0;
- break;
- case 2:
- {
- if (m_pDevice->GetBPP() == 8)
- composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2;
- else if (m_pDevice->GetBPP() == 24)
- composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2;
- else
- composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2;
- }
- break;
- case 3:
- {
- if (m_pDevice->GetBPP() == 8)
- composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3;
- else if (m_pDevice->GetBPP() == 24)
- composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3;
- else
- composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3;
- }
- break;
- case 4:
- composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4;
- break;
- case 6:
- {
- if (m_pDevice->GetBPP() == 8)
- composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6;
- else if (m_pDevice->GetBPP() == 24)
- composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6;
- else
- composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6;
- }
- break;
- case 7:
- {
- if (m_pDevice->GetBPP() == 8)
- composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7;
- else if (m_pDevice->GetBPP() == 24)
- composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7;
- else
- composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7;
- }
- break;
- case 1:
- case 5:
- case 8:
- case 9:
- case 11:
- case 12:
- case 13:
- case 15:
- //TODO...
- break;
- case 10:
- composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10;
- break;
- case 14:
- composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14;
- break;
- }
- if (composite_span == NULL)
- return FALSE;
- return TRUE;
- }
+ if (m_pDevice->GetBPP() == 8) { // Gray(a) device
+ ASSERT(!m_bRgbByteOrder);
+ if (m_pDevice->IsAlphaMask()) {
+ //Alpha Mask
+ m_Gray = 255;
+ } else {
+ //Gray(a) device
+ if (pIccTransform) {
+ uint8_t gray;
+ color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, &gray, (const uint8_t*)&color, 1);
+ m_Gray = gray;
+ } else {
+ if (bObjectCMYK) {
+ uint8_t r, g, b;
+ AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
+ r, g, b);
+ m_Gray = FXRGB2GRAY(r, g, b);
+ } else {
+ m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color));
+ }
+ }
+ }
+ } else {
+ if (bDeviceCMYK) { // Cmyk(a) Device
+ ASSERT(!m_bRgbByteOrder);
+ //TODO... opt for cmyk
+ composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK;
+ if (bObjectCMYK) {
+ m_Color = FXCMYK_TODIB(color);
+ if (pIccTransform)
+ pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&m_Color, 1);
+ } else { // Object RGB
+ if (!pIccTransform)
+ return FALSE;
+ color = FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1);
+ }
+ m_Red = ((uint8_t*)&m_Color)[0];
+ m_Green = ((uint8_t*)&m_Color)[1];
+ m_Blue = ((uint8_t*)&m_Color)[2];
+ m_Gray = ((uint8_t*)&m_Color)[3];
+ return TRUE;
+ }
+ if (pIccTransform) {
+ color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1);
+ ((uint8_t*)&m_Color)[3] = m_Alpha;
+ m_Red = ((uint8_t*)&m_Color)[2];
+ m_Green = ((uint8_t*)&m_Color)[1];
+ m_Blue = ((uint8_t*)&m_Color)[0];
+ // Need Johnson to improvement it.
+ if (m_bRgbByteOrder) {
+ // swap
+ m_Red = ((uint8_t*)&m_Color)[0];
+ m_Blue = ((uint8_t*)&m_Color)[2];
+ m_Color = FXARGB_TODIB(m_Color);
+ m_Color = FXARGB_TOBGRORDERDIB(m_Color);
+ }
+ } else {
+ if (bObjectCMYK) {
+ uint8_t r, g, b;
+ AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
+ r, g, b);
+ m_Color = FXARGB_MAKE(m_Alpha, r, g, b);
+ if (m_bRgbByteOrder){
+ m_Color = FXARGB_TOBGRORDERDIB(m_Color);
+ m_Red = b; m_Green = g; m_Blue = r;//
+ }else {
+ m_Color = FXARGB_TODIB(m_Color);
+ m_Red = r; m_Green = g; m_Blue = b;//
+ }
+ } else {
+ if (m_bRgbByteOrder){
+ m_Color = FXARGB_TOBGRORDERDIB(color);
+ ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); //
+ }else {
+ m_Color = FXARGB_TODIB(color);
+ ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue);
+ }
+ }
+ }
+ }
+ // Get palette transparency selector
+ m_ProcessFilter = (m_pOriDevice? 1 : 0) /* has Ori Device flag */
+ + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */
+ + (m_pClipMask? 4 : 0) /* has clip region flag */
+ + (m_pDevice->m_pAlphaMask? 8 : 0); /* has Alpha Mask chanel flag */
+ switch(m_ProcessFilter) {
+ case 0:
+ composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0;
+ break;
+ case 2:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2;
+ }
+ break;
+ case 3:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3;
+ }
+ break;
+ case 4:
+ composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4;
+ break;
+ case 6:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6;
+ }
+ break;
+ case 7:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7;
+ }
+ break;
+ case 1:
+ case 5:
+ case 8:
+ case 9:
+ case 11:
+ case 12:
+ case 13:
+ case 15:
+ //TODO...
+ break;
+ case 10:
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10;
+ break;
+ case 14:
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14;
+ break;
+ }
+ if (composite_span == NULL)
+ return FALSE;
+ return TRUE;
+ }
- /*----------------------------------------------------------------------------------------------------*/
- void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
- {
- FXSYS_assert(m_pDevice);
- int dst_y = y - m_Top;
- if (dst_y < 0 || dst_y >= m_pDevice->GetHeight())
- return;
+ /*----------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
+ {
+ FXSYS_assert(m_pDevice);
+ int dst_y = y - m_Top;
+ if (dst_y < 0 || dst_y >= m_pDevice->GetHeight())
+ return;
- uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
- uint8_t* dest_pos = dest_scan;
- while (1)
- {
- if (x >= m_dstWidth)
- return;
- int width = runs[0];
- SkASSERT(width >= 0);
- if (width <= 0)
- return;
- unsigned aa = antialias[0];
- if (aa) {
- int col_start = x < m_Left ? 0 : x - m_Left;
- int col_end = x + width;
- col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth();
- int result = col_end - col_start;
- if (result > 0) {
- dest_pos = dest_scan + col_start;
- if (result >= 4)
- FXSYS_memset(dest_pos, FXARGB_MAKE(aa, aa, aa, aa),result);
- else
- FXSYS_memset(dest_pos,aa,result);
- }
- }
- runs += width;
- antialias += width;
- x += width;
- }
- }
- void CFX_SkiaA8Renderer::blitH(int x, int y, int width)
- {
- FXSYS_assert(m_pDevice);
- int dst_y = y - m_Top;
- if (dst_y < 0 || dst_y >= m_pDevice->GetHeight())
- return;
- if (x >= m_dstWidth)
- return;
- uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
- int col_start = x < m_Left ? 0 : x - m_Left;
- int col_end = x + width;
- col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth();
- int result = col_end - col_start;
- if (result > 0) {
- uint8_t* dest_pos = dest_scan + col_start;
- if (result >= 4)
- FXSYS_memset(dest_pos, 0xffffffff,result);
- else
- FXSYS_memset(dest_pos,255,result);
- }
- }
- void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha)
- {
- FXSYS_assert(alpha);
- if (alpha == 255) {
- blitRect(x, y, 1, height);
- } else {
- int16_t runs[2];
- runs[0] = 1;
- runs[1] = 0;
- while (--height >= 0) {
- if (y >= m_dstHeight)
- return;
- blitAntiH(x, y ++, &alpha, runs);
- }
- }
- }
- void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height)
- {
- FXSYS_assert(m_pDevice);
- while (--height >= 0) {
- if (y >= m_dstHeight)
- return;
- blitH(x , y ++, width);
- }
- }
+ uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
+ uint8_t* dest_pos = dest_scan;
+ while (1)
+ {
+ if (x >= m_dstWidth)
+ return;
+ int width = runs[0];
+ SkASSERT(width >= 0);
+ if (width <= 0)
+ return;
+ unsigned aa = antialias[0];
+ if (aa) {
+ int col_start = x < m_Left ? 0 : x - m_Left;
+ int col_end = x + width;
+ col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth();
+ int result = col_end - col_start;
+ if (result > 0) {
+ dest_pos = dest_scan + col_start;
+ if (result >= 4)
+ FXSYS_memset(dest_pos, FXARGB_MAKE(aa, aa, aa, aa),result);
+ else
+ FXSYS_memset(dest_pos,aa,result);
+ }
+ }
+ runs += width;
+ antialias += width;
+ x += width;
+ }
+ }
+ void CFX_SkiaA8Renderer::blitH(int x, int y, int width)
+ {
+ FXSYS_assert(m_pDevice);
+ int dst_y = y - m_Top;
+ if (dst_y < 0 || dst_y >= m_pDevice->GetHeight())
+ return;
+ if (x >= m_dstWidth)
+ return;
+ uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
+ int col_start = x < m_Left ? 0 : x - m_Left;
+ int col_end = x + width;
+ col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth();
+ int result = col_end - col_start;
+ if (result > 0) {
+ uint8_t* dest_pos = dest_scan + col_start;
+ if (result >= 4)
+ FXSYS_memset(dest_pos, 0xffffffff,result);
+ else
+ FXSYS_memset(dest_pos,255,result);
+ }
+ }
+ void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha)
+ {
+ FXSYS_assert(alpha);
+ if (alpha == 255) {
+ blitRect(x, y, 1, height);
+ } else {
+ int16_t runs[2];
+ runs[0] = 1;
+ runs[1] = 0;
+ while (--height >= 0) {
+ if (y >= m_dstHeight)
+ return;
+ blitAntiH(x, y ++, &alpha, runs);
+ }
+ }
+ }
+ void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height)
+ {
+ FXSYS_assert(m_pDevice);
+ while (--height >= 0) {
+ if (y >= m_dstHeight)
+ return;
+ blitH(x , y ++, width);
+ }
+ }
- void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height,
+ void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha)
- {
- blitV(x++, y, height, leftAlpha);
- if (width > 0) {
- blitRect(x, y, width, height);
- x += width;
- }
- blitV(x, y, height, rightAlpha);
- }
+ {
+ blitV(x++, y, height, leftAlpha);
+ if (width > 0) {
+ blitRect(x, y, width, height);
+ x += width;
+ }
+ blitV(x, y, height, rightAlpha);
+ }
- FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top)
- {
- m_pDevice = pDevice;
- m_Left = Left;
- m_Top = Top;
- if (pDevice){
- m_dstWidth = m_Left + pDevice->GetWidth();
- m_dstHeight = m_Top + pDevice->GetHeight();
- }
- return TRUE;
- }
+ FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top)
+ {
+ m_pDevice = pDevice;
+ m_Left = Left;
+ m_Top = Top;
+ if (pDevice){
+ m_dstWidth = m_Left + pDevice->GetWidth();
+ m_dstHeight = m_Top + pDevice->GetHeight();
+ }
+ return TRUE;
+ }
#endif
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index b0dbc14ebc..18bcc595a4 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -267,7 +267,8 @@ void CWin32FontInfo::GetJapanesePreference(CFX_ByteString& face, int weight, int
}
}
return;
- } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
+ }
+ if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) {
face = "MS PMincho";
} else {
@@ -989,8 +990,10 @@ FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo
if (!bGDI) {
CFX_DIBitmap background;
if (!background.Create(width, height, FXDIB_Rgb32) ||
- !GetDIBits(&background, left, top, NULL) ||
- !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) {
+ !GetDIBits(&background, left, top, NULL) ||
+ !background.CompositeMask(0, 0, width, height, pSource, color,
+ 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE,
+ alpha_flag, pIccTransform)) {
return FALSE;
}
FX_RECT src_rect(0, 0, width, height);
@@ -999,23 +1002,22 @@ FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo
FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->Height());
return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRect->top, width, height,
&clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL);
- } else {
- int width = pSrcRect->Width(), height = pSrcRect->Height();
- if (pSource->HasAlpha()) {
- CFX_DIBitmap bitmap;
- if (!bitmap.Create(width, height, FXDIB_Rgb) ||
- !GetDIBits(&bitmap, left, top, NULL) ||
- !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) {
- return FALSE;
- }
- FX_RECT src_rect(0, 0, width, height);
- return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0, NULL);
- }
- CFX_DIBExtractor temp(pSource);
- CFX_DIBitmap* pBitmap = temp;
- if (pBitmap) {
- return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
+ }
+ int width = pSrcRect->Width(), height = pSrcRect->Height();
+ if (pSource->HasAlpha()) {
+ CFX_DIBitmap bitmap;
+ if (!bitmap.Create(width, height, FXDIB_Rgb) ||
+ !GetDIBits(&bitmap, left, top, NULL) ||
+ !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) {
+ return FALSE;
}
+ FX_RECT src_rect(0, 0, width, height);
+ return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0, NULL);
+ }
+ CFX_DIBExtractor temp(pSource);
+ CFX_DIBitmap* pBitmap = temp;
+ if (pBitmap) {
+ return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
}
return FALSE;
}
@@ -1045,9 +1047,10 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
int alpha_flag, void* pIccTransform, int blend_type)
{
ASSERT(pSource != NULL && pClipRect != NULL);
- if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000)
+ if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) {
return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_width, dest_height,
pClipRect, flags, alpha_flag, pIccTransform, blend_type);
+ }
if (pSource->IsAlphaMask()) {
FX_RECT image_rect;
image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width;
@@ -1064,8 +1067,8 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
}
CFX_DIBitmap background;
if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) ||
- !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, NULL) ||
- !background.CompositeMask(0, 0, clip_width, clip_height, pStretched, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) {
+ !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, NULL) ||
+ !background.CompositeMask(0, 0, clip_width, clip_height, pStretched, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) {
delete pStretched;
return FALSE;
}
@@ -1073,25 +1076,24 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
FX_BOOL ret = SetDIBits(&background, 0, &src_rect, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, NULL);
delete pStretched;
return ret;
- } else {
- if (pSource->HasAlpha()) {
- CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !pSource->IsCmykImage()) {
- CFX_DIBExtractor temp(pSource);
- CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
- return FALSE;
- }
- return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, pClipRect, flags);
+ }
+ if (pSource->HasAlpha()) {
+ CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
+ if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !pSource->IsCmykImage()) {
+ CFX_DIBExtractor temp(pSource);
+ CFX_DIBitmap* pBitmap = temp;
+ if (pBitmap == NULL) {
+ return FALSE;
}
- return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_width, dest_height,
- pClipRect, flags, alpha_flag, pIccTransform, blend_type);
- }
- CFX_DIBExtractor temp(pSource);
- CFX_DIBitmap* pBitmap = temp;
- if (pBitmap) {
- return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform);
+ return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, pClipRect, flags);
}
+ return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_width, dest_height,
+ pClipRect, flags, alpha_flag, pIccTransform, blend_type);
+ }
+ CFX_DIBExtractor temp(pSource);
+ CFX_DIBitmap* pBitmap = temp;
+ if (pBitmap) {
+ return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform);
}
return FALSE;
}
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index 191c2dc9cd..3dcfce4802 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -146,7 +146,8 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args)
CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
if (pPlatform->m_GdiplusExt.IsAvailable()) {
return pPlatform->m_GdiplusExt.LoadDIBitmap(args);
- } else if (args.flags == WINDIB_OPEN_MEMORY) {
+ }
+ if (args.flags == WINDIB_OPEN_MEMORY) {
return NULL;
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 889a5684b7..65a35d86a1 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -282,10 +282,9 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid, void** p
*ppvObject = this;
AddRef();
return S_OK;
- } else {
- *ppvObject = NULL;
- return E_NOINTERFACE;
}
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE CDwFontFileStream::AddRef()
{
@@ -306,16 +305,14 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::ReadFileFragment(
OUT void** fragmentContext
)
{
- if (fileOffset <= resourceSize_ &&
- fragmentSize <= resourceSize_ - fileOffset) {
+ if (fileOffset <= resourceSize_ && fragmentSize <= resourceSize_ - fileOffset) {
*fragmentStart = static_cast<uint8_t const*>(resourcePtr_) + static_cast<size_t>(fileOffset);
*fragmentContext = NULL;
return S_OK;
- } else {
- *fragmentStart = NULL;
- *fragmentContext = NULL;
- return E_FAIL;
}
+ *fragmentStart = NULL;
+ *fragmentContext = NULL;
+ return E_FAIL;
}
void STDMETHODCALLTYPE CDwFontFileStream::ReleaseFileFragment(void* fragmentContext)
{
@@ -341,10 +338,9 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid, void** p
*ppvObject = this;
AddRef();
return S_OK;
- } else {
- *ppvObject = NULL;
- return E_NOINTERFACE;
}
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE CDwFontFileLoader::AddRef()
{
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index 8fef914cd8..d76d52e50b 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -1010,14 +1010,14 @@ public:
virtual HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID iid, void ** ppvObject)
{
- if (iid == __uuidof(IUnknown) || iid == __uuidof(IStream) ||
- iid == __uuidof(ISequentialStream)) {
+ if (iid == __uuidof(IUnknown) ||
+ iid == __uuidof(IStream) ||
+ iid == __uuidof(ISequentialStream)) {
*ppvObject = static_cast<IStream*>(this);
AddRef();
return S_OK;
- } else {
- return E_NOINTERFACE;
}
+ return E_NOINTERFACE;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void)
{
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index 199ab78d9f..86dbf9bb0a 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -80,33 +80,31 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
return FALSE;
}
return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, dest_height, color, flags, alpha_flag, pIccTransform);
- } else {
- ASSERT(pSource != NULL);
- if (pSource->HasAlpha()) {
+ }
+ if (pSource->HasAlpha()) {
+ return FALSE;
+ }
+ if (dest_width < 0 || dest_height < 0) {
+ CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0);
+ if (pFlipped == NULL) {
return FALSE;
}
- if (dest_width < 0 || dest_height < 0) {
- CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
- return FALSE;
- }
- if (dest_width < 0) {
- dest_left += dest_width;
- }
- if (dest_height < 0) {
- dest_top += dest_height;
- }
- FX_BOOL ret = GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest_width), abs(dest_height), flags, pIccTransform);
- delete pFlipped;
- return ret;
+ if (dest_width < 0) {
+ dest_left += dest_width;
}
- CFX_DIBExtractor temp(pSource);
- CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
- return FALSE;
+ if (dest_height < 0) {
+ dest_top += dest_height;
}
- return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform);
+ FX_BOOL ret = GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest_width), abs(dest_height), flags, pIccTransform);
+ delete pFlipped;
+ return ret;
+ }
+ CFX_DIBExtractor temp(pSource);
+ CFX_DIBitmap* pBitmap = temp;
+ if (pBitmap == NULL) {
+ return FALSE;
}
+ return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform);
}
static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, const CFX_AffineMatrix* pDestMatrix)
{
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index d3a494405f..841b45ecba 100644
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
@@ -14,7 +14,7 @@
/* ------------------------------- CFFL_ComboBox ------------------------------- */
CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) :
- CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL )
+ CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL )
{
m_State.nIndex = 0;
m_State.nStart = 0;
@@ -28,375 +28,363 @@ CFFL_ComboBox::~CFFL_ComboBox()
PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam()
{
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
+ PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
- ASSERT(m_pWidget != NULL);
+ ASSERT(m_pWidget != NULL);
- int nFlags = m_pWidget->GetFieldFlags();
+ int nFlags = m_pWidget->GetFieldFlags();
- if (nFlags & FIELDFLAG_EDIT)
- {
- cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
- }
+ if (nFlags & FIELDFLAG_EDIT)
+ {
+ cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
+ }
- if (!m_pFontMap)
- {
- m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
- m_pFontMap->Initial();
- }
+ if (!m_pFontMap)
+ {
+ m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
+ m_pFontMap->Initial();
+ }
- cp.pFontMap = m_pFontMap;
- cp.pFocusHandler = this;
+ cp.pFontMap = m_pFontMap;
+ cp.pFocusHandler = this;
- return cp;
+ return cp;
}
CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView)
{
- CPWL_ComboBox * pWnd = new CPWL_ComboBox();
- pWnd->AttachFFLData(this);
- pWnd->Create(cp);
-
- CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller();
- pWnd->SetFillerNotify(pFormFiller);
-
- int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
- CFX_WideString swText;
- if (nCurSel < 0)
- swText = m_pWidget->GetValue();
- else
- swText = m_pWidget->GetOptionLabel(nCurSel);
-
- for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++)
- {
- pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
- }
-
- pWnd->SetSelect(nCurSel);
- pWnd->SetText(swText.c_str());
- return pWnd;
+ CPWL_ComboBox * pWnd = new CPWL_ComboBox();
+ pWnd->AttachFFLData(this);
+ pWnd->Create(cp);
+
+ CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller();
+ pWnd->SetFillerNotify(pFormFiller);
+
+ int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
+ CFX_WideString swText;
+ if (nCurSel < 0)
+ swText = m_pWidget->GetValue();
+ else
+ swText = m_pWidget->GetOptionLabel(nCurSel);
+
+ for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++)
+ {
+ pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
+ }
+
+ pWnd->SetSelect(nCurSel);
+ pWnd->SetText(swText.c_str());
+ return pWnd;
}
-FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
{
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+ return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
}
-FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)
+FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)
{
- if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- int32_t nCurSel = pWnd->GetSelect();
-
- ASSERT(m_pWidget != NULL);
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
- {
- if (nCurSel >= 0)
- {
- return nCurSel != m_pWidget->GetSelectedIndex(0);
- }
- else
- {
- return pWnd->GetText() != m_pWidget->GetValue();
- }
- }
- else
- {
- return nCurSel != m_pWidget->GetSelectedIndex(0);
- }
- }
-
- return FALSE;
+ CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE);
+ if (!pWnd)
+ return FALSE;
+
+ int32_t nCurSel = pWnd->GetSelect();
+ if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT))
+ return nCurSel != m_pWidget->GetSelectedIndex(0);
+
+ if (nCurSel >= 0)
+ return nCurSel != m_pWidget->GetSelectedIndex(0);
+
+ return pWnd->GetText() != m_pWidget->GetValue();
}
void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pWidget != NULL);
-
- if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- CFX_WideString swText = pWnd->GetText();
- int32_t nCurSel = pWnd->GetSelect();
-
- //mantis:0004157
- FX_BOOL bSetValue = TRUE;
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
- {
- if (nCurSel >= 0)
- {
- if (swText != m_pWidget->GetOptionLabel(nCurSel))
- bSetValue = TRUE;
- else
- bSetValue = FALSE;
- }
- else
- bSetValue = TRUE;
- }
- else
- bSetValue = FALSE;
-
- CFX_WideString sOldValue;
-
-
- if (bSetValue)
- {
- sOldValue = m_pWidget->GetValue();
- m_pWidget->SetValue(swText, FALSE);
- }
- else
- {
- m_pWidget->GetSelectedIndex(0);
- m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);
- }
-
- m_pWidget->ResetFieldAppearance(TRUE);
- m_pWidget->UpdateField();
- SetChangeMark();
-
- m_pWidget->GetPDFPage();
-
-
- }
+ ASSERT(m_pWidget != NULL);
+
+ if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ CFX_WideString swText = pWnd->GetText();
+ int32_t nCurSel = pWnd->GetSelect();
+
+ //mantis:0004157
+ FX_BOOL bSetValue = TRUE;
+
+ if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
+ {
+ if (nCurSel >= 0)
+ {
+ if (swText != m_pWidget->GetOptionLabel(nCurSel))
+ bSetValue = TRUE;
+ else
+ bSetValue = FALSE;
+ }
+ else
+ bSetValue = TRUE;
+ }
+ else
+ bSetValue = FALSE;
+
+ CFX_WideString sOldValue;
+
+
+ if (bSetValue)
+ {
+ sOldValue = m_pWidget->GetValue();
+ m_pWidget->SetValue(swText, FALSE);
+ }
+ else
+ {
+ m_pWidget->GetSelectedIndex(0);
+ m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);
+ }
+
+ m_pWidget->ResetFieldAppearance(TRUE);
+ m_pWidget->UpdateField();
+ SetChangeMark();
+
+ m_pWidget->GetPDFPage();
+
+
+ }
}
void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, PDFSDK_FieldAction& fa)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- fa.bFieldFull = pEdit->IsTextFull();
- int nSelStart = 0;
- int nSelEnd = 0;
- pEdit->GetSel(nSelStart, nSelEnd);
- fa.nSelEnd = nSelEnd;
- fa.nSelStart = nSelStart;
- fa.sValue = pEdit->GetText();
- fa.sChangeEx = GetSelectExportText();
-
- if (fa.bFieldFull)
- {
- fa.sChange = L"";
- fa.sChangeEx = L"";
- }
- }
- }
- break;
- case CPDF_AAction::Validate:
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- fa.sValue = pEdit->GetText();
- }
- }
- break;
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::GetFocus:
- ASSERT(m_pWidget != NULL);
- fa.sValue = m_pWidget->GetValue();
- break;
- default:
- break;
- }
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ fa.bFieldFull = pEdit->IsTextFull();
+ int nSelStart = 0;
+ int nSelEnd = 0;
+ pEdit->GetSel(nSelStart, nSelEnd);
+ fa.nSelEnd = nSelEnd;
+ fa.nSelStart = nSelStart;
+ fa.sValue = pEdit->GetText();
+ fa.sChangeEx = GetSelectExportText();
+
+ if (fa.bFieldFull)
+ {
+ fa.sChange = L"";
+ fa.sChangeEx = L"";
+ }
+ }
+ }
+ break;
+ case CPDF_AAction::Validate:
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ fa.sValue = pEdit->GetText();
+ }
+ }
+ break;
+ case CPDF_AAction::LoseFocus:
+ case CPDF_AAction::GetFocus:
+ ASSERT(m_pWidget != NULL);
+ fa.sValue = m_pWidget->GetValue();
+ break;
+ default:
+ break;
+ }
}
void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa)
+ const PDFSDK_FieldAction& fa)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
- }
- }
- break;
- default:
- break;
- }
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
+ pEdit->ReplaceSel(fa.sChange.c_str());
+ }
+ }
+ break;
+ default:
+ break;
+ }
}
-FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
- const PDFSDK_FieldAction& faNew)
+FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
+ const PDFSDK_FieldAction& faNew)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||
- faOld.sChange != faNew.sChange;
- default:
- break;
- }
-
- return FALSE;
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||
+ faOld.sChange != faNew.sChange;
+ default:
+ break;
+ }
+
+ return FALSE;
}
void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView)
{
- ASSERT(pPageView != NULL);
-
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- m_State.nIndex = pComboBox->GetSelect();
-
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- pEdit->GetSel(m_State.nStart, m_State.nEnd);
- m_State.sValue = pEdit->GetText();
- }
- }
+ ASSERT(pPageView != NULL);
+
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ m_State.nIndex = pComboBox->GetSelect();
+
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ pEdit->GetSel(m_State.nStart, m_State.nEnd);
+ m_State.sValue = pEdit->GetText();
+ }
+ }
}
void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView)
{
- ASSERT(pPageView != NULL);
-
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE))
- {
- if (m_State.nIndex >= 0)
- pComboBox->SetSelect(m_State.nIndex);
- else
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- pEdit->SetText(m_State.sValue.c_str());
- pEdit->SetSel(m_State.nStart, m_State.nEnd);
- }
- }
- }
+ ASSERT(pPageView != NULL);
+
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE))
+ {
+ if (m_State.nIndex >= 0)
+ pComboBox->SetSelect(m_State.nIndex);
+ else
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ pEdit->SetText(m_State.sValue.c_str());
+ pEdit->SetSel(m_State.nStart, m_State.nEnd);
+ }
+ }
+ }
}
CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue)
{
- if (bRestoreValue)
- SaveState(pPageView);
+ if (bRestoreValue)
+ SaveState(pPageView);
- DestroyPDFWindow(pPageView);
+ DestroyPDFWindow(pPageView);
- CPWL_Wnd* pRet = NULL;
+ CPWL_Wnd* pRet = NULL;
- if (bRestoreValue)
- {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- }
- else
- pRet = GetPDFWindow(pPageView, TRUE);
+ if (bRestoreValue)
+ {
+ RestoreState(pPageView);
+ pRet = GetPDFWindow(pPageView, FALSE);
+ }
+ else
+ pRet = GetPDFWindow(pPageView, TRUE);
- m_pWidget->UpdateField();
+ m_pWidget->UpdateField();
- return pRet;
+ return pRet;
}
void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag)
{
- ASSERT(m_pWidget != NULL);
-
- int nFlags = m_pWidget->GetFieldFlags();
-
- if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
- {
- if (m_bValid)
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
-
- if (CommitData(pPageView, nFlag))
- {
- DestroyPDFWindow(pPageView);
- m_bValid = FALSE;
- }
- }
- }
+ ASSERT(m_pWidget != NULL);
+
+ int nFlags = m_pWidget->GetFieldFlags();
+
+ if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
+ {
+ if (m_bValid)
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
+
+ if (CommitData(pPageView, nFlag))
+ {
+ DestroyPDFWindow(pPageView);
+ m_bValid = FALSE;
+ }
+ }
+ }
}
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd)
{
- ASSERT(m_pApp != NULL);
+ ASSERT(m_pApp != NULL);
- ASSERT(pWnd != NULL);
+ ASSERT(pWnd != NULL);
- if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
- {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCharSet(134);
- pEdit->SetCodePage(936);
+ if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
+ {
+ CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
+ pEdit->SetCharSet(134);
+ pEdit->SetCodePage(936);
- pEdit->SetReadyToInput();
- CFX_WideString wsText = pEdit->GetText();
- int nCharacters = wsText.GetLength();
- CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
- unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
- m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);
+ pEdit->SetReadyToInput();
+ CFX_WideString wsText = pEdit->GetText();
+ int nCharacters = wsText.GetLength();
+ CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
+ unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
+ m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);
- pEdit->SetEditNotify(this);
- }
+ pEdit->SetEditNotify(this);
+ }
}
void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd)
{
- ASSERT(m_pApp != NULL);
+ ASSERT(m_pApp != NULL);
}
-FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- return FALSE;
+ return FALSE;
}
void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit)
{
- ASSERT(pEdit != NULL);
+ ASSERT(pEdit != NULL);
}
CFX_WideString CFFL_ComboBox::GetSelectExportText()
{
- CFX_WideString swRet;
-
- int nExport = -1;
- CPDFSDK_PageView *pPageView = GetCurPageView();
- if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- nExport = pComboBox->GetSelect();
- }
-
- if (nExport >= 0)
- {
- if (CPDF_FormField * pFormField = m_pWidget->GetFormField())
- {
- swRet = pFormField->GetOptionValue(nExport);
- if (swRet.IsEmpty())
- swRet = pFormField->GetOptionLabel(nExport);
- }
- }
-
- return swRet;
+ CFX_WideString swRet;
+
+ int nExport = -1;
+ CPDFSDK_PageView *pPageView = GetCurPageView();
+ if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ nExport = pComboBox->GetSelect();
+ }
+
+ if (nExport >= 0)
+ {
+ if (CPDF_FormField * pFormField = m_pWidget->GetFormField())
+ {
+ swRet = pFormField->GetOptionValue(nExport);
+ if (swRet.IsEmpty())
+ swRet = pFormField->GetOptionLabel(nExport);
+ }
+ }
+
+ return swRet;
}
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index cd4b45b062..7ce811e85b 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -13,7 +13,7 @@
#include "../../include/formfiller/FFL_RadioButton.h"
#include "../../include/formfiller/FFL_TextField.h"
-#define FFL_MAXLISTBOXHEIGHT 140.0f
+#define FFL_MAXLISTBOXHEIGHT 140.0f
// HHOOK CFFL_IFormFiller::m_hookSheet = NULL;
// MSG CFFL_IFormFiller::g_Msg;
@@ -21,8 +21,8 @@
/* ----------------------------- CFFL_IFormFiller ----------------------------- */
CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) :
- m_pApp(pApp),
- m_bNotifying(FALSE)
+ m_pApp(pApp),
+ m_bNotifying(FALSE)
{
}
@@ -33,554 +33,531 @@ CFFL_IFormFiller::~CFFL_IFormFiller()
m_Maps.clear();
}
-FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)
+FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)
{
- CPDF_Rect rc = pAnnot->GetRect();
- if(rc.Contains(point.x, point.y))
- return TRUE;
- return FALSE;
+ CPDF_Rect rc = pAnnot->GetRect();
+ if(rc.Contains(point.x, point.y))
+ return TRUE;
+ return FALSE;
}
FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
{
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->GetViewBBox(pPageView, pAnnot);
- }
- else
- {
- ASSERT(pPageView != NULL);
- ASSERT(pAnnot != NULL);
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ return pFormFiller->GetViewBBox(pPageView, pAnnot);
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- ASSERT(pPDFAnnot != NULL);
+ ASSERT(pPageView != NULL);
- CPDF_Rect rcAnnot;
- pPDFAnnot->GetRect(rcAnnot);
+ CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+ CPDF_Rect rcAnnot;
+ pPDFAnnot->GetRect(rcAnnot);
-// CRect rcWin;
-// pPageView->DocToWindow(rcAnnot, rcWin);
- CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot,1);
-// rcWin.InflateRect(1, 1);
-
- return rcWin.GetOutterRect();
- }
+ CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1);
+ return rcWin.GetOutterRect();
}
void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
-{
- ASSERT(pPageView != NULL);
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-
- if (IsVisible(pWidget))
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- if (pFormFiller->IsValid())
- {
- pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
- pAnnot->GetPDFPage();
-
- CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
- if (pDocument->GetFocusAnnot() == pAnnot)
- {
- CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView);
- if (!rcFocus.IsEmpty())
- {
- CFX_PathData path;
- path.SetPointCount(5);
- path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO);
- path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO);
- path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO);
- path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO);
- path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.SetDashCount(1);
- gsd.m_DashArray[0] = 1.0f;
- gsd.m_DashPhase = 0;
- gsd.m_LineWidth = 1.0f;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,0,0,0), FXFILL_ALTERNATE);
- }
- }
- return;
- }
- }
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
-
- if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))
- pWidget->DrawShadow(pDevice, pPageView);
- }
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
+{
+ ASSERT(pPageView != NULL);
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+
+ if (IsVisible(pWidget))
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ if (pFormFiller->IsValid())
+ {
+ pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+ pAnnot->GetPDFPage();
+
+ CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
+ if (pDocument->GetFocusAnnot() == pAnnot)
+ {
+ CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView);
+ if (!rcFocus.IsEmpty())
+ {
+ CFX_PathData path;
+ path.SetPointCount(5);
+ path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO);
+ path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO);
+ path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO);
+ path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO);
+ path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO);
+
+ CFX_GraphStateData gsd;
+ gsd.SetDashCount(1);
+ gsd.m_DashArray[0] = 1.0f;
+ gsd.m_DashPhase = 0;
+ gsd.m_LineWidth = 1.0f;
+ pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,0,0,0), FXFILL_ALTERNATE);
+ }
+ }
+ return;
+ }
+ }
+
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+ else
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+
+ if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))
+ pWidget->DrawShadow(pDevice, pPageView);
+ }
}
void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot)
{
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- pFormFiller->OnCreate(pAnnot);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ pFormFiller->OnCreate(pAnnot);
+ }
}
void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot)
{
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- pFormFiller->OnLoad(pAnnot);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ pFormFiller->OnLoad(pAnnot);
+ }
}
void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot)
{
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- pFormFiller->OnDelete(pAnnot);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ pFormFiller->OnDelete(pAnnot);
+ }
- UnRegisterFormFiller(pAnnot);
+ UnRegisterFormFiller(pAnnot);
}
void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorEnter))
- {
- m_bNotifying = TRUE;
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::CursorEnter))
+ {
+ m_bNotifying = TRUE;
- int nValueAge = pWidget->GetValueAge();
+ int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView );
- m_bNotifying = FALSE;
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView );
+ m_bNotifying = FALSE;
- //if ( !IsValidAnnot(pPageView, pAnnot) ) return;
+ //if ( !IsValidAnnot(pPageView, pAnnot) ) return;
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, pWidget->GetValueAge() == nValueAge);
- }
- }
- }
- }
+ if (pWidget->IsAppModified())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, pWidget->GetValueAge() == nValueAge);
+ }
+ }
+ }
+ }
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
- {
- pFormFiller->OnMouseEnter(pPageView, pAnnot);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+ {
+ pFormFiller->OnMouseEnter(pPageView, pAnnot);
+ }
}
void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::CursorExit))
+ {
+ m_bNotifying = TRUE;
+ pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+ pWidget->ClearAppModified();
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorExit))
- {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
+ ASSERT(pPageView != NULL);
- ASSERT(pPageView != NULL);
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);
- m_bNotifying = FALSE;
+ pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);
+ m_bNotifying = FALSE;
- //if (!IsValidAnnot(pPageView, pAnnot)) return;
+ //if (!IsValidAnnot(pPageView, pAnnot)) return;
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
+ if (pWidget->IsAppModified())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+ }
+ }
+ }
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- pFormFiller->OnMouseExit(pPageView, pAnnot);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ pFormFiller->OnMouseExit(pPageView, pAnnot);
+ }
}
-FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (Annot_HitTest(pPageView, pAnnot, point) && pWidget->GetAAction(CPDF_AAction::ButtonDown))
- {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (Annot_HitTest(pPageView, pAnnot, point) && pWidget->GetAAction(CPDF_AAction::ButtonDown))
+ {
+ m_bNotifying = TRUE;
+ pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags);
- pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView);
- m_bNotifying = FALSE;
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags);
+ pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView);
+ m_bNotifying = FALSE;
- if (!IsValidAnnot(pPageView, pAnnot)) return TRUE;
+ if (!IsValidAnnot(pPageView, pAnnot)) return TRUE;
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
+ if (pWidget->IsAppModified())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+ }
+ }
+ }
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
-
- switch (pWidget->GetFieldType())
- {
- case FIELDTYPE_PUSHBUTTON:
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))
- pDocument->SetFocusAnnot(pAnnot);
- break;
- default:
- pDocument->SetFocusAnnot(pAnnot);
- break;
- }
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
+
+ switch (pWidget->GetFieldType())
+ {
+ case FIELDTYPE_PUSHBUTTON:
+ case FIELDTYPE_CHECKBOX:
+ case FIELDTYPE_RADIOBUTTON:
+ if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))
+ pDocument->SetFocusAnnot(pAnnot);
+ break;
+ default:
+ pDocument->SetFocusAnnot(pAnnot);
+ break;
+ }
- FX_BOOL bRet = FALSE;
+ FX_BOOL bRet = FALSE;
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
+ }
- if (pDocument->GetFocusAnnot() == pAnnot)
- {
- FX_BOOL bExit = FALSE;
- FX_BOOL bReset = FALSE;
- OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags);
- if (bExit) return TRUE;
- }
- return bRet;
+ if (pDocument->GetFocusAnnot() == pAnnot)
+ {
+ FX_BOOL bExit = FALSE;
+ FX_BOOL bReset = FALSE;
+ OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags);
+ if (bExit) return TRUE;
+ }
+ return bRet;
}
void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag)
{
- ASSERT(pWidget != NULL);
+ ASSERT(pWidget != NULL);
- if (!m_bNotifying)
- {
- if (pWidget->GetAAction(CPDF_AAction::ButtonUp))
- {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
+ if (!m_bNotifying)
+ {
+ if (pWidget->GetAAction(CPDF_AAction::ButtonUp))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);
- m_bNotifying = FALSE;
+ pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);
+ m_bNotifying = FALSE;
- if (!IsValidAnnot(pPageView, pWidget))
- {
- bExit = TRUE;
- return;
- }
+ if (!IsValidAnnot(pPageView, pWidget))
+ {
+ bExit = TRUE;
+ return;
+ }
- if (nAge != pWidget->GetAppearanceAge())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
+ if (nAge != pWidget->GetAppearanceAge())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
- bReset = TRUE;
- }
- }
- }
+ bReset = TRUE;
+ }
+ }
+ }
}
-FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- //change cursor
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
- {
- return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
- }
+ //change cursor
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+ {
+ return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
+FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (nChar == FWL_VKEY_Tab) return TRUE;
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ if (nChar == FWL_VKEY_Tab)
+ return TRUE;
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnChar(pAnnot, nChar, nFlags);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ return pFormFiller->OnChar(pAnnot, nChar, nFlags);
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
{
- if(!pAnnot) return FALSE;
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::GetFocus))
- {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
-
-
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- ASSERT(pPageView != NULL);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);
- if(!pFormFiller) return FALSE;
- pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);
-
- pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView);
- m_bNotifying = FALSE;
-
- // if (!IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pAnnot)) return FALSE;
-
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
+ if (!pAnnot)
+ return FALSE;
+
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::GetFocus))
+ {
+ m_bNotifying = TRUE;
+ pWidget->GetAppearanceAge();
+
+ int nValueAge = pWidget->GetValueAge();
+ pWidget->ClearAppModified();
+
+ CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ ASSERT(pPageView != NULL);
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);
+ if(!pFormFiller) return FALSE;
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);
+ pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView);
+ m_bNotifying = FALSE;
+
+ if (pWidget->IsAppModified())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+ }
+ }
+ }
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
- {
- if (pFormFiller->OnSetFocus(pAnnot, nFlag))
- {
- return TRUE;
- }
- else
- return FALSE;
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+ return pFormFiller->OnSetFocus(pAnnot, nFlag);
- return TRUE;
+ return TRUE;
}
-FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
+FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
{
- if(!pAnnot) return FALSE;
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ if(!pAnnot) return FALSE;
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- if (pFormFiller->OnKillFocus(pAnnot, nFlag))
- {
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::LoseFocus))
- {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ if (pFormFiller->OnKillFocus(pAnnot, nFlag))
+ {
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::LoseFocus))
+ {
+ m_bNotifying = TRUE;
+ pWidget->ClearAppModified();
- CPDFSDK_PageView* pPageView = pWidget->GetPageView();
- ASSERT(pPageView != NULL);
+ CPDFSDK_PageView* pPageView = pWidget->GetPageView();
+ ASSERT(pPageView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
- pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
- m_bNotifying = FALSE;
+ pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
+ m_bNotifying = FALSE;
- }
- }
- }
- else
- return FALSE;
- }
+ }
+ }
+ }
+ else
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget)
+FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget)
{
- return pWidget->IsVisible();
+ return pWidget->IsVisible();
}
-FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget)
+FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget)
{
- ASSERT(pWidget != NULL);
+ ASSERT(pWidget != NULL);
- int nFieldFlags = pWidget->GetFieldFlags();
+ int nFieldFlags = pWidget->GetFieldFlags();
- return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
+ return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
}
-FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)
+FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)
{
- ASSERT(pWidget != NULL);
+ ASSERT(pWidget != NULL);
- if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return TRUE;
- else
- {
- CPDF_Page* pPage = pWidget->GetPDFPage();
- ASSERT(pPage != NULL);
+ if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+ return TRUE;
+ else
+ {
+ CPDF_Page* pPage = pWidget->GetPDFPage();
+ ASSERT(pPage != NULL);
- CPDF_Document* pDocument = pPage->m_pDocument;
- ASSERT(pDocument != NULL);
+ CPDF_Document* pDocument = pPage->m_pDocument;
+ ASSERT(pDocument != NULL);
- FX_DWORD dwPermissions = pDocument->GetUserPermissions();
- return (dwPermissions&FPDFPERM_FILL_FORM) ||
- (dwPermissions&FPDFPERM_ANNOT_FORM) ||
- (dwPermissions&FPDFPERM_MODIFY);
- }
- return TRUE;
+ FX_DWORD dwPermissions = pDocument->GetUserPermissions();
+ return (dwPermissions&FPDFPERM_FILL_FORM) ||
+ (dwPermissions&FPDFPERM_ANNOT_FORM) ||
+ (dwPermissions&FPDFPERM_MODIFY);
+ }
+ return TRUE;
}
CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister)
@@ -629,10 +606,10 @@ CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL
void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot)
{
- if ( pAnnot != NULL )
- {
- UnRegisterFormFiller( pAnnot );
- }
+ if ( pAnnot != NULL )
+ {
+ UnRegisterFormFiller( pAnnot );
+ }
}
void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)
@@ -647,330 +624,330 @@ void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)
void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet)
{
- ASSERT(pPrivateData != NULL);
-
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
-
-
-
-
- CPDF_Rect rcPageView(0,0,0,0);
- rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();
- rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();
- rcPageView.Normalize();
-
-
- ASSERT(pData->pWidget != NULL);
- CPDF_Rect rcAnnot = pData->pWidget->GetRect();
-
- FX_FLOAT fTop = 0.0f;
- FX_FLOAT fBottom = 0.0f;
-
- CPDFSDK_Widget * pWidget = (CPDFSDK_Widget*)pData->pWidget;
- switch (pWidget->GetRotate() / 90)
- {
- default:
- case 0:
- fTop = rcPageView.top - rcAnnot.top;
- fBottom = rcAnnot.bottom - rcPageView.bottom;
- break;
- case 1:
- fTop = rcAnnot.left - rcPageView.left;
- fBottom = rcPageView.right - rcAnnot.right;
- break;
- case 2:
- fTop = rcAnnot.bottom - rcPageView.bottom;
- fBottom = rcPageView.top - rcAnnot.top;
- break;
- case 3:
- fTop = rcPageView.right - rcAnnot.right;
- fBottom = rcAnnot.left - rcPageView.left;
- break;
- }
-
- FX_FLOAT fFactHeight = 0;
- FX_BOOL bBottom = TRUE;
- FX_FLOAT fMaxListBoxHeight = 0;
- if (fPopupMax > FFL_MAXLISTBOXHEIGHT)
- {
- if (fPopupMin > FFL_MAXLISTBOXHEIGHT)
- {
- fMaxListBoxHeight = fPopupMin;
- }
- else
- {
- fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT;
- }
- }
- else
- fMaxListBoxHeight = fPopupMax;
-
- if (fBottom > fMaxListBoxHeight)
- {
- fFactHeight = fMaxListBoxHeight;
- bBottom = TRUE;
- }
- else
- {
- if (fTop > fMaxListBoxHeight)
- {
- fFactHeight = fMaxListBoxHeight;
- bBottom = FALSE;
- }
- else
- {
- if (fTop > fBottom)
- {
- fFactHeight = fTop;
- bBottom = FALSE;
- }
- else
- {
- fFactHeight = fBottom;
- bBottom = TRUE;
- }
- }
- }
-
- nRet = bBottom ? 0 : 1;
- fPopupRet = fFactHeight;
+ ASSERT(pPrivateData != NULL);
+
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+
+
+
+
+ CPDF_Rect rcPageView(0,0,0,0);
+ rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();
+ rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();
+ rcPageView.Normalize();
+
+
+ ASSERT(pData->pWidget != NULL);
+ CPDF_Rect rcAnnot = pData->pWidget->GetRect();
+
+ FX_FLOAT fTop = 0.0f;
+ FX_FLOAT fBottom = 0.0f;
+
+ CPDFSDK_Widget * pWidget = (CPDFSDK_Widget*)pData->pWidget;
+ switch (pWidget->GetRotate() / 90)
+ {
+ default:
+ case 0:
+ fTop = rcPageView.top - rcAnnot.top;
+ fBottom = rcAnnot.bottom - rcPageView.bottom;
+ break;
+ case 1:
+ fTop = rcAnnot.left - rcPageView.left;
+ fBottom = rcPageView.right - rcAnnot.right;
+ break;
+ case 2:
+ fTop = rcAnnot.bottom - rcPageView.bottom;
+ fBottom = rcPageView.top - rcAnnot.top;
+ break;
+ case 3:
+ fTop = rcPageView.right - rcAnnot.right;
+ fBottom = rcAnnot.left - rcPageView.left;
+ break;
+ }
+
+ FX_FLOAT fFactHeight = 0;
+ FX_BOOL bBottom = TRUE;
+ FX_FLOAT fMaxListBoxHeight = 0;
+ if (fPopupMax > FFL_MAXLISTBOXHEIGHT)
+ {
+ if (fPopupMin > FFL_MAXLISTBOXHEIGHT)
+ {
+ fMaxListBoxHeight = fPopupMin;
+ }
+ else
+ {
+ fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT;
+ }
+ }
+ else
+ fMaxListBoxHeight = fPopupMax;
+
+ if (fBottom > fMaxListBoxHeight)
+ {
+ fFactHeight = fMaxListBoxHeight;
+ bBottom = TRUE;
+ }
+ else
+ {
+ if (fTop > fMaxListBoxHeight)
+ {
+ fFactHeight = fMaxListBoxHeight;
+ bBottom = FALSE;
+ }
+ else
+ {
+ if (fTop > fBottom)
+ {
+ fFactHeight = fTop;
+ bBottom = FALSE;
+ }
+ else
+ {
+ fFactHeight = fBottom;
+ bBottom = TRUE;
+ }
+ }
+ }
+
+ nRet = bBottom ? 0 : 1;
+ fPopupRet = fFactHeight;
}
void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag)
{
- if (!m_bNotifying)
- {
- ASSERT(pWidget != NULL);
- if (pWidget->GetAAction(CPDF_AAction::KeyStroke))
- {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ if (pWidget->GetAAction(CPDF_AAction::KeyStroke))
+ {
+ m_bNotifying = TRUE;
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.bWillCommit = TRUE;
- fa.bKeyDown = TRUE;
- fa.bRC = TRUE;
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ fa.bWillCommit = TRUE;
+ fa.bKeyDown = TRUE;
+ fa.bRC = TRUE;
- CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
- ASSERT(pFormFiller != NULL);
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
- pFormFiller->SaveState(pPageView);
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
+ pFormFiller->SaveState(pPageView);
- PDFSDK_FieldAction faOld = fa;
- pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
+ PDFSDK_FieldAction faOld = fa;
+ pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
- bRC = fa.bRC;
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+ bRC = fa.bRC;
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- m_bNotifying = FALSE;
- }
- }
+ m_bNotifying = FALSE;
+ }
+ }
}
void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag)
{
- if (!m_bNotifying)
- {
- ASSERT(pWidget != NULL);
- if (pWidget->GetAAction(CPDF_AAction::Validate))
- {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ if (pWidget->GetAAction(CPDF_AAction::Validate))
+ {
+ m_bNotifying = TRUE;
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.bKeyDown = TRUE;
- fa.bRC = TRUE;
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ fa.bKeyDown = TRUE;
+ fa.bRC = TRUE;
- CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
- ASSERT(pFormFiller != NULL);
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
- pFormFiller->SaveState(pPageView);
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
+ pFormFiller->SaveState(pPageView);
- PDFSDK_FieldAction faOld = fa;
- pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
+ PDFSDK_FieldAction faOld = fa;
+ pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
- bRC = fa.bRC;
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+ bRC = fa.bRC;
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- m_bNotifying = FALSE;
- }
- }
+ m_bNotifying = FALSE;
+ }
+ }
}
void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)
{
- if (!m_bNotifying)
- {
- ASSERT(pWidget != NULL);
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- ASSERT(pDocument != NULL);
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- pInterForm->OnCalculate(pWidget->GetFormField());
+ pInterForm->OnCalculate(pWidget->GetFormField());
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- m_bNotifying = FALSE;
- }
+ m_bNotifying = FALSE;
+ }
}
void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)
{
- if (!m_bNotifying)
- {
- ASSERT(pWidget != NULL);
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- ASSERT(pDocument != NULL);
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), bFormated);
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), bFormated);
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- if (bExit) return;
+ if (bExit) return;
- if (bFormated)
- {
- pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), TRUE);
- pInterForm->UpdateField(pWidget->GetFormField());
- }
+ if (bFormated)
+ {
+ pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), TRUE);
+ pInterForm->UpdateField(pWidget->GetFormField());
+ }
- m_bNotifying = FALSE;
- }
+ m_bNotifying = FALSE;
+ }
}
-FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
+FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
{
- ASSERT(pPageView != NULL);
- ASSERT(pAnnot != NULL);
+ ASSERT(pPageView != NULL);
+ ASSERT(pAnnot != NULL);
- if(pPageView)
- return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
- else
- return FALSE;
+ if(pPageView)
+ return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
+ else
+ return FALSE;
}
void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode,
- CFX_WideString & strChange, const CFX_WideString& strChangeEx,
- int nSelStart, int nSelEnd,
- FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag)
-{
- ASSERT(pPrivateData != NULL);
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData->pWidget != NULL);
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
- ASSERT(pFormFiller != NULL);
-
- if (!m_bNotifying)
- {
- if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))
- {
- m_bNotifying = TRUE;
- int nAge = pData->pWidget->GetAppearanceAge();
- int nValueAge = pData->pWidget->GetValueAge();
-
- ASSERT(pData->pPageView != NULL);
- CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument();
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.sChange = strChange;
- fa.sChangeEx = strChangeEx;
- fa.bKeyDown = bKeyDown;
- fa.bWillCommit = FALSE;
- fa.bRC = TRUE;
- fa.nSelStart = nSelStart;
- fa.nSelEnd = nSelEnd;
-
-
- pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
- pFormFiller->SaveState(pData->pPageView);
-
- if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pData->pPageView))
- {
- if (!IsValidAnnot(pData->pPageView, pData->pWidget))
- {
- bExit = TRUE;
- m_bNotifying = FALSE;
- return;
- }
-
- if (nAge != pData->pWidget->GetAppearanceAge())
- {
- CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(pData->pPageView, nValueAge == pData->pWidget->GetValueAge());
- pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- bExit = TRUE;
- }
-
- if (fa.bRC)
- {
- pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
- bRC = FALSE;
- }
- else
- {
- pFormFiller->RestoreState(pData->pPageView);
- bRC = FALSE;
- }
-
- if (pDocument->GetFocusAnnot() != pData->pWidget)
- {
- pFormFiller->CommitData(pData->pPageView,nFlag);
- bExit = TRUE;
- }
- }
- else
- {
- if (!IsValidAnnot(pData->pPageView, pData->pWidget))
- {
- bExit = TRUE;
- m_bNotifying = FALSE;
- return;
- }
- }
-
- m_bNotifying = FALSE;
- }
- }
-}
-
-void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag)
-{
- ASSERT(pPrivateData != NULL);
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData->pWidget != NULL);
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
- ASSERT(pFormFiller != NULL);
-
- if (!bEditOrList)
- pFormFiller->OnKeyStroke(bExit);
+ CFX_WideString & strChange, const CFX_WideString& strChangeEx,
+ int nSelStart, int nSelEnd,
+ FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag)
+{
+ ASSERT(pPrivateData != NULL);
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+ ASSERT(pData->pWidget != NULL);
+
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
+
+ if (!m_bNotifying)
+ {
+ if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pData->pWidget->GetAppearanceAge();
+ int nValueAge = pData->pWidget->GetValueAge();
+
+ ASSERT(pData->pPageView != NULL);
+ CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument();
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ fa.sChange = strChange;
+ fa.sChangeEx = strChangeEx;
+ fa.bKeyDown = bKeyDown;
+ fa.bWillCommit = FALSE;
+ fa.bRC = TRUE;
+ fa.nSelStart = nSelStart;
+ fa.nSelEnd = nSelEnd;
+
+
+ pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
+ pFormFiller->SaveState(pData->pPageView);
+
+ if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pData->pPageView))
+ {
+ if (!IsValidAnnot(pData->pPageView, pData->pWidget))
+ {
+ bExit = TRUE;
+ m_bNotifying = FALSE;
+ return;
+ }
+
+ if (nAge != pData->pWidget->GetAppearanceAge())
+ {
+ CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(pData->pPageView, nValueAge == pData->pWidget->GetValueAge());
+ pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
+ bExit = TRUE;
+ }
+
+ if (fa.bRC)
+ {
+ pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
+ bRC = FALSE;
+ }
+ else
+ {
+ pFormFiller->RestoreState(pData->pPageView);
+ bRC = FALSE;
+ }
+
+ if (pDocument->GetFocusAnnot() != pData->pWidget)
+ {
+ pFormFiller->CommitData(pData->pPageView,nFlag);
+ bExit = TRUE;
+ }
+ }
+ else
+ {
+ if (!IsValidAnnot(pData->pPageView, pData->pWidget))
+ {
+ bExit = TRUE;
+ m_bNotifying = FALSE;
+ return;
+ }
+ }
+
+ m_bNotifying = FALSE;
+ }
+ }
+}
+
+void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag)
+{
+ ASSERT(pPrivateData != NULL);
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+ ASSERT(pData->pWidget != NULL);
+
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
+
+ if (!bEditOrList)
+ pFormFiller->OnKeyStroke(bExit);
}
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
index a5be60ed4e..a4b87263ed 100644
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp
@@ -10,11 +10,11 @@
/* ------------------------------- CFFL_TextField ------------------------------- */
CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) :
- CFFL_FormFiller(pApp, pAnnot),
- m_pFontMap(NULL)//,
- //m_pSpellCheck(NULL)
+ CFFL_FormFiller(pApp, pAnnot),
+ m_pFontMap(NULL)//,
+ //m_pSpellCheck(NULL)
{
- m_State.nStart = m_State.nEnd = 0;
+ m_State.nStart = m_State.nEnd = 0;
}
CFFL_TextField::~CFFL_TextField()
@@ -24,316 +24,313 @@ CFFL_TextField::~CFFL_TextField()
PWL_CREATEPARAM CFFL_TextField::GetCreateParam()
{
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
- ASSERT(m_pWidget != NULL);
- int nFlags = m_pWidget->GetFieldFlags();
-
-
- if (nFlags & FIELDFLAG_PASSWORD)
- {
- cp.dwFlags |= PES_PASSWORD;
- }
-
- if (!(nFlags & FIELDFLAG_DONOTSPELLCHECK))
- {
- }
-
- if (nFlags & FIELDFLAG_MULTILINE)
- {
- cp.dwFlags |= PES_MULTILINE | PES_AUTORETURN | PES_TOP;
-
- if (!(nFlags & FIELDFLAG_DONOTSCROLL))
- {
- cp.dwFlags |= PWS_VSCROLL | PES_AUTOSCROLL;
- }
- }
- else
- {
- cp.dwFlags |= PES_CENTER;
-
- if (!(nFlags & FIELDFLAG_DONOTSCROLL))
- {
- cp.dwFlags |= PES_AUTOSCROLL;
- }
- }
-
- if (nFlags & FIELDFLAG_COMB)
- {
- cp.dwFlags |= PES_CHARARRAY;
- }
-
- if (nFlags & FIELDFLAG_RICHTEXT)
- {
- cp.dwFlags |= PES_RICH;
- }
-
- cp.dwFlags |= PES_UNDO;
-
- switch (m_pWidget->GetAlignment())
- {
- default:
- case BF_ALIGN_LEFT:
- cp.dwFlags |= PES_LEFT;
- break;
- case BF_ALIGN_MIDDLE:
- cp.dwFlags |= PES_MIDDLE;
- break;
- case BF_ALIGN_RIGHT:
- cp.dwFlags |= PES_RIGHT;
- break;
- }
-
- if (!m_pFontMap)
- {
- m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler());
- m_pFontMap->Initial();
- }
- cp.pFontMap = m_pFontMap;
- cp.pFocusHandler = this;
-
- return cp;
+ PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
+
+ ASSERT(m_pWidget != NULL);
+ int nFlags = m_pWidget->GetFieldFlags();
+
+
+ if (nFlags & FIELDFLAG_PASSWORD)
+ {
+ cp.dwFlags |= PES_PASSWORD;
+ }
+
+ if (!(nFlags & FIELDFLAG_DONOTSPELLCHECK))
+ {
+ }
+
+ if (nFlags & FIELDFLAG_MULTILINE)
+ {
+ cp.dwFlags |= PES_MULTILINE | PES_AUTORETURN | PES_TOP;
+
+ if (!(nFlags & FIELDFLAG_DONOTSCROLL))
+ {
+ cp.dwFlags |= PWS_VSCROLL | PES_AUTOSCROLL;
+ }
+ }
+ else
+ {
+ cp.dwFlags |= PES_CENTER;
+
+ if (!(nFlags & FIELDFLAG_DONOTSCROLL))
+ {
+ cp.dwFlags |= PES_AUTOSCROLL;
+ }
+ }
+
+ if (nFlags & FIELDFLAG_COMB)
+ {
+ cp.dwFlags |= PES_CHARARRAY;
+ }
+
+ if (nFlags & FIELDFLAG_RICHTEXT)
+ {
+ cp.dwFlags |= PES_RICH;
+ }
+
+ cp.dwFlags |= PES_UNDO;
+
+ switch (m_pWidget->GetAlignment())
+ {
+ default:
+ case BF_ALIGN_LEFT:
+ cp.dwFlags |= PES_LEFT;
+ break;
+ case BF_ALIGN_MIDDLE:
+ cp.dwFlags |= PES_MIDDLE;
+ break;
+ case BF_ALIGN_RIGHT:
+ cp.dwFlags |= PES_RIGHT;
+ break;
+ }
+
+ if (!m_pFontMap)
+ {
+ m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler());
+ m_pFontMap->Initial();
+ }
+ cp.pFontMap = m_pFontMap;
+ cp.pFocusHandler = this;
+
+ return cp;
}
CPWL_Wnd* CFFL_TextField::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView)
{
- CPWL_Edit * pWnd = new CPWL_Edit();
- pWnd->AttachFFLData(this);
- pWnd->Create(cp);
-
-
-
- ASSERT(m_pApp != NULL);
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- pWnd->SetFillerNotify(pIFormFiller);
-
- ASSERT(m_pWidget != NULL);
- int32_t nMaxLen = m_pWidget->GetMaxLen();
- CFX_WideString swValue = m_pWidget->GetValue();
-
- if (nMaxLen > 0)
- {
- if (pWnd->HasFlag(PES_CHARARRAY))
- {
- pWnd->SetCharArray(nMaxLen);
- pWnd->SetAlignFormatV(PEAV_CENTER);
- }
- else
- {
- pWnd->SetLimitChar(nMaxLen);
- }
- }
-
- pWnd->SetText(swValue.c_str());
- return pWnd;
+ CPWL_Edit * pWnd = new CPWL_Edit();
+ pWnd->AttachFFLData(this);
+ pWnd->Create(cp);
+
+
+
+ ASSERT(m_pApp != NULL);
+ CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
+ pWnd->SetFillerNotify(pIFormFiller);
+
+ ASSERT(m_pWidget != NULL);
+ int32_t nMaxLen = m_pWidget->GetMaxLen();
+ CFX_WideString swValue = m_pWidget->GetValue();
+
+ if (nMaxLen > 0)
+ {
+ if (pWnd->HasFlag(PES_CHARARRAY))
+ {
+ pWnd->SetCharArray(nMaxLen);
+ pWnd->SetAlignFormatV(PEAV_CENTER);
+ }
+ else
+ {
+ pWnd->SetLimitChar(nMaxLen);
+ }
+ }
+
+ pWnd->SetText(swValue.c_str());
+ return pWnd;
}
-FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
{
- switch (nChar)
- {
- case FWL_VKEY_Return:
- if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE))
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
- m_bValid = !m_bValid;
- CPDF_Rect rcAnnot = pAnnot->GetRect();
- m_pApp->FFI_Invalidate(pAnnot->GetPDFPage(), rcAnnot.left, rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
-
- if (m_bValid)
- {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
- pWnd->SetFocus();
- }
- else
- {
- if (CommitData(pPageView, nFlags))
- {
- DestroyPDFWindow(pPageView);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- }
- break;
- case FWL_VKEY_Escape:
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
- EscapeFiller(pPageView,TRUE);
- return TRUE;
- }
- }
-
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+ switch (nChar)
+ {
+ case FWL_VKEY_Return:
+ if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE))
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
+ m_bValid = !m_bValid;
+ CPDF_Rect rcAnnot = pAnnot->GetRect();
+ m_pApp->FFI_Invalidate(pAnnot->GetPDFPage(), rcAnnot.left, rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
+
+ if (m_bValid)
+ {
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
+ pWnd->SetFocus();
+ }
+ else
+ {
+ if (CommitData(pPageView, nFlags))
+ {
+ DestroyPDFWindow(pPageView);
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+ break;
+ case FWL_VKEY_Escape:
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
+ EscapeFiller(pPageView,TRUE);
+ return TRUE;
+ }
+ }
+
+ return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
}
-FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView)
+FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pWidget != NULL);
+ ASSERT(m_pWidget != NULL);
- if (CPWL_Edit * pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- return pEdit->GetText() != m_pWidget->GetValue();
+ if (CPWL_Edit * pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ return pEdit->GetText() != m_pWidget->GetValue();
- return FALSE;
+ return FALSE;
}
void CFFL_TextField::SaveData(CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pWidget != NULL);
-
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- {
- CFX_WideString sOldValue = m_pWidget->GetValue();
- CFX_WideString sNewValue = pWnd->GetText();
-
- m_pWidget->SetValue(sNewValue, FALSE);
- m_pWidget->ResetFieldAppearance(TRUE);
- m_pWidget->UpdateField();
- SetChangeMark();
- }
+ ASSERT(m_pWidget != NULL);
+
+ if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ {
+ CFX_WideString sOldValue = m_pWidget->GetValue();
+ CFX_WideString sNewValue = pWnd->GetText();
+
+ m_pWidget->SetValue(sNewValue, FALSE);
+ m_pWidget->ResetFieldAppearance(TRUE);
+ m_pWidget->UpdateField();
+ SetChangeMark();
+ }
}
void CFFL_TextField::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& fa)
+ PDFSDK_FieldAction& fa)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- {
- fa.bFieldFull = pWnd->IsTextFull();
-
- fa.sValue = pWnd->GetText();
-
- if (fa.bFieldFull)
- {
- fa.sChange = L"";
- fa.sChangeEx = L"";
- }
- }
- break;
- case CPDF_AAction::Validate:
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- {
- fa.sValue = pWnd->GetText();
- }
- break;
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::GetFocus:
- ASSERT(m_pWidget != NULL);
- fa.sValue = m_pWidget->GetValue();
- break;
- default:
- break;
- }
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ {
+ fa.bFieldFull = pWnd->IsTextFull();
+
+ fa.sValue = pWnd->GetText();
+
+ if (fa.bFieldFull)
+ {
+ fa.sChange = L"";
+ fa.sChangeEx = L"";
+ }
+ }
+ break;
+ case CPDF_AAction::Validate:
+ if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ {
+ fa.sValue = pWnd->GetText();
+ }
+ break;
+ case CPDF_AAction::LoseFocus:
+ case CPDF_AAction::GetFocus:
+ ASSERT(m_pWidget != NULL);
+ fa.sValue = m_pWidget->GetValue();
+ break;
+ default:
+ break;
+ }
}
void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa)
+ const PDFSDK_FieldAction& fa)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- if (CPWL_Edit * pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- {
- pEdit->SetFocus();
- pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
- }
- break;
- default:
- break;
- }
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ if (CPWL_Edit * pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ {
+ pEdit->SetFocus();
+ pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
+ pEdit->ReplaceSel(fa.sChange.c_str());
+ }
+ break;
+ default:
+ break;
+ }
}
-FX_BOOL CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
- const PDFSDK_FieldAction& faNew)
+FX_BOOL CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
+ const PDFSDK_FieldAction& faNew)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||
- faOld.sChange != faNew.sChange;
- default:
- break;
- }
-
- return FALSE;
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||
+ faOld.sChange != faNew.sChange;
+ default:
+ break;
+ }
+
+ return FALSE;
}
void CFFL_TextField::SaveState(CPDFSDK_PageView* pPageView)
{
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- {
- pWnd->GetSel(m_State.nStart, m_State.nEnd);
- m_State.sValue = pWnd->GetText();
- }
+ if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ {
+ pWnd->GetSel(m_State.nStart, m_State.nEnd);
+ m_State.sValue = pWnd->GetText();
+ }
}
void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView)
{
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE))
- {
- pWnd->SetText(m_State.sValue.c_str());
- pWnd->SetSel(m_State.nStart, m_State.nEnd);
- }
+ if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE))
+ {
+ pWnd->SetText(m_State.sValue.c_str());
+ pWnd->SetSel(m_State.nStart, m_State.nEnd);
+ }
}
CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue)
{
- if (bRestoreValue)
- SaveState(pPageView);
+ if (bRestoreValue)
+ SaveState(pPageView);
- DestroyPDFWindow(pPageView);
+ DestroyPDFWindow(pPageView);
- CPWL_Wnd* pRet = NULL;
+ CPWL_Wnd* pRet = NULL;
- if (bRestoreValue)
- {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- }
- else
- pRet = GetPDFWindow(pPageView, TRUE);
+ if (bRestoreValue)
+ {
+ RestoreState(pPageView);
+ pRet = GetPDFWindow(pPageView, FALSE);
+ }
+ else
+ pRet = GetPDFWindow(pPageView, TRUE);
- m_pWidget->UpdateField();
+ m_pWidget->UpdateField();
- return pRet;
+ return pRet;
}
void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd)
{
- ASSERT(m_pApp != NULL);
-
- ASSERT(pWnd != NULL);
-
- if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
- {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCharSet(134);
- pEdit->SetCodePage(936);
-
- pEdit->SetReadyToInput();
- CFX_WideString wsText = pEdit->GetText();
- int nCharacters = wsText.GetLength();
- CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
- unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
- m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);
-
- pEdit->SetEditNotify(this);
- //pUndo->BeginEdit(pDocument);
- }
+ ASSERT(m_pApp != NULL);
+
+ ASSERT(pWnd != NULL);
+
+ if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
+ {
+ CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
+ pEdit->SetCharSet(134);
+ pEdit->SetCodePage(936);
+
+ pEdit->SetReadyToInput();
+ CFX_WideString wsText = pEdit->GetText();
+ int nCharacters = wsText.GetLength();
+ CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
+ unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
+ m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE);
+
+ pEdit->SetEditNotify(this);
+ //pUndo->BeginEdit(pDocument);
+ }
}
void CFFL_TextField::OnKillFocus(CPWL_Wnd* pWnd)
@@ -341,19 +338,19 @@ void CFFL_TextField::OnKillFocus(CPWL_Wnd* pWnd)
}
-FX_BOOL CFFL_TextField::CanCopy(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_TextField::CanCopy(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_TextField::CanCut(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_TextField::CanPaste(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_TextField::CanPaste(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
void CFFL_TextField::OnAddUndo(CPWL_Edit* pEdit)
diff --git a/fpdfsdk/src/fpdf_ext.cpp b/fpdfsdk/src/fpdf_ext.cpp
index 9afe9b5ea8..0d8db417ac 100644
--- a/fpdfsdk/src/fpdf_ext.cpp
+++ b/fpdfsdk/src/fpdf_ext.cpp
@@ -13,205 +13,205 @@
class CFSDK_UnsupportInfo_Adapter
{
public:
- CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info){ m_unsp_info = unsp_info;}
-// FX_BOOL NeedToPauseNow();
- void ReportError(int nErrorType);
+ CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info){ m_unsp_info = unsp_info;}
+// FX_BOOL NeedToPauseNow();
+ void ReportError(int nErrorType);
private:
- UNSUPPORT_INFO* m_unsp_info;
+ UNSUPPORT_INFO* m_unsp_info;
};
void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType)
{
- if(m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler)
- {
- m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info,nErrorType);
- }
+ if(m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler)
+ {
+ m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info,nErrorType);
+ }
}
void FreeUnsupportInfo(void* pData)
{
- CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)pData;
- delete pAdapter;
+ CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)pData;
+ delete pAdapter;
}
FX_BOOL FPDF_UnSupportError(int nError)
{
- CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)CPDF_ModuleMgr::Get()->GetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL);
+ CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)CPDF_ModuleMgr::Get()->GetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL);
- if(!pAdapter)
- return FALSE;
- pAdapter->ReportError(nError);
- return TRUE;
+ if(!pAdapter)
+ return FALSE;
+ pAdapter->ReportError(nError);
+ return TRUE;
}
DLLEXPORT FPDF_BOOL STDCALL FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info)
{
- if (!unsp_info || unsp_info->version!=1)
- return FALSE;
- CFSDK_UnsupportInfo_Adapter * pAdapter = new CFSDK_UnsupportInfo_Adapter(unsp_info);
+ if (!unsp_info || unsp_info->version!=1)
+ return FALSE;
+ CFSDK_UnsupportInfo_Adapter * pAdapter = new CFSDK_UnsupportInfo_Adapter(unsp_info);
- CPDF_ModuleMgr::Get()->SetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL,pAdapter, &FreeUnsupportInfo);
+ CPDF_ModuleMgr::Get()->SetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL,pAdapter, &FreeUnsupportInfo);
- return TRUE;
+ return TRUE;
}
void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot)
{
- CFX_ByteString cbSubType = pPDFAnnot->GetSubType();
- if(cbSubType.Compare("3D") == 0)
- {
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT);
- }
- else if(cbSubType.Compare("Screen") ==0)
- {
- CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
- CFX_ByteString cbString;
- if(pAnnotDict->KeyExist("IT"))
- cbString = pAnnotDict->GetString("IT");
- if(cbString.Compare("Img") != 0)
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA);
- }
- else if(cbSubType.Compare("Movie") ==0)
- {
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE);
- }
- else if(cbSubType.Compare("Sound") ==0)
- {
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND);
- }
- else if(cbSubType.Compare("RichMedia") ==0)
- {
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA);
- }
- else if(cbSubType.Compare("FileAttachment") ==0)
- {
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT);
- }
- else if(cbSubType.Compare("Widget") ==0)
- {
- CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
- CFX_ByteString cbString;
- if(pAnnotDict->KeyExist("FT"))
- {
- cbString = pAnnotDict->GetString("FT");
- }
- if(cbString.Compare("Sig") == 0)
- {
- FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG);
- }
- }
+ CFX_ByteString cbSubType = pPDFAnnot->GetSubType();
+ if(cbSubType.Compare("3D") == 0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT);
+ }
+ else if(cbSubType.Compare("Screen") ==0)
+ {
+ CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
+ CFX_ByteString cbString;
+ if(pAnnotDict->KeyExist("IT"))
+ cbString = pAnnotDict->GetString("IT");
+ if(cbString.Compare("Img") != 0)
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA);
+ }
+ else if(cbSubType.Compare("Movie") ==0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE);
+ }
+ else if(cbSubType.Compare("Sound") ==0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND);
+ }
+ else if(cbSubType.Compare("RichMedia") ==0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA);
+ }
+ else if(cbSubType.Compare("FileAttachment") ==0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT);
+ }
+ else if(cbSubType.Compare("Widget") ==0)
+ {
+ CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
+ CFX_ByteString cbString;
+ if(pAnnotDict->KeyExist("FT"))
+ {
+ cbString = pAnnotDict->GetString("FT");
+ }
+ if(cbString.Compare("Sig") == 0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG);
+ }
+ }
}
FX_BOOL CheckSharedForm(CXML_Element * pElement, CFX_ByteString cbName)
{
- int count = pElement->CountAttrs();
- int i=0;
- for (i = 0; i < count; i++)
- {
- CFX_ByteString space, name;
- CFX_WideString value;
- pElement->GetAttrByIndex(i, space, name, value);
- if (space == FX_BSTRC("xmlns") && name == FX_BSTRC("adhocwf") && value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/")
- {
- CXML_Element *pVersion = pElement->GetElement("adhocwf",cbName);
- if (!pVersion)
- continue;
- CFX_WideString wsContent = pVersion->GetContent(0); // == 1.1
- int nType = wsContent.GetInteger();
- switch(nType)
- {
- case 1:
- FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT);
- break;
- case 2:
- FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM);
- break;
- case 0:
- FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMAIL);
- break;
- }
- }
- }
-
- FX_DWORD nCount = pElement->CountChildren();
- for(i=0; i<(int)nCount; i++)
- {
- CXML_Element::ChildType childType = pElement->GetChildType(i);
- if(childType == CXML_Element::Element)
- {
- CXML_Element * pChild = pElement->GetElement(i);
- if(CheckSharedForm(pChild, cbName))
- return TRUE;
- }
- }
- return FALSE;
+ int count = pElement->CountAttrs();
+ int i=0;
+ for (i = 0; i < count; i++)
+ {
+ CFX_ByteString space, name;
+ CFX_WideString value;
+ pElement->GetAttrByIndex(i, space, name, value);
+ if (space == FX_BSTRC("xmlns") && name == FX_BSTRC("adhocwf") && value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/")
+ {
+ CXML_Element *pVersion = pElement->GetElement("adhocwf",cbName);
+ if (!pVersion)
+ continue;
+ CFX_WideString wsContent = pVersion->GetContent(0); // == 1.1
+ int nType = wsContent.GetInteger();
+ switch(nType)
+ {
+ case 1:
+ FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT);
+ break;
+ case 2:
+ FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM);
+ break;
+ case 0:
+ FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMAIL);
+ break;
+ }
+ }
+ }
+
+ FX_DWORD nCount = pElement->CountChildren();
+ for(i=0; i<(int)nCount; i++)
+ {
+ CXML_Element::ChildType childType = pElement->GetChildType(i);
+ if(childType == CXML_Element::Element)
+ {
+ CXML_Element * pChild = pElement->GetElement(i);
+ if(CheckSharedForm(pChild, cbName))
+ return TRUE;
+ }
+ }
+ return FALSE;
}
void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code)
{
- // Security
- if(err_code == FPDF_ERR_SECURITY)
- {
- FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY);
- return ;
- }
- if(!pDoc)
- return ;
-
- // Portfolios and Packages
- CPDF_Dictionary * pRootDict = pDoc->GetRoot();
- if(pRootDict)
- {
- CFX_ByteString cbString;
- if(pRootDict->KeyExist("Collection"))
- {
- FPDF_UnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION);
- return ;
- }
- if(pRootDict->KeyExist("Names"))
- {
- CPDF_Dictionary* pNameDict = pRootDict->GetDict("Names");
- if (pNameDict && pNameDict->KeyExist("EmbeddedFiles"))
- {
- FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT);
- return;
- }
- else if (pNameDict && pNameDict->KeyExist("JavaScript"))
- {
- CPDF_Dictionary* pJSDict = pNameDict->GetDict("JavaScript");
- CPDF_Array * pArray = pJSDict ? pJSDict->GetArray("Names") : NULL;
- if (pArray) {
- int nCount = pArray->GetCount();
- for(int i=0; i<nCount; i++)
- {
- CFX_ByteString cbStr = pArray->GetString(i);
- if(cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0)
- {
- FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW);
- return;
- }
- }
- }
- }
- }
- }
-
- // SharedForm
- CPDF_Metadata metaData;
- metaData.LoadDoc(pDoc);
- CXML_Element * pElement = metaData.GetRoot();
- if(pElement)
- CheckSharedForm(pElement, "workflowType");
-
- // XFA Forms
- CPDF_InterForm * pInterForm = new CPDF_InterForm(pDoc,FALSE);
- if (pInterForm->HasXFAForm())
- {
- FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM);
- }
- delete pInterForm;
+ // Security
+ if(err_code == FPDF_ERR_SECURITY)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY);
+ return ;
+ }
+ if(!pDoc)
+ return ;
+
+ // Portfolios and Packages
+ CPDF_Dictionary * pRootDict = pDoc->GetRoot();
+ if(pRootDict)
+ {
+ CFX_ByteString cbString;
+ if(pRootDict->KeyExist("Collection"))
+ {
+ FPDF_UnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION);
+ return ;
+ }
+ if(pRootDict->KeyExist("Names"))
+ {
+ CPDF_Dictionary* pNameDict = pRootDict->GetDict("Names");
+ if (pNameDict && pNameDict->KeyExist("EmbeddedFiles"))
+ {
+ FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT);
+ return;
+ }
+ if (pNameDict && pNameDict->KeyExist("JavaScript"))
+ {
+ CPDF_Dictionary* pJSDict = pNameDict->GetDict("JavaScript");
+ CPDF_Array * pArray = pJSDict ? pJSDict->GetArray("Names") : NULL;
+ if (pArray) {
+ int nCount = pArray->GetCount();
+ for(int i=0; i<nCount; i++)
+ {
+ CFX_ByteString cbStr = pArray->GetString(i);
+ if(cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0)
+ {
+ FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // SharedForm
+ CPDF_Metadata metaData;
+ metaData.LoadDoc(pDoc);
+ CXML_Element * pElement = metaData.GetRoot();
+ if(pElement)
+ CheckSharedForm(pElement, "workflowType");
+
+ // XFA Forms
+ CPDF_InterForm * pInterForm = new CPDF_InterForm(pDoc,FALSE);
+ if (pInterForm->HasXFAForm())
+ {
+ FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM);
+ }
+ delete pInterForm;
}
DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document)
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index ca0c30ee1b..f75197bdbf 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -11,20 +11,20 @@ static int THISMODULE = 0;
static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark bookmark, const CFX_WideString& title)
{
- if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
- // First check this item
- return bookmark;
- }
- // go into children items
- CPDF_Bookmark child = tree.GetFirstChild(bookmark);
- while (child) {
- // check if this item
- CPDF_Bookmark found = FindBookmark(tree, child, title);
- if (found)
- return found;
- child = tree.GetNextSibling(child);
- }
- return CPDF_Bookmark();
+ if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
+ // First check this item
+ return bookmark;
+ }
+ // go into children items
+ CPDF_Bookmark child = tree.GetFirstChild(bookmark);
+ while (child) {
+ // check if this item
+ CPDF_Bookmark found = FindBookmark(tree, child, title);
+ if (found)
+ return found;
+ child = tree.GetNextSibling(child);
+ }
+ return CPDF_Bookmark();
}
DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict)
@@ -63,234 +63,233 @@ DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void*
DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title)
{
- if (!document)
- return NULL;
- if (!title || title[0] == 0)
- return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_BookmarkTree tree(pDoc);
- FX_STRSIZE len = CFX_WideString::WStringLength(title);
- CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len);
- return FindBookmark(tree, CPDF_Bookmark(), encodedTitle).GetDict();
+ if (!document)
+ return NULL;
+ if (!title || title[0] == 0)
+ return NULL;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_BookmarkTree tree(pDoc);
+ FX_STRSIZE len = CFX_WideString::WStringLength(title);
+ CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len);
+ return FindBookmark(tree, CPDF_Bookmark(), encodedTitle).GetDict();
}
DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict)
{
- if (!document)
- return NULL;
- if (!pDict)
- return NULL;
- CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_Dest dest = bookmark.GetDest(pDoc);
- if (dest)
- return dest.GetObject();
- // If this bookmark is not directly associated with a dest, we try to get action
- CPDF_Action action = bookmark.GetAction();
- if (!action)
- return NULL;
- return action.GetDest(pDoc).GetObject();
+ if (!document)
+ return NULL;
+ if (!pDict)
+ return NULL;
+ CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Dest dest = bookmark.GetDest(pDoc);
+ if (dest)
+ return dest.GetObject();
+ // If this bookmark is not directly associated with a dest, we try to get action
+ CPDF_Action action = bookmark.GetAction();
+ if (!action)
+ return NULL;
+ return action.GetDest(pDoc).GetObject();
}
DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict)
{
- if (!pDict)
- return NULL;
- CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
- return bookmark.GetAction().GetDict();
+ if (!pDict)
+ return NULL;
+ CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
+ return bookmark.GetAction().GetDict();
}
DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict)
{
- if (!pDict)
- return 0;
- CPDF_Action action((CPDF_Dictionary*)pDict);
- CPDF_Action::ActionType type = action.GetType();
- switch (type) {
- case CPDF_Action::GoTo:
- return PDFACTION_GOTO;
- case CPDF_Action::GoToR:
- return PDFACTION_REMOTEGOTO;
- case CPDF_Action::URI:
- return PDFACTION_URI;
- case CPDF_Action::Launch:
- return PDFACTION_LAUNCH;
- default:
- return PDFACTION_UNSUPPORTED;
- }
- return PDFACTION_UNSUPPORTED;
+ if (!pDict)
+ return 0;
+ CPDF_Action action((CPDF_Dictionary*)pDict);
+ CPDF_Action::ActionType type = action.GetType();
+ switch (type) {
+ case CPDF_Action::GoTo:
+ return PDFACTION_GOTO;
+ case CPDF_Action::GoToR:
+ return PDFACTION_REMOTEGOTO;
+ case CPDF_Action::URI:
+ return PDFACTION_URI;
+ case CPDF_Action::Launch:
+ return PDFACTION_LAUNCH;
+ default:
+ return PDFACTION_UNSUPPORTED;
+ }
+ return PDFACTION_UNSUPPORTED;
}
DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTION pDict)
{
- if (!document)
- return NULL;
- if (!pDict)
- return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_Action action((CPDF_Dictionary*)pDict);
- return action.GetDest(pDoc).GetObject();
+ if (!document)
+ return NULL;
+ if (!pDict)
+ return NULL;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Action action((CPDF_Dictionary*)pDict);
+ return action.GetDest(pDoc).GetObject();
}
DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION pDict,
- void* buffer, unsigned long buflen)
+ void* buffer, unsigned long buflen)
{
- if (!document)
- return 0;
- if (!pDict)
- return 0;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_Action action((CPDF_Dictionary*)pDict);
- CFX_ByteString path = action.GetURI(pDoc);
- unsigned long len = path.GetLength() + 1;
- if (buffer != NULL && buflen >= len)
- FXSYS_memcpy(buffer, path.c_str(), len);
- return len;
+ if (!document)
+ return 0;
+ if (!pDict)
+ return 0;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Action action((CPDF_Dictionary*)pDict);
+ CFX_ByteString path = action.GetURI(pDoc);
+ unsigned long len = path.GetLength() + 1;
+ if (buffer != NULL && buflen >= len)
+ FXSYS_memcpy(buffer, path.c_str(), len);
+ return len;
}
DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST pDict)
{
- if (!document)
- return 0;
- if (!pDict)
- return 0;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_Dest dest((CPDF_Array*)pDict);
- return dest.GetPageIndex(pDoc);
+ if (!document)
+ return 0;
+ if (!pDict)
+ return 0;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Dest dest((CPDF_Array*)pDict);
+ return dest.GetPageIndex(pDoc);
}
static void ReleaseLinkList(void* data)
{
- delete (CPDF_LinkList*)data;
+ delete (CPDF_LinkList*)data;
}
DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y)
{
- if (!page)
- return NULL;
- CPDF_Page* pPage = (CPDF_Page*)page;
- // Link list is stored with the document
- CPDF_Document* pDoc = pPage->m_pDocument;
- CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
- if (!pLinkList) {
- pLinkList = new CPDF_LinkList(pDoc);
- pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
- }
- return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict();
+ if (!page)
+ return NULL;
+ CPDF_Page* pPage = (CPDF_Page*)page;
+ // Link list is stored with the document
+ CPDF_Document* pDoc = pPage->m_pDocument;
+ CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
+ if (!pLinkList) {
+ pLinkList = new CPDF_LinkList(pDoc);
+ pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
+ }
+ return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict();
}
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK pDict)
{
- if (!document)
- return NULL;
- if (!pDict)
- return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_Link link((CPDF_Dictionary*)pDict);
- FPDF_DEST dest = link.GetDest(pDoc).GetObject();
- if (dest)
- return dest;
- // If this link is not directly associated with a dest, we try to get action
- CPDF_Action action = link.GetAction();
- if (!action)
- return NULL;
- return action.GetDest(pDoc).GetObject();
+ if (!document)
+ return NULL;
+ if (!pDict)
+ return NULL;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Link link((CPDF_Dictionary*)pDict);
+ FPDF_DEST dest = link.GetDest(pDoc).GetObject();
+ if (dest)
+ return dest;
+ // If this link is not directly associated with a dest, we try to get action
+ CPDF_Action action = link.GetAction();
+ if (!action)
+ return NULL;
+ return action.GetDest(pDoc).GetObject();
}
DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict)
{
- if (!pDict)
- return NULL;
- CPDF_Link link((CPDF_Dictionary*)pDict);
- return link.GetAction().GetDict();
+ if (!pDict)
+ return NULL;
+ CPDF_Link link((CPDF_Dictionary*)pDict);
+ return link.GetAction().GetDict();
}
DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FPDF_LINK* linkAnnot)
{
- if(!page || !startPos || !linkAnnot)
- return FALSE;
- CPDF_Page* pPage = (CPDF_Page*)page;
- if(!pPage->m_pFormDict)
- return FALSE;
- CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
- if(!pAnnots)
- return FALSE;
- for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) {
- CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i);
- if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY)
- continue;
- if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) {
- *startPos = i + 1;
- *linkAnnot = (FPDF_LINK)pDict;
- return TRUE;
- }
- }
- return FALSE;
+ if(!page || !startPos || !linkAnnot)
+ return FALSE;
+ CPDF_Page* pPage = (CPDF_Page*)page;
+ if(!pPage->m_pFormDict)
+ return FALSE;
+ CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
+ if(!pAnnots)
+ return FALSE;
+ for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) {
+ CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i);
+ if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY)
+ continue;
+ if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) {
+ *startPos = i + 1;
+ *linkAnnot = (FPDF_LINK)pDict;
+ return TRUE;
+ }
+ }
+ return FALSE;
}
DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF* rect)
{
- if(!linkAnnot || !rect)
- return FALSE;
- CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
- CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect"));
- rect->left = rt.left;
- rect->bottom = rt.bottom;
- rect->right = rt.right;
- rect->top = rt.top;
- return TRUE;
+ if(!linkAnnot || !rect)
+ return FALSE;
+ CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
+ CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect"));
+ rect->left = rt.left;
+ rect->bottom = rt.bottom;
+ rect->right = rt.right;
+ rect->top = rt.top;
+ return TRUE;
}
DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot)
{
- if(!linkAnnot)
- return 0;
- CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
- CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
- if (!pArray)
- return 0;
- else
- return pArray->GetCount() / 8;
+ if(!linkAnnot)
+ return 0;
+ CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
+ CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
+ if (!pArray)
+ return 0;
+ return pArray->GetCount() / 8;
}
DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quadIndex, FS_QUADPOINTSF* quadPoints)
{
- if(!linkAnnot || !quadPoints)
- return FALSE;
- CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
- CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
- if (pArray) {
- if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || ((quadIndex*8+7) >= (int)pArray->GetCount()))
- return FALSE;
- quadPoints->x1 = pArray->GetNumber(quadIndex*8);
- quadPoints->y1 = pArray->GetNumber(quadIndex*8+1);
- quadPoints->x2 = pArray->GetNumber(quadIndex*8+2);
- quadPoints->y2 = pArray->GetNumber(quadIndex*8+3);
- quadPoints->x3 = pArray->GetNumber(quadIndex*8+4);
- quadPoints->y3 = pArray->GetNumber(quadIndex*8+5);
- quadPoints->x4 = pArray->GetNumber(quadIndex*8+6);
- quadPoints->y4 = pArray->GetNumber(quadIndex*8+7);
- return TRUE;
- }
- return FALSE;
+ if(!linkAnnot || !quadPoints)
+ return FALSE;
+ CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
+ CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
+ if (pArray) {
+ if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || ((quadIndex*8+7) >= (int)pArray->GetCount()))
+ return FALSE;
+ quadPoints->x1 = pArray->GetNumber(quadIndex*8);
+ quadPoints->y1 = pArray->GetNumber(quadIndex*8+1);
+ quadPoints->x2 = pArray->GetNumber(quadIndex*8+2);
+ quadPoints->y2 = pArray->GetNumber(quadIndex*8+3);
+ quadPoints->x3 = pArray->GetNumber(quadIndex*8+4);
+ quadPoints->y3 = pArray->GetNumber(quadIndex*8+5);
+ quadPoints->x4 = pArray->GetNumber(quadIndex*8+6);
+ quadPoints->y4 = pArray->GetNumber(quadIndex*8+7);
+ return TRUE;
+ }
+ return FALSE;
}
DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTRING tag,
- void* buffer, unsigned long buflen)
+ void* buffer, unsigned long buflen)
{
- if (!doc || !tag)
- return 0;
- CPDF_Document* pDoc = (CPDF_Document*)doc;
- // Get info dictionary
- CPDF_Dictionary* pInfo = pDoc->GetInfo();
- if (!pInfo)
- return 0;
- CFX_WideString text = pInfo->GetUnicodeText(tag);
- // Use UTF-16LE encoding
- CFX_ByteString encodedText = text.UTF16LE_Encode();
- unsigned long len = encodedText.GetLength();
- if (buffer && buflen >= len) {
- FXSYS_memcpy(buffer, encodedText.c_str(), len);
- }
- return len;
+ if (!doc || !tag)
+ return 0;
+ CPDF_Document* pDoc = (CPDF_Document*)doc;
+ // Get info dictionary
+ CPDF_Dictionary* pInfo = pDoc->GetInfo();
+ if (!pInfo)
+ return 0;
+ CFX_WideString text = pInfo->GetUnicodeText(tag);
+ // Use UTF-16LE encoding
+ CFX_ByteString encodedText = text.UTF16LE_Encode();
+ unsigned long len = encodedText.GetLength();
+ if (buffer && buflen >= len) {
+ FXSYS_memcpy(buffer, encodedText.c_str(), len);
+ }
+ return len;
}
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index 2e92d4a153..40d56b304d 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -185,9 +185,9 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
CPDF_Dictionary* pDict,
CFX_ByteString nSrctag)
{
- if (!pDict || !pDict->KeyExist("Type") || nSrctag.IsEmpty())
+ if (!pDict || nSrctag.IsEmpty())
return nullptr;
- if (!pDict->KeyExist("Parent"))
+ if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type"))
return nullptr;
CPDF_Object* pType = pDict->GetElement("Type")->GetDirect();
@@ -200,19 +200,19 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (!pParent || pParent->GetType() != PDFOBJ_DICTIONARY)
return nullptr;
- CPDF_Dictionary* pp = (CPDF_Dictionary*)pParent;
-
if (pDict->KeyExist((const char*)nSrctag))
return pDict->GetElement((const char*)nSrctag);
+ CPDF_Dictionary* pp = (CPDF_Dictionary*)pParent;
while (pp) {
if (pp->KeyExist((const char*)nSrctag)) {
return pp->GetElement((const char*)nSrctag);
- } else if (pp->KeyExist("Parent")) {
- pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect();
- if (pp->GetType() == PDFOBJ_NULL)
- break;
- } else {
+ }
+ if (!pp->KeyExist("Parent")) {
+ break;
+ }
+ pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect();
+ if (pp->GetType() == PDFOBJ_NULL) {
break;
}
}
@@ -259,12 +259,10 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
FX_DWORD count = pArray->GetCount();
for (FX_DWORD i = 0; i < count; ++i) {
CPDF_Object* pNextObj = pArray->GetElement(i);
- if (pNextObj) {
- if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
- return FALSE;
- } else {
+ if (!pNextObj)
+ return FALSE;
+ if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
return FALSE;
- }
}
break;
}
@@ -316,7 +314,8 @@ FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
if (!FXSYS_stricmp(strType, "Pages")) {
pDictClone->Release();
return 4;
- } else if (!FXSYS_stricmp(strType, "Page")) {
+ }
+ if (!FXSYS_stricmp(strType, "Page")) {
pDictClone->Release();
return 0;
}
@@ -373,10 +372,9 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring,
nStartPageNum >nEndPageNum ||
nEndPageNum > nCount) {
return FALSE;
- } else {
- for (int i = nStartPageNum; i <= nEndPageNum; ++i) {
- pageArray->Add(i);
- }
+ }
+ for (int i = nStartPageNum; i <= nEndPageNum; ++i) {
+ pageArray->Add(i);
}
}
nStringFrom = nStringTo + 1;
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 4b9d7acecf..ddd6f6e90e 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -18,80 +18,76 @@ class CFX_IFileWrite final : public IFX_StreamWrite
{
public:
- CFX_IFileWrite();
- FX_BOOL Init( FPDF_FILEWRITE * pFileWriteStruct );
- virtual FX_BOOL WriteBlock(const void* pData, size_t size) override;
- virtual void Release() override {}
+ CFX_IFileWrite();
+ FX_BOOL Init( FPDF_FILEWRITE * pFileWriteStruct );
+ virtual FX_BOOL WriteBlock(const void* pData, size_t size) override;
+ virtual void Release() override {}
protected:
- FPDF_FILEWRITE* m_pFileWriteStruct;
+ FPDF_FILEWRITE* m_pFileWriteStruct;
};
CFX_IFileWrite::CFX_IFileWrite()
{
- m_pFileWriteStruct = NULL;
+ m_pFileWriteStruct = NULL;
}
FX_BOOL CFX_IFileWrite::Init( FPDF_FILEWRITE * pFileWriteStruct )
{
- if (!pFileWriteStruct)
- return FALSE;
- else
- {
- m_pFileWriteStruct = pFileWriteStruct;
- }
- return TRUE;
+ if (!pFileWriteStruct)
+ return FALSE;
+
+ m_pFileWriteStruct = pFileWriteStruct;
+ return TRUE;
}
FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size)
{
- if (m_pFileWriteStruct)
- {
- m_pFileWriteStruct->WriteBlock( m_pFileWriteStruct, pData, size );
- return TRUE;
- }
- else
- return FALSE;
+ if (!m_pFileWriteStruct)
+ return FALSE;
+
+ m_pFileWriteStruct->WriteBlock( m_pFileWriteStruct, pData, size );
+ return TRUE;
}
FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,FPDF_DWORD flags, FPDF_BOOL bSetVersion,
- int fileVerion)
+ int fileVerion)
{
- CPDF_Document* pDoc = (CPDF_Document*)document;
- if (!pDoc)
- return 0;
-
- if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY )
- {
- flags = 0;
- }
-
- CPDF_Creator FileMaker(pDoc);
- if(bSetVersion)
- FileMaker.SetFileVersion(fileVerion);
- if(flags == FPDF_REMOVE_SECURITY)
- {
- flags = 0;
- FileMaker.RemoveSecurity();
- }
- CFX_IFileWrite* pStreamWrite = NULL;
- FX_BOOL bRet;
- pStreamWrite = new CFX_IFileWrite;
- pStreamWrite->Init( pFileWrite );
- bRet = FileMaker.Create(pStreamWrite, flags);
- delete pStreamWrite;
- return bRet;
+ CPDF_Document* pDoc = (CPDF_Document*)document;
+ if (!pDoc)
+ return 0;
+
+ if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY )
+ {
+ flags = 0;
+ }
+
+ CPDF_Creator FileMaker(pDoc);
+ if(bSetVersion)
+ FileMaker.SetFileVersion(fileVerion);
+ if(flags == FPDF_REMOVE_SECURITY)
+ {
+ flags = 0;
+ FileMaker.RemoveSecurity();
+ }
+ CFX_IFileWrite* pStreamWrite = NULL;
+ FX_BOOL bRet;
+ pStreamWrite = new CFX_IFileWrite;
+ pStreamWrite->Init( pFileWrite );
+ bRet = FileMaker.Create(pStreamWrite, flags);
+ delete pStreamWrite;
+ return bRet;
}
-DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,
- FPDF_DWORD flags )
+DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,
+ FPDF_DWORD flags )
{
- return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE , 0);
+ return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE , 0);
}
-DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion( FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,
- FPDF_DWORD flags, int fileVersion)
+DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion( FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,
+ FPDF_DWORD flags, int fileVersion)
{
- return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE , fileVersion);
+ return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE , fileVersion);
}
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index de7f7d9716..9b008cd762 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -288,35 +288,18 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot,
if (pAnnotHandler->OnSetFocus(pAnnot, nFlag))
{
CPDFSDK_PageView* pPage = pAnnot->GetPageView();
- ASSERT(pPage != NULL);
-
pPage->GetSDKDocument();
- // pDocument->SetTopmostAnnot(pAnnot);
-
return TRUE;
}
- else
- {
- return FALSE;
- }
}
-
return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
-
+ ASSERT(pAnnot);
if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- if (pAnnotHandler->OnKillFocus(pAnnot, nFlag))
- {
- return TRUE;
- }
- else
- return FALSE;
- }
+ return pAnnotHandler->OnKillFocus(pAnnot, nFlag);
return FALSE;
}
@@ -325,9 +308,8 @@ CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage
{
ASSERT(pAnnot);
if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
return pAnnotHandler->GetViewBBox(pPageView, pAnnot);
- }
+
return pAnnot->GetRect();
}
@@ -336,7 +318,7 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP
ASSERT(pAnnot);
if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
{
- if(pAnnotHandler->CanAnswer(pAnnot))
+ if (pAnnotHandler->CanAnswer(pAnnot))
return pAnnotHandler->HitTest(pPageView, pAnnot, point);
}
return FALSE;
@@ -350,38 +332,26 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F
FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot);
ASSERT(pAnnot->GetType() == "Widget");
- CFX_ByteString sSubType = pAnnot->GetSubType();
-
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (!pWidget->IsVisible()) return FALSE;
+ if (pAnnot->GetSubType() == BFFT_SIGNATURE)
+ return FALSE;
- int nFieldFlags = pWidget->GetFieldFlags();
- if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FALSE;
- if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return TRUE;
- else
- {
- CPDF_Page* pPage = pWidget->GetPDFPage();
- ASSERT(pPage != NULL);
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (!pWidget->IsVisible())
+ return FALSE;
- CPDF_Document* pDocument = pPage->m_pDocument;
- ASSERT(pDocument != NULL);
+ int nFieldFlags = pWidget->GetFieldFlags();
+ if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
+ return FALSE;
- FX_DWORD dwPermissions = pDocument->GetUserPermissions();
- return (dwPermissions&FPDFPERM_FILL_FORM) ||
- (dwPermissions&FPDFPERM_ANNOT_FORM) ||
- (dwPermissions&FPDFPERM_ANNOT_FORM);
- }
- }
+ if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+ return TRUE;
- return FALSE;
+ CPDF_Page* pPage = pWidget->GetPDFPage();
+ CPDF_Document* pDocument = pPage->m_pDocument;
+ FX_DWORD dwPermissions = pDocument->GetUserPermissions();
+ return (dwPermissions & FPDFPERM_FILL_FORM) ||
+ (dwPermissions & FPDFPERM_ANNOT_FORM);
}
CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage)
@@ -873,12 +843,11 @@ void CPDFSDK_AnnotIterator::InsertSort(CFX_PtrArray &arrayList, AI_COMPARE pComp
int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
{
- if(p1->GetLayoutOrder() < p2->GetLayoutOrder())
+ if (p1->GetLayoutOrder() < p2->GetLayoutOrder())
return -1;
- else if (p1->GetLayoutOrder() == p2->GetLayoutOrder())
- return 0;
- else
+ if (p1->GetLayoutOrder() > p2->GetLayoutOrder())
return 1;
+ return 0;
}
FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView,CFX_PtrArray * pAnnotList)
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index e35e537765..d0dc4ef738 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -10,498 +10,498 @@
//---------------------------------------------------------------------------
-// CPDFSDK_DateTime
+// CPDFSDK_DateTime
//---------------------------------------------------------------------------
int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute)
{
- return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
+ return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
}
FX_BOOL _gAfxIsLeapYear(int16_t year)
{
- return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
+ return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
}
FX_WORD _gAfxGetYearDays(int16_t year)
{
- return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365);
+ return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365);
}
uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month)
{
- uint8_t mDays;
- switch (month)
- {
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- mDays = 31;
- break;
-
- case 4:
- case 6:
- case 9:
- case 11:
- mDays = 30;
- break;
-
- case 2:
- if (_gAfxIsLeapYear(year) == TRUE)
- mDays = 29;
- else
- mDays = 28;
- break;
-
- default:
- mDays = 0;
- break;
- }
-
- return mDays;
+ uint8_t mDays;
+ switch (month)
+ {
+ case 1:
+ case 3:
+ case 5:
+ case 7:
+ case 8:
+ case 10:
+ case 12:
+ mDays = 31;
+ break;
+
+ case 4:
+ case 6:
+ case 9:
+ case 11:
+ mDays = 30;
+ break;
+
+ case 2:
+ if (_gAfxIsLeapYear(year) == TRUE)
+ mDays = 29;
+ else
+ mDays = 28;
+ break;
+
+ default:
+ mDays = 0;
+ break;
+ }
+
+ return mDays;
}
CPDFSDK_DateTime::CPDFSDK_DateTime()
{
- ResetDateTime();
+ ResetDateTime();
}
CPDFSDK_DateTime::CPDFSDK_DateTime(const CFX_ByteString& dtStr)
{
- ResetDateTime();
+ ResetDateTime();
- FromPDFDateTimeString(dtStr);
+ FromPDFDateTimeString(dtStr);
}
CPDFSDK_DateTime::CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime)
{
- operator = (datetime);
+ operator = (datetime);
}
CPDFSDK_DateTime::CPDFSDK_DateTime(const FX_SYSTEMTIME& st)
{
- operator = (st) ;
+ operator = (st) ;
}
void CPDFSDK_DateTime::ResetDateTime()
{
- tzset();
+ tzset();
- time_t curTime;
- time(&curTime);
- struct tm* newtime;
- //newtime = gmtime(&curTime);
- newtime = localtime(&curTime);
+ time_t curTime;
+ time(&curTime);
+ struct tm* newtime;
+ //newtime = gmtime(&curTime);
+ newtime = localtime(&curTime);
- dt.year = newtime->tm_year + 1900;
- dt.month = newtime->tm_mon + 1;
- dt.day = newtime->tm_mday;
- dt.hour = newtime->tm_hour;
- dt.minute = newtime->tm_min;
- dt.second = newtime->tm_sec;
-// dt.tzHour = _timezone / 3600 * -1;
-// dt.tzMinute = (abs(_timezone) % 3600) / 60;
+ dt.year = newtime->tm_year + 1900;
+ dt.month = newtime->tm_mon + 1;
+ dt.day = newtime->tm_mday;
+ dt.hour = newtime->tm_hour;
+ dt.minute = newtime->tm_min;
+ dt.second = newtime->tm_sec;
+// dt.tzHour = _timezone / 3600 * -1;
+// dt.tzMinute = (abs(_timezone) % 3600) / 60;
}
CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const CPDFSDK_DateTime& datetime)
{
- FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME));
- return *this;
+ FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME));
+ return *this;
}
CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const FX_SYSTEMTIME& st)
{
- tzset();
+ tzset();
- dt.year = (int16_t)st.wYear;
- dt.month = (uint8_t)st.wMonth;
- dt.day = (uint8_t)st.wDay;
- dt.hour = (uint8_t)st.wHour;
- dt.minute = (uint8_t)st.wMinute;
- dt.second = (uint8_t)st.wSecond;
-// dt.tzHour = _timezone / 3600 * -1;
-// dt.tzMinute = (abs(_timezone) % 3600) / 60;
- return *this;
+ dt.year = (int16_t)st.wYear;
+ dt.month = (uint8_t)st.wMonth;
+ dt.day = (uint8_t)st.wDay;
+ dt.hour = (uint8_t)st.wHour;
+ dt.minute = (uint8_t)st.wMinute;
+ dt.second = (uint8_t)st.wSecond;
+// dt.tzHour = _timezone / 3600 * -1;
+// dt.tzMinute = (abs(_timezone) % 3600) / 60;
+ return *this;
}
FX_BOOL CPDFSDK_DateTime::operator == (CPDFSDK_DateTime& datetime)
{
- return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0);
+ return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0);
}
FX_BOOL CPDFSDK_DateTime::operator != (CPDFSDK_DateTime& datetime)
{
- return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0);
+ return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0);
}
FX_BOOL CPDFSDK_DateTime::operator > (CPDFSDK_DateTime& datetime)
{
- CPDFSDK_DateTime dt1 = ToGMT();
- CPDFSDK_DateTime dt2 = datetime.ToGMT();
- int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
- int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
- int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
- int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
+ CPDFSDK_DateTime dt1 = ToGMT();
+ CPDFSDK_DateTime dt2 = datetime.ToGMT();
+ int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
+ int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
+ int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
+ int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
- if (d1 > d3) return TRUE;
- if (d2 > d4) return TRUE;
- return FALSE;
+ if (d1 > d3) return TRUE;
+ if (d2 > d4) return TRUE;
+ return FALSE;
}
FX_BOOL CPDFSDK_DateTime::operator >= (CPDFSDK_DateTime& datetime)
{
- CPDFSDK_DateTime dt1 = ToGMT();
- CPDFSDK_DateTime dt2 = datetime.ToGMT();
- int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
- int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
- int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
- int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
+ CPDFSDK_DateTime dt1 = ToGMT();
+ CPDFSDK_DateTime dt2 = datetime.ToGMT();
+ int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
+ int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
+ int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
+ int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
- if (d1 >= d3) return TRUE;
- if (d2 >= d4) return TRUE;
- return FALSE;
+ if (d1 >= d3) return TRUE;
+ if (d2 >= d4) return TRUE;
+ return FALSE;
}
FX_BOOL CPDFSDK_DateTime::operator < (CPDFSDK_DateTime& datetime)
{
- CPDFSDK_DateTime dt1 = ToGMT();
- CPDFSDK_DateTime dt2 = datetime.ToGMT();
- int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
- int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
- int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
- int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
+ CPDFSDK_DateTime dt1 = ToGMT();
+ CPDFSDK_DateTime dt2 = datetime.ToGMT();
+ int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
+ int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
+ int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
+ int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
- if (d1 < d3) return TRUE;
- if (d2 < d4) return TRUE;
- return FALSE;
+ if (d1 < d3) return TRUE;
+ if (d2 < d4) return TRUE;
+ return FALSE;
}
FX_BOOL CPDFSDK_DateTime::operator <= (CPDFSDK_DateTime& datetime)
{
- CPDFSDK_DateTime dt1 = ToGMT();
- CPDFSDK_DateTime dt2 = datetime.ToGMT();
- int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
- int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
- int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
- int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
+ CPDFSDK_DateTime dt1 = ToGMT();
+ CPDFSDK_DateTime dt2 = datetime.ToGMT();
+ int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day;
+ int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1.dt.second;
+ int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day;
+ int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2.dt.second;
- if (d1 <= d3) return TRUE;
- if (d2 <= d4) return TRUE;
- return FALSE;
+ if (d1 <= d3) return TRUE;
+ if (d2 <= d4) return TRUE;
+ return FALSE;
}
CPDFSDK_DateTime::operator time_t()
{
- struct tm newtime;
+ struct tm newtime;
- newtime.tm_year = dt.year - 1900;
- newtime.tm_mon = dt.month - 1;
- newtime.tm_mday = dt.day;
- newtime.tm_hour = dt.hour;
- newtime.tm_min = dt.minute;
- newtime.tm_sec = dt.second;
+ newtime.tm_year = dt.year - 1900;
+ newtime.tm_mon = dt.month - 1;
+ newtime.tm_mday = dt.day;
+ newtime.tm_hour = dt.hour;
+ newtime.tm_min = dt.minute;
+ newtime.tm_sec = dt.second;
- return mktime(&newtime);
+ return mktime(&newtime);
}
CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(const CFX_ByteString& dtStr)
{
- int strLength = dtStr.GetLength();
- if (strLength > 0)
- {
- int i = 0;
- int j, k;
- FX_CHAR ch;
- while (i < strLength)
- {
- ch = dtStr[i];
- if (ch >= '0' && ch <= '9') break;
- i ++;
- }
- if (i >= strLength) return *this;
-
- j = 0;
- k = 0;
- while (i < strLength && j < 4)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.year = (int16_t)k;
- if (i >= strLength || j < 4) return *this;
-
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.month = (uint8_t)k;
- if (i >= strLength || j < 2) return *this;
-
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.day = (uint8_t)k;
- if (i >= strLength || j < 2) return *this;
-
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.hour = (uint8_t)k;
- if (i >= strLength || j < 2) return *this;
-
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.minute = (uint8_t)k;
- if (i >= strLength || j < 2) return *this;
-
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.second = (uint8_t)k;
- if (i >= strLength || j < 2) return *this;
-
- ch = dtStr[i ++];
- if (ch != '-' && ch != '+') return *this;
- if (ch == '-')
- dt.tzHour = -1;
- else
- dt.tzHour = 1;
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.tzHour *= (FX_CHAR)k;
- if (i >= strLength || j < 2) return *this;
-
- ch = dtStr[i ++];
- if (ch != '\'') return *this;
- j = 0;
- k = 0;
- while (i < strLength && j < 2)
- {
- ch = dtStr[i];
- k = k * 10 + ch - '0';
- j ++;
- if (ch < '0' || ch > '9') break;
- i ++;
- }
- dt.tzMinute = (uint8_t)k;
- if (i >= strLength || j < 2) return *this;
- }
-
- return *this;
+ int strLength = dtStr.GetLength();
+ if (strLength > 0)
+ {
+ int i = 0;
+ int j, k;
+ FX_CHAR ch;
+ while (i < strLength)
+ {
+ ch = dtStr[i];
+ if (ch >= '0' && ch <= '9') break;
+ i ++;
+ }
+ if (i >= strLength) return *this;
+
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 4)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.year = (int16_t)k;
+ if (i >= strLength || j < 4) return *this;
+
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.month = (uint8_t)k;
+ if (i >= strLength || j < 2) return *this;
+
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.day = (uint8_t)k;
+ if (i >= strLength || j < 2) return *this;
+
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.hour = (uint8_t)k;
+ if (i >= strLength || j < 2) return *this;
+
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.minute = (uint8_t)k;
+ if (i >= strLength || j < 2) return *this;
+
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.second = (uint8_t)k;
+ if (i >= strLength || j < 2) return *this;
+
+ ch = dtStr[i ++];
+ if (ch != '-' && ch != '+') return *this;
+ if (ch == '-')
+ dt.tzHour = -1;
+ else
+ dt.tzHour = 1;
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.tzHour *= (FX_CHAR)k;
+ if (i >= strLength || j < 2) return *this;
+
+ ch = dtStr[i ++];
+ if (ch != '\'') return *this;
+ j = 0;
+ k = 0;
+ while (i < strLength && j < 2)
+ {
+ ch = dtStr[i];
+ k = k * 10 + ch - '0';
+ j ++;
+ if (ch < '0' || ch > '9') break;
+ i ++;
+ }
+ dt.tzMinute = (uint8_t)k;
+ if (i >= strLength || j < 2) return *this;
+ }
+
+ return *this;
}
CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString()
{
- CFX_ByteString str1;
- str1.Format("%04d-%02d-%02d %02d:%02d:%02d ", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
- if (dt.tzHour < 0)
- str1 += "-";
- else
- str1 += "+";
- CFX_ByteString str2;
- str2.Format("%02d:%02d", abs(dt.tzHour), dt.tzMinute);
- return str1 + str2;
+ CFX_ByteString str1;
+ str1.Format("%04d-%02d-%02d %02d:%02d:%02d ", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
+ if (dt.tzHour < 0)
+ str1 += "-";
+ else
+ str1 += "+";
+ CFX_ByteString str2;
+ str2.Format("%02d:%02d", abs(dt.tzHour), dt.tzMinute);
+ return str1 + str2;
}
CFX_ByteString CPDFSDK_DateTime::ToPDFDateTimeString()
{
- CFX_ByteString dtStr;
- char tempStr[32];
- memset(tempStr, 0, sizeof(tempStr));
- FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "D:%04d%02d%02d%02d%02d%02d",
+ CFX_ByteString dtStr;
+ char tempStr[32];
+ memset(tempStr, 0, sizeof(tempStr));
+ FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "D:%04d%02d%02d%02d%02d%02d",
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
- dtStr = CFX_ByteString(tempStr);
- if (dt.tzHour < 0)
- dtStr += CFX_ByteString("-");
- else
- dtStr += CFX_ByteString("+");
- memset(tempStr, 0, sizeof(tempStr));
- FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02d'", abs(dt.tzHour), dt.tzMinute);
- dtStr += CFX_ByteString(tempStr);
- return dtStr;
+ dtStr = CFX_ByteString(tempStr);
+ if (dt.tzHour < 0)
+ dtStr += CFX_ByteString("-");
+ else
+ dtStr += CFX_ByteString("+");
+ memset(tempStr, 0, sizeof(tempStr));
+ FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02d'", abs(dt.tzHour), dt.tzMinute);
+ dtStr += CFX_ByteString(tempStr);
+ return dtStr;
}
void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st)
{
- CPDFSDK_DateTime dt = *this;
- time_t t = (time_t)dt;
- struct tm* pTime = localtime(&t);
- if(pTime){
- st.wYear = (FX_WORD)pTime->tm_year + 1900;
- st.wMonth = (FX_WORD)pTime->tm_mon + 1;
- st.wDay = (FX_WORD)pTime->tm_mday;
- st.wDayOfWeek = (FX_WORD)pTime->tm_wday;
- st.wHour = (FX_WORD)pTime->tm_hour;
- st.wMinute = (FX_WORD)pTime->tm_min;
- st.wSecond = (FX_WORD)pTime->tm_sec;
- st.wMilliseconds = 0;
- }
+ CPDFSDK_DateTime dt = *this;
+ time_t t = (time_t)dt;
+ struct tm* pTime = localtime(&t);
+ if(pTime){
+ st.wYear = (FX_WORD)pTime->tm_year + 1900;
+ st.wMonth = (FX_WORD)pTime->tm_mon + 1;
+ st.wDay = (FX_WORD)pTime->tm_mday;
+ st.wDayOfWeek = (FX_WORD)pTime->tm_wday;
+ st.wHour = (FX_WORD)pTime->tm_hour;
+ st.wMinute = (FX_WORD)pTime->tm_min;
+ st.wSecond = (FX_WORD)pTime->tm_sec;
+ st.wMilliseconds = 0;
+ }
}
CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT()
{
- CPDFSDK_DateTime dt = *this;
- dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute));
- dt.dt.tzHour = 0;
- dt.dt.tzMinute = 0;
- return dt;
+ CPDFSDK_DateTime dt = *this;
+ dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute));
+ dt.dt.tzHour = 0;
+ dt.dt.tzMinute = 0;
+ return dt;
}
CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days)
{
- if (days == 0) return *this;
-
- int16_t y = dt.year, yy;
- uint8_t m = dt.month;
- uint8_t d = dt.day;
- int mdays, ydays, ldays;
-
- ldays = days;
- if (ldays > 0)
- {
- yy = y;
- if (((FX_WORD)m * 100 + d) > 300) yy ++;
- ydays = _gAfxGetYearDays(yy);
- while (ldays >= ydays)
- {
- y ++;
- ldays -= ydays;
- yy ++;
- mdays = _gAfxGetMonthDays(y, m);
- if (d > mdays)
- {
- m ++;
- d -= mdays;
- }
- ydays = _gAfxGetYearDays(yy);
- }
- mdays = _gAfxGetMonthDays(y, m) - d + 1;
- while (ldays >= mdays)
- {
- ldays -= mdays;
- m ++;
- d = 1;
- mdays = _gAfxGetMonthDays(y, m);
- }
- d += ldays;
- }
- else
- {
- ldays *= -1;
- yy = y;
- if (((FX_WORD)m * 100 + d) < 300) yy --;
- ydays = _gAfxGetYearDays(yy);
- while (ldays >= ydays)
- {
- y --;
- ldays -= ydays;
- yy --;
- mdays = _gAfxGetMonthDays(y, m);
- if (d > mdays)
- {
- m ++;
- d -= mdays;
- }
- ydays = _gAfxGetYearDays(yy);
- }
- while (ldays >= d)
- {
- ldays -= d;
- m --;
- mdays = _gAfxGetMonthDays(y, m);
- d = mdays;
- }
- d -= ldays;
- }
-
- dt.year = y;
- dt.month = m;
- dt.day = d;
-
- return *this;
+ if (days == 0) return *this;
+
+ int16_t y = dt.year, yy;
+ uint8_t m = dt.month;
+ uint8_t d = dt.day;
+ int mdays, ydays, ldays;
+
+ ldays = days;
+ if (ldays > 0)
+ {
+ yy = y;
+ if (((FX_WORD)m * 100 + d) > 300) yy ++;
+ ydays = _gAfxGetYearDays(yy);
+ while (ldays >= ydays)
+ {
+ y ++;
+ ldays -= ydays;
+ yy ++;
+ mdays = _gAfxGetMonthDays(y, m);
+ if (d > mdays)
+ {
+ m ++;
+ d -= mdays;
+ }
+ ydays = _gAfxGetYearDays(yy);
+ }
+ mdays = _gAfxGetMonthDays(y, m) - d + 1;
+ while (ldays >= mdays)
+ {
+ ldays -= mdays;
+ m ++;
+ d = 1;
+ mdays = _gAfxGetMonthDays(y, m);
+ }
+ d += ldays;
+ }
+ else
+ {
+ ldays *= -1;
+ yy = y;
+ if (((FX_WORD)m * 100 + d) < 300) yy --;
+ ydays = _gAfxGetYearDays(yy);
+ while (ldays >= ydays)
+ {
+ y --;
+ ldays -= ydays;
+ yy --;
+ mdays = _gAfxGetMonthDays(y, m);
+ if (d > mdays)
+ {
+ m ++;
+ d -= mdays;
+ }
+ ydays = _gAfxGetYearDays(yy);
+ }
+ while (ldays >= d)
+ {
+ ldays -= d;
+ m --;
+ mdays = _gAfxGetMonthDays(y, m);
+ d = mdays;
+ }
+ d -= ldays;
+ }
+
+ dt.year = y;
+ dt.month = m;
+ dt.day = d;
+
+ return *this;
}
CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds)
{
- if (seconds == 0) return *this;
+ if (seconds == 0) return *this;
- int n;
- int days;
+ int n;
+ int days;
- n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds;
- if (n < 0)
- {
- days = (n - 86399) / 86400;
- n -= days * 86400;
- }
- else
- {
- days = n / 86400;
- n %= 86400;
- }
- dt.hour = (uint8_t)(n / 3600);
- dt.hour %= 24;
- n %= 3600;
- dt.minute = (uint8_t)(n / 60);
- dt.second = (uint8_t)(n % 60);
- if (days != 0) AddDays(days);
+ n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds;
+ if (n < 0)
+ {
+ days = (n - 86399) / 86400;
+ n -= days * 86400;
+ }
+ else
+ {
+ days = n / 86400;
+ n %= 86400;
+ }
+ dt.hour = (uint8_t)(n / 3600);
+ dt.hour %= 24;
+ n %= 3600;
+ dt.minute = (uint8_t)(n / 60);
+ dt.second = (uint8_t)(n % 60);
+ if (days != 0) AddDays(days);
- return *this;
+ return *this;
}
//---------------------------------------------------------------------------
-// CPDFSDK_Annot
+// CPDFSDK_Annot
//---------------------------------------------------------------------------
CPDFSDK_Annot::CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) :
m_pAnnot(pAnnot),
@@ -513,572 +513,563 @@ m_nTabOrder(-1)
CPDFSDK_Annot::~CPDFSDK_Annot()
{
- m_pAnnot = NULL;
- m_pPageView = NULL;
+ m_pAnnot = NULL;
+ m_pPageView = NULL;
}
-CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot()
+CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot()
{
- return m_pAnnot;
+ return m_pAnnot;
}
FX_DWORD CPDFSDK_Annot::GetFlags()
{
- ASSERT(m_pAnnot != NULL);
+ ASSERT(m_pAnnot != NULL);
- return m_pAnnot->GetFlags();
+ return m_pAnnot->GetFlags();
}
void CPDFSDK_Annot::SetPage(CPDFSDK_PageView* pPageView)
{
- m_pPageView = pPageView;
+ m_pPageView = pPageView;
}
CPDFSDK_PageView* CPDFSDK_Annot::GetPageView()
{
- return m_pPageView;
+ return m_pPageView;
}
FX_BOOL CPDFSDK_Annot::IsSelected()
{
- return m_bSelected;
+ return m_bSelected;
}
void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected)
{
- m_bSelected = bSelected;
+ m_bSelected = bSelected;
}
// Tab Order
int CPDFSDK_Annot::GetTabOrder()
{
- return m_nTabOrder;
+ return m_nTabOrder;
}
void CPDFSDK_Annot::SetTabOrder(int iTabOrder)
{
- m_nTabOrder = iTabOrder;
+ m_nTabOrder = iTabOrder;
}
CPDF_Dictionary* CPDFSDK_Annot::GetAnnotDict() const
{
- ASSERT(m_pAnnot != NULL);
+ ASSERT(m_pAnnot != NULL);
- return m_pAnnot->GetAnnotDict();
+ return m_pAnnot->GetAnnotDict();
}
void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect)
{
- ASSERT(rect.right - rect.left >= GetMinWidth());
- ASSERT(rect.top - rect.bottom >= GetMinHeight());
+ ASSERT(rect.right - rect.left >= GetMinWidth());
+ ASSERT(rect.top - rect.bottom >= GetMinHeight());
- m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect);
+ m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect);
}
CPDF_Rect CPDFSDK_Annot::GetRect() const
{
- ASSERT(m_pAnnot != NULL);
+ ASSERT(m_pAnnot != NULL);
- CPDF_Rect rect;
- m_pAnnot->GetRect(rect);
+ CPDF_Rect rect;
+ m_pAnnot->GetRect(rect);
- return rect;
+ return rect;
}
CFX_ByteString CPDFSDK_Annot::GetType() const
{
- ASSERT(m_pAnnot != NULL);
+ ASSERT(m_pAnnot != NULL);
- return m_pAnnot->GetSubType();
+ return m_pAnnot->GetSubType();
}
CFX_ByteString CPDFSDK_Annot::GetSubType() const
{
- return "";
+ return "";
}
void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
- CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions)
+ CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions)
{
- ASSERT(m_pPageView != NULL);
- ASSERT(m_pAnnot != NULL);
+ ASSERT(m_pPageView != NULL);
+ ASSERT(m_pAnnot != NULL);
- m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, mode, pOptions);
+ m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, mode, pOptions);
}
-FX_BOOL CPDFSDK_Annot::IsAppearanceValid()
+FX_BOOL CPDFSDK_Annot::IsAppearanceValid()
{
- return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL;
+ return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL;
}
-FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
+FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
{
- CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
- if (pAP == NULL) return FALSE;
+ CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
+ if (pAP == NULL) return FALSE;
- // Choose the right sub-ap
- const FX_CHAR* ap_entry = "N";
- if (mode == CPDF_Annot::Down)
- ap_entry = "D";
- else if (mode == CPDF_Annot::Rollover)
- ap_entry = "R";
- if (!pAP->KeyExist(ap_entry))
- ap_entry = "N";
+ // Choose the right sub-ap
+ const FX_CHAR* ap_entry = "N";
+ if (mode == CPDF_Annot::Down)
+ ap_entry = "D";
+ else if (mode == CPDF_Annot::Rollover)
+ ap_entry = "R";
+ if (!pAP->KeyExist(ap_entry))
+ ap_entry = "N";
- // Get the AP stream or subdirectory
- CPDF_Object* psub = pAP->GetElementValue(ap_entry);
- if (psub == NULL) return FALSE;
+ // Get the AP stream or subdirectory
+ CPDF_Object* psub = pAP->GetElementValue(ap_entry);
+ if (psub == NULL) return FALSE;
- return TRUE;
+ return TRUE;
}
void CPDFSDK_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
- const CPDF_RenderOptions* pOptions)
+ const CPDF_RenderOptions* pOptions)
{
- ASSERT(m_pAnnot != NULL);
- m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
+ ASSERT(m_pAnnot != NULL);
+ m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
}
void CPDFSDK_Annot::ClearCachedAP()
{
- ASSERT(m_pAnnot != NULL);
- m_pAnnot->ClearCachedAP();
+ ASSERT(m_pAnnot != NULL);
+ m_pAnnot->ClearCachedAP();
}
void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents)
{
- if (sContents.IsEmpty())
- m_pAnnot->GetAnnotDict()->RemoveAt("Contents");
- else
- m_pAnnot->GetAnnotDict()->SetAtString("Contents", PDF_EncodeText(sContents));
+ if (sContents.IsEmpty())
+ m_pAnnot->GetAnnotDict()->RemoveAt("Contents");
+ else
+ m_pAnnot->GetAnnotDict()->SetAtString("Contents", PDF_EncodeText(sContents));
}
CFX_WideString CPDFSDK_Annot::GetContents() const
{
- return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents");
+ return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents");
}
void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName)
{
- if (sName.IsEmpty())
- m_pAnnot->GetAnnotDict()->RemoveAt("NM");
- else
- m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName));
+ if (sName.IsEmpty())
+ m_pAnnot->GetAnnotDict()->RemoveAt("NM");
+ else
+ m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName));
}
CFX_WideString CPDFSDK_Annot::GetAnnotName() const
{
- return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM");
+ return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM");
}
void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st)
{
- CPDFSDK_DateTime dt(st);
- CFX_ByteString str = dt.ToPDFDateTimeString();
+ CPDFSDK_DateTime dt(st);
+ CFX_ByteString str = dt.ToPDFDateTimeString();
- if (str.IsEmpty())
- m_pAnnot->GetAnnotDict()->RemoveAt("M");
- else
- m_pAnnot->GetAnnotDict()->SetAtString("M", str);
+ if (str.IsEmpty())
+ m_pAnnot->GetAnnotDict()->RemoveAt("M");
+ else
+ m_pAnnot->GetAnnotDict()->SetAtString("M", str);
}
FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const
{
- FX_SYSTEMTIME systime;
- CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M");
+ FX_SYSTEMTIME systime;
+ CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M");
- CPDFSDK_DateTime dt(str);
- dt.ToSystemTime(systime);
+ CPDFSDK_DateTime dt(str);
+ dt.ToSystemTime(systime);
- return systime;
+ return systime;
}
void CPDFSDK_Annot::SetFlags(int nFlags)
{
- m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags);
+ m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags);
}
int CPDFSDK_Annot::GetFlags() const
{
- return m_pAnnot->GetAnnotDict()->GetInteger("F");
+ return m_pAnnot->GetAnnotDict()->GetInteger("F");
}
void CPDFSDK_Annot::SetAppState(const CFX_ByteString& str)
{
- if (str.IsEmpty())
- m_pAnnot->GetAnnotDict()->RemoveAt("AS");
- else
- m_pAnnot->GetAnnotDict()->SetAtString("AS", str);
+ if (str.IsEmpty())
+ m_pAnnot->GetAnnotDict()->RemoveAt("AS");
+ else
+ m_pAnnot->GetAnnotDict()->SetAtString("AS", str);
}
CFX_ByteString CPDFSDK_Annot::GetAppState() const
{
- return m_pAnnot->GetAnnotDict()->GetString("AS");
+ return m_pAnnot->GetAnnotDict()->GetString("AS");
}
void CPDFSDK_Annot::SetStructParent(int key)
{
- m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key);
+ m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key);
}
-int CPDFSDK_Annot::GetStructParent() const
+int CPDFSDK_Annot::GetStructParent() const
{
- return m_pAnnot->GetAnnotDict()->GetInteger("StructParent");
+ return m_pAnnot->GetAnnotDict()->GetInteger("StructParent");
}
//border
void CPDFSDK_Annot::SetBorderWidth(int nWidth)
{
- CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
- if (pBorder)
- {
- pBorder->SetAt(2, new CPDF_Number(nWidth));
- }
- else
- {
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
+ if (pBorder)
+ {
+ pBorder->SetAt(2, new CPDF_Number(nWidth));
+ }
+ else
+ {
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
- if (!pBSDict)
- {
- pBSDict = new CPDF_Dictionary;
- m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
- }
+ if (!pBSDict)
+ {
+ pBSDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
+ }
- pBSDict->SetAtInteger("W", nWidth);
- }
+ pBSDict->SetAtInteger("W", nWidth);
+ }
}
-int CPDFSDK_Annot::GetBorderWidth() const
+int CPDFSDK_Annot::GetBorderWidth() const
{
- CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
-
- if (pBorder)
- {
- return pBorder->GetInteger(2);
- }
- else
- {
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
-
- if (pBSDict)
- {
- return pBSDict->GetInteger("W", 1);
- }
- }
- return 1;
+ if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border")) {
+ return pBorder->GetInteger(2);
+ }
+ if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS")) {
+ return pBSDict->GetInteger("W", 1);
+ }
+ return 1;
}
void CPDFSDK_Annot::SetBorderStyle(int nStyle)
{
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
- if (!pBSDict)
- {
- pBSDict = new CPDF_Dictionary;
- m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
- }
-
- switch (nStyle)
- {
- case BBS_SOLID:
- pBSDict->SetAtName("S", "S");
- break;
- case BBS_DASH:
- pBSDict->SetAtName("S", "D");
- break;
- case BBS_BEVELED:
- pBSDict->SetAtName("S", "B");
- break;
- case BBS_INSET:
- pBSDict->SetAtName("S", "I");
- break;
- case BBS_UNDERLINE:
- pBSDict->SetAtName("S", "U");
- break;
- }
-}
-
-int CPDFSDK_Annot::GetBorderStyle() const
-{
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
- if (pBSDict)
- {
- CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S");
- if (sBorderStyle == "S") return BBS_SOLID;
- if (sBorderStyle == "D") return BBS_DASH;
- if (sBorderStyle == "B") return BBS_BEVELED;
- if (sBorderStyle == "I") return BBS_INSET;
- if (sBorderStyle == "U") return BBS_UNDERLINE;
- }
-
- CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
- if (pBorder)
- {
- if (pBorder->GetCount() >= 4)
- {
- CPDF_Array *pDP = pBorder->GetArray(3);
- if (pDP && pDP->GetCount() > 0)
- return BBS_DASH;
- }
- }
-
- return BBS_SOLID;
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
+ if (!pBSDict)
+ {
+ pBSDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
+ }
+
+ switch (nStyle)
+ {
+ case BBS_SOLID:
+ pBSDict->SetAtName("S", "S");
+ break;
+ case BBS_DASH:
+ pBSDict->SetAtName("S", "D");
+ break;
+ case BBS_BEVELED:
+ pBSDict->SetAtName("S", "B");
+ break;
+ case BBS_INSET:
+ pBSDict->SetAtName("S", "I");
+ break;
+ case BBS_UNDERLINE:
+ pBSDict->SetAtName("S", "U");
+ break;
+ }
+}
+
+int CPDFSDK_Annot::GetBorderStyle() const
+{
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
+ if (pBSDict)
+ {
+ CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S");
+ if (sBorderStyle == "S") return BBS_SOLID;
+ if (sBorderStyle == "D") return BBS_DASH;
+ if (sBorderStyle == "B") return BBS_BEVELED;
+ if (sBorderStyle == "I") return BBS_INSET;
+ if (sBorderStyle == "U") return BBS_UNDERLINE;
+ }
+
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
+ if (pBorder)
+ {
+ if (pBorder->GetCount() >= 4)
+ {
+ CPDF_Array *pDP = pBorder->GetArray(3);
+ if (pDP && pDP->GetCount() > 0)
+ return BBS_DASH;
+ }
+ }
+
+ return BBS_SOLID;
}
void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array)
{
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
- if (!pBSDict)
- {
- pBSDict = new CPDF_Dictionary;
- m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
- }
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
+ if (!pBSDict)
+ {
+ pBSDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
+ }
- CPDF_Array* pArray = new CPDF_Array;
- for (int i=0,sz=array.GetSize(); i<sz; i++)
- {
- pArray->AddInteger(array[i]);
- }
+ CPDF_Array* pArray = new CPDF_Array;
+ for (int i=0,sz=array.GetSize(); i<sz; i++)
+ {
+ pArray->AddInteger(array[i]);
+ }
- pBSDict->SetAt("D", pArray);
+ pBSDict->SetAt("D", pArray);
}
void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const
{
- CPDF_Array* pDash = NULL;
-
- CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
- if (pBorder)
- {
- pDash = pBorder->GetArray(3);
- }
- else
- {
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
- if (pBSDict)
- {
- pDash = pBSDict->GetArray("D");
- }
- }
-
- if (pDash)
- {
- for (int i=0,sz=pDash->GetCount(); i<sz; i++)
- {
- array.Add(pDash->GetInteger(i));
- }
- }
+ CPDF_Array* pDash = NULL;
+
+ CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
+ if (pBorder)
+ {
+ pDash = pBorder->GetArray(3);
+ }
+ else
+ {
+ CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
+ if (pBSDict)
+ {
+ pDash = pBSDict->GetArray("D");
+ }
+ }
+
+ if (pDash)
+ {
+ for (int i=0,sz=pDash->GetCount(); i<sz; i++)
+ {
+ array.Add(pDash->GetInteger(i));
+ }
+ }
}
void CPDFSDK_Annot::SetColor(FX_COLORREF color)
{
- CPDF_Array* pArray = new CPDF_Array;
- pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f);
- pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f);
- pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f);
- m_pAnnot->GetAnnotDict()->SetAt("C", pArray);
+ CPDF_Array* pArray = new CPDF_Array;
+ pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f);
+ pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f);
+ pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f);
+ m_pAnnot->GetAnnotDict()->SetAt("C", pArray);
}
void CPDFSDK_Annot::RemoveColor()
{
- m_pAnnot->GetAnnotDict()->RemoveAt("C");
+ m_pAnnot->GetAnnotDict()->RemoveAt("C");
}
FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const
{
- if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C"))
- {
- int nCount = pEntry->GetCount();
- if (nCount == 1)
- {
- FX_FLOAT g = pEntry->GetNumber(0) * 255;
+ if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C"))
+ {
+ int nCount = pEntry->GetCount();
+ if (nCount == 1)
+ {
+ FX_FLOAT g = pEntry->GetNumber(0) * 255;
- color = FXSYS_RGB((int)g, (int)g, (int)g);
+ color = FXSYS_RGB((int)g, (int)g, (int)g);
- return TRUE;
- }
- else if (nCount == 3)
- {
- FX_FLOAT r = pEntry->GetNumber(0) * 255;
- FX_FLOAT g = pEntry->GetNumber(1) * 255;
- FX_FLOAT b = pEntry->GetNumber(2) * 255;
+ return TRUE;
+ }
+ else if (nCount == 3)
+ {
+ FX_FLOAT r = pEntry->GetNumber(0) * 255;
+ FX_FLOAT g = pEntry->GetNumber(1) * 255;
+ FX_FLOAT b = pEntry->GetNumber(2) * 255;
- color = FXSYS_RGB((int)r, (int)g, (int)b);
+ color = FXSYS_RGB((int)r, (int)g, (int)b);
- return TRUE;
- }
- else if (nCount == 4)
- {
- FX_FLOAT c = pEntry->GetNumber(0);
- FX_FLOAT m = pEntry->GetNumber(1);
- FX_FLOAT y = pEntry->GetNumber(2);
- FX_FLOAT k = pEntry->GetNumber(3);
+ return TRUE;
+ }
+ else if (nCount == 4)
+ {
+ FX_FLOAT c = pEntry->GetNumber(0);
+ FX_FLOAT m = pEntry->GetNumber(1);
+ FX_FLOAT y = pEntry->GetNumber(2);
+ FX_FLOAT k = pEntry->GetNumber(3);
- FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k);
- FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k);
- FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k);
+ FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k);
+ FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k);
+ FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k);
- color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)(b * 255));
+ color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)(b * 255));
- return TRUE;
- }
- }
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
- const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
- const CFX_ByteString& sAPState)
-{
- CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
-
- if (!pAPDict)
- {
- pAPDict = new CPDF_Dictionary;
- m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
- }
-
- CPDF_Stream* pStream = NULL;
- CPDF_Dictionary* pParentDict = NULL;
-
- if (sAPState.IsEmpty())
- {
- pParentDict = pAPDict;
- pStream = pAPDict->GetStream(sAPType);
- }
- else
- {
- CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
- if (!pAPTypeDict)
- {
- pAPTypeDict = new CPDF_Dictionary;
- pAPDict->SetAt(sAPType, pAPTypeDict);
- }
-
- pParentDict = pAPTypeDict;
- pStream = pAPTypeDict->GetStream(sAPState);
- }
-
- if (!pStream)
- {
- CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- pStream = new CPDF_Stream(NULL, 0, NULL);
- int32_t objnum = pDoc->AddIndirectObject(pStream);
- pParentDict->SetAtReference(sAPType, pDoc, objnum);
- }
-
- CPDF_Dictionary *pStreamDict = pStream->GetDict();
- if (!pStreamDict)
- {
- pStreamDict = new CPDF_Dictionary;
- pStreamDict->SetAtName("Type", "XObject");
- pStreamDict->SetAtName("Subtype", "Form");
- pStreamDict->SetAtInteger("FormType", 1);
- pStream->InitStream(NULL,0,pStreamDict);
- }
-
- if (pStreamDict)
- {
- pStreamDict->SetAtMatrix("Matrix",matrix);
- pStreamDict->SetAtRect("BBox", rcBBox);
- }
-
- pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, FALSE);
-}
-
-#define BA_ANNOT_MINWIDTH 1
-#define BA_ANNOT_MINHEIGHT 1
+ const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
+ const CFX_ByteString& sAPState)
+{
+ CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
+
+ if (!pAPDict)
+ {
+ pAPDict = new CPDF_Dictionary;
+ m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
+ }
+
+ CPDF_Stream* pStream = NULL;
+ CPDF_Dictionary* pParentDict = NULL;
+
+ if (sAPState.IsEmpty())
+ {
+ pParentDict = pAPDict;
+ pStream = pAPDict->GetStream(sAPType);
+ }
+ else
+ {
+ CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
+ if (!pAPTypeDict)
+ {
+ pAPTypeDict = new CPDF_Dictionary;
+ pAPDict->SetAt(sAPType, pAPTypeDict);
+ }
+
+ pParentDict = pAPTypeDict;
+ pStream = pAPTypeDict->GetStream(sAPState);
+ }
+
+ if (!pStream)
+ {
+ CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
+ pStream = new CPDF_Stream(NULL, 0, NULL);
+ int32_t objnum = pDoc->AddIndirectObject(pStream);
+ pParentDict->SetAtReference(sAPType, pDoc, objnum);
+ }
+
+ CPDF_Dictionary *pStreamDict = pStream->GetDict();
+ if (!pStreamDict)
+ {
+ pStreamDict = new CPDF_Dictionary;
+ pStreamDict->SetAtName("Type", "XObject");
+ pStreamDict->SetAtName("Subtype", "Form");
+ pStreamDict->SetAtInteger("FormType", 1);
+ pStream->InitStream(NULL,0,pStreamDict);
+ }
+
+ if (pStreamDict)
+ {
+ pStreamDict->SetAtMatrix("Matrix",matrix);
+ pStreamDict->SetAtRect("BBox", rcBBox);
+ }
+
+ pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, FALSE);
+}
+
+#define BA_ANNOT_MINWIDTH 1
+#define BA_ANNOT_MINHEIGHT 1
FX_FLOAT CPDFSDK_Annot::GetMinWidth() const
{
- return BA_ANNOT_MINWIDTH;
+ return BA_ANNOT_MINWIDTH;
}
FX_FLOAT CPDFSDK_Annot::GetMinHeight() const
{
- return BA_ANNOT_MINHEIGHT;
+ return BA_ANNOT_MINHEIGHT;
}
FX_BOOL CPDFSDK_Annot::CreateFormFiller()
{
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPDFSDK_Annot::IsVisible() const
+FX_BOOL CPDFSDK_Annot::IsVisible() const
{
- int nFlags = GetFlags();
- return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || (nFlags & ANNOTFLAG_NOVIEW));
+ int nFlags = GetFlags();
+ return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || (nFlags & ANNOTFLAG_NOVIEW));
}
CPDF_Action CPDFSDK_Annot::GetAction() const
{
- return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"));
+ return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"));
}
void CPDFSDK_Annot::SetAction(const CPDF_Action& action)
{
- ASSERT(action);
- if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A")))
- {
- CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- CPDF_Dictionary* pDict = action.GetDict();
- if (pDict && pDict->GetObjNum() == 0) {
- pDoc->AddIndirectObject(pDict);
- }
- m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum());
- }
+ ASSERT(action);
+ if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A")))
+ {
+ CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
+ CPDF_Dictionary* pDict = action.GetDict();
+ if (pDict && pDict->GetObjNum() == 0) {
+ pDoc->AddIndirectObject(pDict);
+ }
+ m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum());
+ }
}
void CPDFSDK_Annot::RemoveAction()
{
- m_pAnnot->GetAnnotDict()->RemoveAt("A");
+ m_pAnnot->GetAnnotDict()->RemoveAt("A");
}
CPDF_AAction CPDFSDK_Annot::GetAAction() const
{
- return m_pAnnot->GetAnnotDict()->GetDict("AA");
+ return m_pAnnot->GetAnnotDict()->GetDict("AA");
}
void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa)
{
- ASSERT(aa != NULL);
+ ASSERT(aa != NULL);
- if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA"))
- m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
+ if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA"))
+ m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
}
void CPDFSDK_Annot::RemoveAAction()
{
- m_pAnnot->GetAnnotDict()->RemoveAt("AA");
+ m_pAnnot->GetAnnotDict()->RemoveAt("AA");
}
-CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
+CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
{
- CPDF_AAction AAction = GetAAction();
+ CPDF_AAction AAction = GetAAction();
- if (AAction.ActionExist(eAAT))
- return AAction.GetAction(eAAT);
+ if (AAction.ActionExist(eAAT))
+ return AAction.GetAction(eAAT);
- if (eAAT == CPDF_AAction::ButtonUp)
- return GetAction();
+ if (eAAT == CPDF_AAction::ButtonUp)
+ return GetAction();
- return CPDF_Action();
+ return CPDF_Action();
}
void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, CPDF_RenderOptions* pOptions)
{
- m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
- m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
+ m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- return ;
+ return ;
}
CPDF_Page* CPDFSDK_Annot::GetPDFPage()
{
- if(m_pPageView)
- return m_pPageView->GetPDFPage();
- return NULL;
+ if(m_pPageView)
+ return m_pPageView->GetPDFPage();
+ return NULL;
}
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index d3742520fa..ee16212f46 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -15,21 +15,21 @@
#include "../include/javascript/IJavaScript.h"
//------------------------------------------------------------------------------------
-//* CPDFSDK_Widget
+//* CPDFSDK_Widget
//------------------------------------------------------------------------------------
-#define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01)
-#define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
+#define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01)
+#define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) :
- CPDFSDK_Annot(pAnnot, pPageView),
- m_pInterForm(pInterForm),
- m_nAppAge(0),
- m_nValueAge(0)
+ CPDFSDK_Annot(pAnnot, pPageView),
+ m_pInterForm(pInterForm),
+ m_nAppAge(0),
+ m_nValueAge(0)
{
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pInterForm != NULL);
}
CPDFSDK_Widget::~CPDFSDK_Widget()
@@ -37,265 +37,261 @@ CPDFSDK_Widget::~CPDFSDK_Widget()
}
-FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode)
-{
- CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
- if (pAP == NULL) return FALSE;
-
- // Choose the right sub-ap
- const FX_CHAR* ap_entry = "N";
- if (mode == CPDF_Annot::Down)
- ap_entry = "D";
- else if (mode == CPDF_Annot::Rollover)
- ap_entry = "R";
- if (!pAP->KeyExist(ap_entry))
- ap_entry = "N";
-
- // Get the AP stream or subdirectory
- CPDF_Object* psub = pAP->GetElementValue(ap_entry);
- if (psub == NULL) return FALSE;
-
- int nFieldType = GetFieldType();
- switch (nFieldType)
- {
- case FIELDTYPE_PUSHBUTTON:
- case FIELDTYPE_COMBOBOX:
- case FIELDTYPE_LISTBOX:
- case FIELDTYPE_TEXTFIELD:
- case FIELDTYPE_SIGNATURE:
- return psub->GetType() == PDFOBJ_STREAM;
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- if (psub->GetType() == PDFOBJ_DICTIONARY)
- {
- CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub;
-
- return pSubDict->GetStream(GetAppState()) != NULL;
- }
- else
- return FALSE;
- break;
- }
+FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode)
+{
+ CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
+ if (pAP == NULL) return FALSE;
+
+ // Choose the right sub-ap
+ const FX_CHAR* ap_entry = "N";
+ if (mode == CPDF_Annot::Down)
+ ap_entry = "D";
+ else if (mode == CPDF_Annot::Rollover)
+ ap_entry = "R";
+ if (!pAP->KeyExist(ap_entry))
+ ap_entry = "N";
+
+ // Get the AP stream or subdirectory
+ CPDF_Object* psub = pAP->GetElementValue(ap_entry);
+ if (psub == NULL) return FALSE;
+
+ int nFieldType = GetFieldType();
+ switch (nFieldType)
+ {
+ case FIELDTYPE_PUSHBUTTON:
+ case FIELDTYPE_COMBOBOX:
+ case FIELDTYPE_LISTBOX:
+ case FIELDTYPE_TEXTFIELD:
+ case FIELDTYPE_SIGNATURE:
+ return psub->GetType() == PDFOBJ_STREAM;
+ case FIELDTYPE_CHECKBOX:
+ case FIELDTYPE_RADIOBUTTON:
+ if (psub->GetType() == PDFOBJ_DICTIONARY) {
+ CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub;
+ return pSubDict->GetStream(GetAppState()) != NULL;
+ }
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-int CPDFSDK_Widget::GetFieldType() const
+int CPDFSDK_Widget::GetFieldType() const
{
- CPDF_FormField* pField = GetFormField();
- ASSERT(pField != NULL);
+ CPDF_FormField* pField = GetFormField();
+ ASSERT(pField != NULL);
- return pField->GetFieldType();
+ return pField->GetFieldType();
}
int CPDFSDK_Widget::GetFieldFlags() const
{
- CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
- ASSERT(pPDFInterForm != NULL);
+ CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
+ ASSERT(pPDFInterForm != NULL);
- CPDF_FormControl* pFormControl = pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict());
- CPDF_FormField* pFormField = pFormControl->GetField();
- return pFormField->GetFieldFlags();
+ CPDF_FormControl* pFormControl = pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict());
+ CPDF_FormField* pFormField = pFormControl->GetField();
+ return pFormField->GetFieldFlags();
}
CFX_ByteString CPDFSDK_Widget::GetSubType() const
{
- int nType = GetFieldType();
+ int nType = GetFieldType();
- if (nType == FIELDTYPE_SIGNATURE)
- return BFFT_SIGNATURE;
- return CPDFSDK_Annot::GetSubType();
+ if (nType == FIELDTYPE_SIGNATURE)
+ return BFFT_SIGNATURE;
+ return CPDFSDK_Annot::GetSubType();
}
-CPDF_FormField* CPDFSDK_Widget::GetFormField() const
+CPDF_FormField* CPDFSDK_Widget::GetFormField() const
{
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pInterForm != NULL);
- CPDF_FormControl* pCtrl = GetFormControl();
- ASSERT(pCtrl != NULL);
+ CPDF_FormControl* pCtrl = GetFormControl();
+ ASSERT(pCtrl != NULL);
- return pCtrl->GetField();
+ return pCtrl->GetField();
}
CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const
{
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pInterForm != NULL);
- CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
- ASSERT(pPDFInterForm != NULL);
+ CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
+ ASSERT(pPDFInterForm != NULL);
- return pPDFInterForm->GetControlByDict(GetAnnotDict());
+ return pPDFInterForm->GetControlByDict(GetAnnotDict());
}
CPDF_FormControl* CPDFSDK_Widget::GetFormControl(CPDF_InterForm* pInterForm, CPDF_Dictionary* pAnnotDict)
{
- ASSERT(pInterForm != NULL);
- ASSERT(pAnnotDict != NULL);
+ ASSERT(pInterForm != NULL);
+ ASSERT(pAnnotDict != NULL);
- CPDF_FormControl* pControl = pInterForm->GetControlByDict(pAnnotDict);
+ CPDF_FormControl* pControl = pInterForm->GetControlByDict(pAnnotDict);
- return pControl;
+ return pControl;
}
int CPDFSDK_Widget::GetRotate() const
{
- CPDF_FormControl* pCtrl = GetFormControl();
- ASSERT(pCtrl != NULL);
+ CPDF_FormControl* pCtrl = GetFormControl();
+ ASSERT(pCtrl != NULL);
- return pCtrl->GetRotation() % 360;
+ return pCtrl->GetRotation() % 360;
}
-FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const
+FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- int iColorType = 0;
- color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType));
+ int iColorType = 0;
+ color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType));
- return iColorType != COLORTYPE_TRANSPARENT;
+ return iColorType != COLORTYPE_TRANSPARENT;
}
-FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const
+FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- int iColorType = 0;
- color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType));
+ int iColorType = 0;
+ color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType));
- return iColorType != COLORTYPE_TRANSPARENT;
+ return iColorType != COLORTYPE_TRANSPARENT;
}
-FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const
+FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance();
- if (da.HasColor())
- {
- FX_ARGB argb;
- int iColorType = COLORTYPE_TRANSPARENT;
- da.GetColor(argb, iColorType);
- color = FX_ARGBTOCOLORREF(argb);
+ CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance();
+ if (da.HasColor())
+ {
+ FX_ARGB argb;
+ int iColorType = COLORTYPE_TRANSPARENT;
+ da.GetColor(argb, iColorType);
+ color = FX_ARGBTOCOLORREF(argb);
- return iColorType != COLORTYPE_TRANSPARENT;
- }
+ return iColorType != COLORTYPE_TRANSPARENT;
+ }
- return FALSE;
+ return FALSE;
}
FX_FLOAT CPDFSDK_Widget::GetFontSize() const
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance();
- CFX_ByteString csFont = "";
- FX_FLOAT fFontSize = 0.0f;
- pDa.GetFont(csFont, fFontSize);
+ CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance();
+ CFX_ByteString csFont = "";
+ FX_FLOAT fFontSize = 0.0f;
+ pDa.GetFont(csFont, fFontSize);
- return fFontSize;
+ return fFontSize;
}
-int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const
+int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetSelectedIndex(nIndex);
+ return pFormField->GetSelectedIndex(nIndex);
}
CFX_WideString CPDFSDK_Widget::GetValue() const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetValue();
+ return pFormField->GetValue();
}
CFX_WideString CPDFSDK_Widget::GetDefaultValue() const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetDefaultValue();
+ return pFormField->GetDefaultValue();
}
CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetOptionLabel(nIndex);
+ return pFormField->GetOptionLabel(nIndex);
}
-int CPDFSDK_Widget::CountOptions() const
+int CPDFSDK_Widget::CountOptions() const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->CountOptions();
+ return pFormField->CountOptions();
}
-FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const
+FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->IsItemSelected(nIndex);
+ return pFormField->IsItemSelected(nIndex);
}
-int CPDFSDK_Widget::GetTopVisibleIndex() const
+int CPDFSDK_Widget::GetTopVisibleIndex() const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetTopVisibleIndex();
+ return pFormField->GetTopVisibleIndex();
}
-FX_BOOL CPDFSDK_Widget::IsChecked() const
+FX_BOOL CPDFSDK_Widget::IsChecked() const
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- return pFormCtrl->IsChecked();
+ return pFormCtrl->IsChecked();
}
-int CPDFSDK_Widget::GetAlignment() const
+int CPDFSDK_Widget::GetAlignment() const
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- return pFormCtrl->GetControlAlignment();
+ return pFormCtrl->GetControlAlignment();
}
-int CPDFSDK_Widget::GetMaxLen() const
+int CPDFSDK_Widget::GetMaxLen() const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetMaxLen();
+ return pFormField->GetMaxLen();
}
void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify)
{
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- CPDF_FormField* pFormField = pFormCtrl->GetField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = pFormCtrl->GetField();
+ ASSERT(pFormField != NULL);
- pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, bNotify);
+ pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, bNotify);
}
void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify)
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- pFormField->SetValue(sValue, bNotify);
+ pFormField->SetValue(sValue, bNotify);
}
void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue)
@@ -303,18 +299,18 @@ void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue)
}
void CPDFSDK_Widget::SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify)
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- pFormField->SetItemSelection(index, bSelected, bNotify);
+ pFormField->SetItemSelection(index, bSelected, bNotify);
}
void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify)
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- pFormField->ClearSelection(bNotify);
+ pFormField->ClearSelection(bNotify);
}
void CPDFSDK_Widget::SetTopVisibleIndex(int index)
@@ -323,55 +319,55 @@ void CPDFSDK_Widget::SetTopVisibleIndex(int index)
void CPDFSDK_Widget::SetAppModified()
{
- m_bAppModified = TRUE;
+ m_bAppModified = TRUE;
}
void CPDFSDK_Widget::ClearAppModified()
{
- m_bAppModified = FALSE;
+ m_bAppModified = FALSE;
}
FX_BOOL CPDFSDK_Widget::IsAppModified() const
{
- return m_bAppModified;
+ return m_bAppModified;
}
void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged)
{
- SetAppModified();
-
- m_nAppAge++;
- if (m_nAppAge > 999999)
- m_nAppAge = 0;
- if (bValueChanged)
- m_nValueAge++;
-
- int nFieldType = GetFieldType();
-
- switch (nFieldType)
- {
- case FIELDTYPE_PUSHBUTTON:
- ResetAppearance_PushButton();
- break;
- case FIELDTYPE_CHECKBOX:
- ResetAppearance_CheckBox();
- break;
- case FIELDTYPE_RADIOBUTTON:
- ResetAppearance_RadioButton();
- break;
- case FIELDTYPE_COMBOBOX:
- ResetAppearance_ComboBox(sValue);
- break;
- case FIELDTYPE_LISTBOX:
- ResetAppearance_ListBox();
- break;
- case FIELDTYPE_TEXTFIELD:
- ResetAppearance_TextField(sValue);
- break;
- }
-
- ASSERT(m_pAnnot != NULL);
- m_pAnnot->ClearCachedAP();
+ SetAppModified();
+
+ m_nAppAge++;
+ if (m_nAppAge > 999999)
+ m_nAppAge = 0;
+ if (bValueChanged)
+ m_nValueAge++;
+
+ int nFieldType = GetFieldType();
+
+ switch (nFieldType)
+ {
+ case FIELDTYPE_PUSHBUTTON:
+ ResetAppearance_PushButton();
+ break;
+ case FIELDTYPE_CHECKBOX:
+ ResetAppearance_CheckBox();
+ break;
+ case FIELDTYPE_RADIOBUTTON:
+ ResetAppearance_RadioButton();
+ break;
+ case FIELDTYPE_COMBOBOX:
+ ResetAppearance_ComboBox(sValue);
+ break;
+ case FIELDTYPE_LISTBOX:
+ ResetAppearance_ListBox();
+ break;
+ case FIELDTYPE_TEXTFIELD:
+ ResetAppearance_TextField(sValue);
+ break;
+ }
+
+ ASSERT(m_pAnnot != NULL);
+ m_pAnnot->ClearCachedAP();
}
CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated)
@@ -383,1285 +379,1283 @@ CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated)
void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged)
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pInterForm != NULL);
- m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged);
+ m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged);
}
-void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
- CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions)
+void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
+ CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions)
{
- int nFieldType = GetFieldType();
+ int nFieldType = GetFieldType();
- if ((nFieldType == FIELDTYPE_CHECKBOX || nFieldType == FIELDTYPE_RADIOBUTTON) &&
- mode == CPDF_Annot::Normal &&
- !IsWidgetAppearanceValid(CPDF_Annot::Normal))
- {
- CFX_PathData pathData;
+ if ((nFieldType == FIELDTYPE_CHECKBOX || nFieldType == FIELDTYPE_RADIOBUTTON) &&
+ mode == CPDF_Annot::Normal &&
+ !IsWidgetAppearanceValid(CPDF_Annot::Normal))
+ {
+ CFX_PathData pathData;
- CPDF_Rect rcAnnot = GetRect();
+ CPDF_Rect rcAnnot = GetRect();
- pathData.AppendRect(rcAnnot.left, rcAnnot.bottom,
- rcAnnot.right, rcAnnot.top);
+ pathData.AppendRect(rcAnnot.left, rcAnnot.bottom,
+ rcAnnot.right, rcAnnot.top);
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 0.0f;
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = 0.0f;
- pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, FXFILL_ALTERNATE);
- }
- else
- {
- CPDFSDK_Annot::DrawAppearance(pDevice, pUser2Device, mode, pOptions);
- }
+ pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, FXFILL_ALTERNATE);
+ }
+ else
+ {
+ CPDFSDK_Annot::DrawAppearance(pDevice, pUser2Device, mode, pOptions);
+ }
}
void CPDFSDK_Widget::UpdateField()
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- ASSERT(m_pInterForm != NULL);
- m_pInterForm->UpdateField(pFormField);
+ ASSERT(m_pInterForm != NULL);
+ m_pInterForm->UpdateField(pFormField);
}
void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pInterForm != NULL);
+
+ int nFieldType = GetFieldType();
+ if (m_pInterForm->IsNeedHighLight(nFieldType))
+ {
+
+// if (nFieldType != FIELDTYPE_PUSHBUTTON)
+// {
+ CPDF_Rect rc = GetRect();
+ FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType);
+ uint8_t alpha = m_pInterForm->GetHighlightAlpha();
+
+ CFX_FloatRect rcDevice;
+ ASSERT(m_pInterForm->GetDocument());
+ CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv();
+ if(!pEnv)
+ return;
+ CFX_AffineMatrix page2device;
+ pPageView->GetCurrentMatrix(page2device);
+ page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), rcDevice.left, rcDevice.bottom);
+// pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.left, rc.bottom, &rcDevice.left, &rcDevice.bottom);
+// pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.right, rc.top, &rcDevice.right, &rcDevice.top);
+ page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), rcDevice.right, rcDevice.top);
+
+ rcDevice.Normalize();
+
+ FX_ARGB argb = ArgbEncode((int)alpha, color);
+ FX_RECT rcDev((int)rcDevice.left,(int)rcDevice.top,(int)rcDevice.right,(int)rcDevice.bottom);
+ pDevice->FillRect(&rcDev, argb);
+ /* }*/
+ }
+}
- int nFieldType = GetFieldType();
- if (m_pInterForm->IsNeedHighLight(nFieldType))
- {
+void CPDFSDK_Widget::ResetAppearance_PushButton()
+{
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+
+
+
+ CPDF_Rect rcWindow = GetRotatedRect();
+
+ int32_t nLayout = 0;
+
+ switch (pControl->GetTextPosition())
+ {
+ case TEXTPOS_ICON:
+ nLayout = PPBL_ICON;
+ break;
+ case TEXTPOS_BELOW:
+ nLayout = PPBL_ICONTOPLABELBOTTOM;
+ break;
+ case TEXTPOS_ABOVE:
+ nLayout = PPBL_LABELTOPICONBOTTOM;
+ break;
+ case TEXTPOS_RIGHT:
+ nLayout = PPBL_ICONLEFTLABELRIGHT;
+ break;
+ case TEXTPOS_LEFT:
+ nLayout = PPBL_LABELLEFTICONRIGHT;
+ break;
+ case TEXTPOS_OVERLAID:
+ nLayout = PPBL_LABELOVERICON;
+ break;
+ default:
+ nLayout = PPBL_LABEL;
+ break;
+ }
-// if (nFieldType != FIELDTYPE_PUSHBUTTON)
-// {
- CPDF_Rect rc = GetRect();
- FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType);
- uint8_t alpha = m_pInterForm->GetHighlightAlpha();
+ CPWL_Color crBackground, crBorder;
+
+ int iColorType;
+ FX_FLOAT fc[4];
+
+ pControl->GetOriginalBackgroundColor(iColorType, fc);
+ if (iColorType > 0)
+ crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+
+ pControl->GetOriginalBorderColor(iColorType, fc);
+ if (iColorType > 0)
+ crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ int32_t nBorderStyle = 0;
+ CPWL_Dash dsBorder(3,0,0);
+ CPWL_Color crLeftTop,crRightBottom;
+
+ switch (GetBorderStyle())
+ {
+ case BBS_DASH:
+ nBorderStyle = PBS_DASH;
+ dsBorder = CPWL_Dash(3, 3, 0);
+ break;
+ case BBS_BEVELED:
+ nBorderStyle = PBS_BEVELED;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,1);
+ crRightBottom = CPWL_Utils::DevideColor(crBackground,2);
+ break;
+ case BBS_INSET:
+ nBorderStyle = PBS_INSET;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75);
+ break;
+ case BBS_UNDERLINE:
+ nBorderStyle = PBS_UNDERLINED;
+ break;
+ default:
+ nBorderStyle = PBS_SOLID;
+ break;
+ }
- CFX_FloatRect rcDevice;
- ASSERT(m_pInterForm->GetDocument());
- CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv();
- if(!pEnv)
- return;
- CFX_AffineMatrix page2device;
- pPageView->GetCurrentMatrix(page2device);
- page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), rcDevice.left, rcDevice.bottom);
-// pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.left, rc.bottom, &rcDevice.left, &rcDevice.bottom);
-// pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.right, rc.top, &rcDevice.right, &rcDevice.top);
- page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), rcDevice.right, rcDevice.top);
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth);
- rcDevice.Normalize();
+ CPWL_Color crText(COLORTYPE_GRAY,0);
- FX_ARGB argb = ArgbEncode((int)alpha, color);
- FX_RECT rcDev((int)rcDevice.left,(int)rcDevice.top,(int)rcDevice.right,(int)rcDevice.bottom);
- pDevice->FillRect(&rcDev, argb);
- /* }*/
- }
-}
+ FX_FLOAT fFontSize = 12.0f;
+ CFX_ByteString csNameTag;
-void CPDFSDK_Widget::ResetAppearance_PushButton()
-{
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
-
-
-
- CPDF_Rect rcWindow = GetRotatedRect();
-
- int32_t nLayout = 0;
-
- switch (pControl->GetTextPosition())
- {
- case TEXTPOS_ICON:
- nLayout = PPBL_ICON;
- break;
- case TEXTPOS_BELOW:
- nLayout = PPBL_ICONTOPLABELBOTTOM;
- break;
- case TEXTPOS_ABOVE:
- nLayout = PPBL_LABELTOPICONBOTTOM;
- break;
- case TEXTPOS_RIGHT:
- nLayout = PPBL_ICONLEFTLABELRIGHT;
- break;
- case TEXTPOS_LEFT:
- nLayout = PPBL_LABELLEFTICONRIGHT;
- break;
- case TEXTPOS_OVERLAID:
- nLayout = PPBL_LABELOVERICON;
- break;
- default:
- nLayout = PPBL_LABEL;
- break;
- }
-
- CPWL_Color crBackground, crBorder;
-
- int iColorType;
- FX_FLOAT fc[4];
-
- pControl->GetOriginalBackgroundColor(iColorType, fc);
- if (iColorType > 0)
- crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
-
- pControl->GetOriginalBorderColor(iColorType, fc);
- if (iColorType > 0)
- crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
-
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
- CPWL_Dash dsBorder(3,0,0);
- CPWL_Color crLeftTop,crRightBottom;
-
- switch (GetBorderStyle())
- {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
- dsBorder = CPWL_Dash(3, 3, 0);
- break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,1);
- crRightBottom = CPWL_Utils::DevideColor(crBackground,2);
- break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75);
- break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
- default:
- nBorderStyle = PBS_SOLID;
- break;
- }
-
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth);
-
- CPWL_Color crText(COLORTYPE_GRAY,0);
-
- FX_FLOAT fFontSize = 12.0f;
- CFX_ByteString csNameTag;
-
- CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
- if (da.HasColor())
- {
- da.GetColor(iColorType, fc);
- crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
- }
-
- if (da.HasFont())
- da.GetFont(csNameTag, fFontSize);
-
- CFX_WideString csWCaption;
- CFX_WideString csNormalCaption, csRolloverCaption, csDownCaption;
-
- if (pControl->HasMKEntry("CA"))
- {
- csNormalCaption = pControl->GetNormalCaption();
- }
- if (pControl->HasMKEntry("RC"))
- {
- csRolloverCaption = pControl->GetRolloverCaption();
- }
- if (pControl->HasMKEntry("AC"))
- {
- csDownCaption = pControl->GetDownCaption();
- }
-
- CPDF_Stream* pNormalIcon = NULL;
- CPDF_Stream* pRolloverIcon = NULL;
- CPDF_Stream* pDownIcon = NULL;
-
- if (pControl->HasMKEntry("I"))
- {
- pNormalIcon = pControl->GetNormalIcon();
- }
- if (pControl->HasMKEntry("RI"))
- {
- pRolloverIcon = pControl->GetRolloverIcon();
- }
- if (pControl->HasMKEntry("IX"))
- {
- pDownIcon = pControl->GetDownIcon();
- }
-
- if (pNormalIcon)
- {
- if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict())
- {
- if (pImageDict->GetString("Name").IsEmpty())
- pImageDict->SetAtString("Name", "ImgA");
- }
- }
-
- if (pRolloverIcon)
- {
- if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict())
- {
- if (pImageDict->GetString("Name").IsEmpty())
- pImageDict->SetAtString("Name", "ImgB");
- }
- }
-
- if (pDownIcon)
- {
- if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict())
- {
- if (pImageDict->GetString("Name").IsEmpty())
- pImageDict->SetAtString("Name", "ImgC");
- }
- }
-
- CPDF_IconFit iconFit = pControl->GetIconFit();
-
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- ASSERT(pDoc != NULL);
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
-
- CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSystemHandler(m_pBaseForm->GetEnv()));
- FontMap.Initial();
-
- FontMap.SetAPType("N");
-
- CFX_ByteString csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) +
- CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout);
-
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP);
- if (pNormalIcon)
- AddImageToAppearance("N", pNormalIcon);
-
- CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode();
- if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle)
- {
- if (csRolloverCaption.IsEmpty() && !pRolloverIcon)
- {
- csRolloverCaption = csNormalCaption;
- pRolloverIcon = pNormalIcon;
- }
-
- FontMap.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, pRolloverIcon, iconFit, csRolloverCaption, crText, fFontSize, nLayout);
-
- WriteAppearance("R", GetRotatedRect(), GetMatrix(), csAP);
- if (pRolloverIcon)
- AddImageToAppearance("R", pRolloverIcon);
-
- if (csDownCaption.IsEmpty() && !pDownIcon)
- {
- csDownCaption = csNormalCaption;
- pDownIcon = pNormalIcon;
- }
-
- switch (nBorderStyle)
- {
- case PBS_BEVELED:
- {
- CPWL_Color crTemp = crLeftTop;
- crLeftTop = crRightBottom;
- crRightBottom = crTemp;
- }
- break;
- case PBS_INSET:
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
- break;
- }
-
- FontMap.SetAPType("D");
-
- csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, CPWL_Utils::SubstractColor(crBackground,0.25f)) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) +
- CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout);
-
- WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP);
- if (pDownIcon)
- AddImageToAppearance("D", pDownIcon);
- }
- else
- {
- RemoveAppearance("D");
- RemoveAppearance("R");
- }
+ CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
+ if (da.HasColor())
+ {
+ da.GetColor(iColorType, fc);
+ crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+ }
+
+ if (da.HasFont())
+ da.GetFont(csNameTag, fFontSize);
+
+ CFX_WideString csWCaption;
+ CFX_WideString csNormalCaption, csRolloverCaption, csDownCaption;
+
+ if (pControl->HasMKEntry("CA"))
+ {
+ csNormalCaption = pControl->GetNormalCaption();
+ }
+ if (pControl->HasMKEntry("RC"))
+ {
+ csRolloverCaption = pControl->GetRolloverCaption();
+ }
+ if (pControl->HasMKEntry("AC"))
+ {
+ csDownCaption = pControl->GetDownCaption();
+ }
+
+ CPDF_Stream* pNormalIcon = NULL;
+ CPDF_Stream* pRolloverIcon = NULL;
+ CPDF_Stream* pDownIcon = NULL;
+
+ if (pControl->HasMKEntry("I"))
+ {
+ pNormalIcon = pControl->GetNormalIcon();
+ }
+ if (pControl->HasMKEntry("RI"))
+ {
+ pRolloverIcon = pControl->GetRolloverIcon();
+ }
+ if (pControl->HasMKEntry("IX"))
+ {
+ pDownIcon = pControl->GetDownIcon();
+ }
+
+ if (pNormalIcon)
+ {
+ if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict())
+ {
+ if (pImageDict->GetString("Name").IsEmpty())
+ pImageDict->SetAtString("Name", "ImgA");
+ }
+ }
+
+ if (pRolloverIcon)
+ {
+ if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict())
+ {
+ if (pImageDict->GetString("Name").IsEmpty())
+ pImageDict->SetAtString("Name", "ImgB");
+ }
+ }
+
+ if (pDownIcon)
+ {
+ if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict())
+ {
+ if (pImageDict->GetString("Name").IsEmpty())
+ pImageDict->SetAtString("Name", "ImgC");
+ }
+ }
+
+ CPDF_IconFit iconFit = pControl->GetIconFit();
+
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ ASSERT(pDoc != NULL);
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+
+ CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSystemHandler(m_pBaseForm->GetEnv()));
+ FontMap.Initial();
+
+ FontMap.SetAPType("N");
+
+ CFX_ByteString csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
+ CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) +
+ CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout);
+
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP);
+ if (pNormalIcon)
+ AddImageToAppearance("N", pNormalIcon);
+
+ CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode();
+ if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle)
+ {
+ if (csRolloverCaption.IsEmpty() && !pRolloverIcon)
+ {
+ csRolloverCaption = csNormalCaption;
+ pRolloverIcon = pNormalIcon;
+ }
+
+ FontMap.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, pRolloverIcon, iconFit, csRolloverCaption, crText, fFontSize, nLayout);
+
+ WriteAppearance("R", GetRotatedRect(), GetMatrix(), csAP);
+ if (pRolloverIcon)
+ AddImageToAppearance("R", pRolloverIcon);
+
+ if (csDownCaption.IsEmpty() && !pDownIcon)
+ {
+ csDownCaption = csNormalCaption;
+ pDownIcon = pNormalIcon;
+ }
+
+ switch (nBorderStyle)
+ {
+ case PBS_BEVELED:
+ {
+ CPWL_Color crTemp = crLeftTop;
+ crLeftTop = crRightBottom;
+ crRightBottom = crTemp;
+ }
+ break;
+ case PBS_INSET:
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
+ break;
+ }
+
+ FontMap.SetAPType("D");
+
+ csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, CPWL_Utils::SubstractColor(crBackground,0.25f)) +
+ CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) +
+ CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout);
+
+ WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP);
+ if (pDownIcon)
+ AddImageToAppearance("D", pDownIcon);
+ }
+ else
+ {
+ RemoveAppearance("D");
+ RemoveAppearance("R");
+ }
}
void CPDFSDK_Widget::ResetAppearance_CheckBox()
{
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
-
-
-
- CPWL_Color crBackground, crBorder, crText;
-
- int iColorType;
- FX_FLOAT fc[4];
-
- pControl->GetOriginalBackgroundColor(iColorType, fc);
- if (iColorType > 0)
- crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
-
- pControl->GetOriginalBorderColor(iColorType, fc);
- if (iColorType > 0)
- crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
-
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
- CPWL_Dash dsBorder(3,0,0);
- CPWL_Color crLeftTop,crRightBottom;
-
- switch (GetBorderStyle())
- {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
- dsBorder = CPWL_Dash(3, 3, 0);
- break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,1);
- crRightBottom = CPWL_Utils::DevideColor(crBackground,2);
- break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75);
- break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
- default:
- nBorderStyle = PBS_SOLID;
- break;
- }
-
- CPDF_Rect rcWindow = GetRotatedRect();
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth);
-
- CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
- if (da.HasColor())
- {
- da.GetColor(iColorType, fc);
- crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
- }
-
- int32_t nStyle = 0;
-
- CFX_WideString csWCaption = pControl->GetNormalCaption();
- if (csWCaption.GetLength() > 0)
- {
- switch (csWCaption[0])
- {
- case L'l':
- nStyle = PCS_CIRCLE;
- break;
- case L'8':
- nStyle = PCS_CROSS;
- break;
- case L'u':
- nStyle = PCS_DIAMOND;
- break;
- case L'n':
- nStyle = PCS_SQUARE;
- break;
- case L'H':
- nStyle = PCS_STAR;
- break;
- default: //L'4'
- nStyle = PCS_CHECK;
- break;
- }
- }
- else
- {
- nStyle = PCS_CHECK;
- }
-
- CFX_ByteString csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
-
- CFX_ByteString csAP_N_OFF = csAP_N_ON;
-
- switch (nBorderStyle)
- {
- case PBS_BEVELED:
- {
- CPWL_Color crTemp = crLeftTop;
- crLeftTop = crRightBottom;
- crRightBottom = crTemp;
- }
- break;
- case PBS_INSET:
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
- break;
- }
-
- CFX_ByteString csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) +
- CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
-
- CFX_ByteString csAP_D_OFF = csAP_D_ON;
-
- csAP_N_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient,nStyle,crText);
- csAP_D_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient,nStyle,crText);
-
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_ON, pControl->GetCheckedAPState());
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off");
-
- WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl->GetCheckedAPState());
- WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off");
-
- CFX_ByteString csAS = GetAppState();
- if (csAS.IsEmpty())
- SetAppState("Off");
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+
+
+
+ CPWL_Color crBackground, crBorder, crText;
+
+ int iColorType;
+ FX_FLOAT fc[4];
+
+ pControl->GetOriginalBackgroundColor(iColorType, fc);
+ if (iColorType > 0)
+ crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+
+ pControl->GetOriginalBorderColor(iColorType, fc);
+ if (iColorType > 0)
+ crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ int32_t nBorderStyle = 0;
+ CPWL_Dash dsBorder(3,0,0);
+ CPWL_Color crLeftTop,crRightBottom;
+
+ switch (GetBorderStyle())
+ {
+ case BBS_DASH:
+ nBorderStyle = PBS_DASH;
+ dsBorder = CPWL_Dash(3, 3, 0);
+ break;
+ case BBS_BEVELED:
+ nBorderStyle = PBS_BEVELED;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,1);
+ crRightBottom = CPWL_Utils::DevideColor(crBackground,2);
+ break;
+ case BBS_INSET:
+ nBorderStyle = PBS_INSET;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75);
+ break;
+ case BBS_UNDERLINE:
+ nBorderStyle = PBS_UNDERLINED;
+ break;
+ default:
+ nBorderStyle = PBS_SOLID;
+ break;
+ }
+
+ CPDF_Rect rcWindow = GetRotatedRect();
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth);
+
+ CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
+ if (da.HasColor())
+ {
+ da.GetColor(iColorType, fc);
+ crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+ }
+
+ int32_t nStyle = 0;
+
+ CFX_WideString csWCaption = pControl->GetNormalCaption();
+ if (csWCaption.GetLength() > 0)
+ {
+ switch (csWCaption[0])
+ {
+ case L'l':
+ nStyle = PCS_CIRCLE;
+ break;
+ case L'8':
+ nStyle = PCS_CROSS;
+ break;
+ case L'u':
+ nStyle = PCS_DIAMOND;
+ break;
+ case L'n':
+ nStyle = PCS_SQUARE;
+ break;
+ case L'H':
+ nStyle = PCS_STAR;
+ break;
+ default: //L'4'
+ nStyle = PCS_CHECK;
+ break;
+ }
+ }
+ else
+ {
+ nStyle = PCS_CHECK;
+ }
+
+ CFX_ByteString csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackground) +
+ CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
+
+ CFX_ByteString csAP_N_OFF = csAP_N_ON;
+
+ switch (nBorderStyle)
+ {
+ case PBS_BEVELED:
+ {
+ CPWL_Color crTemp = crLeftTop;
+ crLeftTop = crRightBottom;
+ crRightBottom = crTemp;
+ }
+ break;
+ case PBS_INSET:
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
+ break;
+ }
+
+ CFX_ByteString csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) +
+ CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
+
+ CFX_ByteString csAP_D_OFF = csAP_D_ON;
+
+ csAP_N_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient,nStyle,crText);
+ csAP_D_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient,nStyle,crText);
+
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_ON, pControl->GetCheckedAPState());
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off");
+
+ WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl->GetCheckedAPState());
+ WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off");
+
+ CFX_ByteString csAS = GetAppState();
+ if (csAS.IsEmpty())
+ SetAppState("Off");
}
void CPDFSDK_Widget::ResetAppearance_RadioButton()
{
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
-
-
-
- CPWL_Color crBackground, crBorder, crText;
-
- int iColorType;
- FX_FLOAT fc[4];
-
- pControl->GetOriginalBackgroundColor(iColorType, fc);
- if (iColorType > 0)
- crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
-
- pControl->GetOriginalBorderColor(iColorType, fc);
- if (iColorType > 0)
- crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
-
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
- CPWL_Dash dsBorder(3,0,0);
- CPWL_Color crLeftTop,crRightBottom;
-
- switch (GetBorderStyle())
- {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
- dsBorder = CPWL_Dash(3, 3, 0);
- break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,1);
- crRightBottom = CPWL_Utils::DevideColor(crBackground,2);
- break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75);
- break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
- default:
- nBorderStyle = PBS_SOLID;
- break;
- }
-
- CPDF_Rect rcWindow = GetRotatedRect();
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth);
-
- CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
- if (da.HasColor())
- {
- da.GetColor(iColorType, fc);
- crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
- }
-
- int32_t nStyle = 0;
-
- CFX_WideString csWCaption = pControl->GetNormalCaption();
- if (csWCaption.GetLength() > 0)
- {
- switch (csWCaption[0])
- {
- default: //L'l':
- nStyle = PCS_CIRCLE;
- break;
- case L'8':
- nStyle = PCS_CROSS;
- break;
- case L'u':
- nStyle = PCS_DIAMOND;
- break;
- case L'n':
- nStyle = PCS_SQUARE;
- break;
- case L'H':
- nStyle = PCS_STAR;
- break;
- case L'4':
- nStyle = PCS_CHECK;
- break;
- }
- }
- else
- {
- nStyle = PCS_CIRCLE;
- }
-
- CFX_ByteString csAP_N_ON;
-
- CPDF_Rect rcCenter = CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f);
-
- if (nStyle == PCS_CIRCLE)
- {
- if (nBorderStyle == PBS_BEVELED)
- {
- crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
- crRightBottom = CPWL_Utils::SubstractColor(crBackground,0.25f);
- }
- else if (nBorderStyle == PBS_INSET)
- {
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5f);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75f);
- }
-
- csAP_N_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBackground) +
- CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
- }
- else
- {
- csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
- }
-
- CFX_ByteString csAP_N_OFF = csAP_N_ON;
-
- switch (nBorderStyle)
- {
- case PBS_BEVELED:
- {
- CPWL_Color crTemp = crLeftTop;
- crLeftTop = crRightBottom;
- crRightBottom = crTemp;
- }
- break;
- case PBS_INSET:
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
- break;
- }
-
- CFX_ByteString csAP_D_ON;
-
- if (nStyle == PCS_CIRCLE)
- {
- CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground,0.25f);
- if (nBorderStyle == PBS_BEVELED)
- {
- crLeftTop = CPWL_Utils::SubstractColor(crBackground,0.25f);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
- crBK = crBackground;
- }
- else if (nBorderStyle == PBS_INSET)
- {
- crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
- }
-
- csAP_D_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBK)
- + CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
- }
- else
- {
- csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) +
- CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
- }
-
- CFX_ByteString csAP_D_OFF = csAP_D_ON;
-
- csAP_N_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient,nStyle,crText);
- csAP_D_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient,nStyle,crText);
-
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_ON, pControl->GetCheckedAPState());
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off");
-
- WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl->GetCheckedAPState());
- WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off");
-
- CFX_ByteString csAS = GetAppState();
- if (csAS.IsEmpty())
- SetAppState("Off");
-}
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+
+
+
+ CPWL_Color crBackground, crBorder, crText;
+
+ int iColorType;
+ FX_FLOAT fc[4];
+
+ pControl->GetOriginalBackgroundColor(iColorType, fc);
+ if (iColorType > 0)
+ crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+
+ pControl->GetOriginalBorderColor(iColorType, fc);
+ if (iColorType > 0)
+ crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ int32_t nBorderStyle = 0;
+ CPWL_Dash dsBorder(3,0,0);
+ CPWL_Color crLeftTop,crRightBottom;
+
+ switch (GetBorderStyle())
+ {
+ case BBS_DASH:
+ nBorderStyle = PBS_DASH;
+ dsBorder = CPWL_Dash(3, 3, 0);
+ break;
+ case BBS_BEVELED:
+ nBorderStyle = PBS_BEVELED;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,1);
+ crRightBottom = CPWL_Utils::DevideColor(crBackground,2);
+ break;
+ case BBS_INSET:
+ nBorderStyle = PBS_INSET;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75);
+ break;
+ case BBS_UNDERLINE:
+ nBorderStyle = PBS_UNDERLINED;
+ break;
+ default:
+ nBorderStyle = PBS_SOLID;
+ break;
+ }
-void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue)
-{
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
- CPDF_FormField* pField = pControl->GetField();
- ASSERT(pField != NULL);
+ CPDF_Rect rcWindow = GetRotatedRect();
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth);
- CFX_ByteTextBuf sBody, sLines;
+ CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
+ if (da.HasColor())
+ {
+ da.GetColor(iColorType, fc);
+ crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+ }
- CPDF_Rect rcClient = GetClientRect();
- CPDF_Rect rcButton = rcClient;
- rcButton.left = rcButton.right - 13;
- rcButton.Normalize();
+ int32_t nStyle = 0;
+
+ CFX_WideString csWCaption = pControl->GetNormalCaption();
+ if (csWCaption.GetLength() > 0)
+ {
+ switch (csWCaption[0])
+ {
+ default: //L'l':
+ nStyle = PCS_CIRCLE;
+ break;
+ case L'8':
+ nStyle = PCS_CROSS;
+ break;
+ case L'u':
+ nStyle = PCS_DIAMOND;
+ break;
+ case L'n':
+ nStyle = PCS_SQUARE;
+ break;
+ case L'H':
+ nStyle = PCS_STAR;
+ break;
+ case L'4':
+ nStyle = PCS_CHECK;
+ break;
+ }
+ }
+ else
+ {
+ nStyle = PCS_CIRCLE;
+ }
- if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
- {
- pEdit->EnableRefresh(FALSE);
+ CFX_ByteString csAP_N_ON;
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- ASSERT(pDoc != NULL);
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap FontMap(this,pEnv->GetSysHandler());
- FontMap.Initial();
- pEdit->SetFontMap(&FontMap);
+ CPDF_Rect rcCenter = CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f);
- CPDF_Rect rcEdit = rcClient;
- rcEdit.right = rcButton.left;
- rcEdit.Normalize();
+ if (nStyle == PCS_CIRCLE)
+ {
+ if (nBorderStyle == PBS_BEVELED)
+ {
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
+ crRightBottom = CPWL_Utils::SubstractColor(crBackground,0.25f);
+ }
+ else if (nBorderStyle == PBS_INSET)
+ {
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5f);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75f);
+ }
- pEdit->SetPlateRect(rcEdit);
- pEdit->SetAlignmentV(1);
+ csAP_N_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBackground) +
+ CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
+ }
+ else
+ {
+ csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackground) +
+ CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
+ }
- FX_FLOAT fFontSize = GetFontSize();
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
+ CFX_ByteString csAP_N_OFF = csAP_N_ON;
- pEdit->Initialize();
+ switch (nBorderStyle)
+ {
+ case PBS_BEVELED:
+ {
+ CPWL_Color crTemp = crLeftTop;
+ crLeftTop = crRightBottom;
+ crRightBottom = crTemp;
+ }
+ break;
+ case PBS_INSET:
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
+ break;
+ }
- if (sValue)
- pEdit->SetText(sValue);
- else
- {
- int32_t nCurSel = pField->GetSelectedIndex(0);
+ CFX_ByteString csAP_D_ON;
- if (nCurSel < 0)
- pEdit->SetText(pField->GetValue().c_str());
- else
- pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str());
- }
+ if (nStyle == PCS_CIRCLE)
+ {
+ CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground,0.25f);
+ if (nBorderStyle == PBS_BEVELED)
+ {
+ crLeftTop = CPWL_Utils::SubstractColor(crBackground,0.25f);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
+ crBK = crBackground;
+ }
+ else if (nBorderStyle == PBS_INSET)
+ {
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY,0);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY,1);
+ }
- CPDF_Rect rcContent = pEdit->GetContentRect();
+ csAP_D_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBK)
+ + CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
+ }
+ else
+ {
+ csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) +
+ CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder);
+ }
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,0.0f));
- if (sEdit.GetLength() > 0)
- {
- sBody << "/Tx BMC\n" << "q\n";
- if (rcContent.Width() > rcEdit.Width() ||
- rcContent.Height() > rcEdit.Height())
- {
- sBody << rcEdit.left << " " << rcEdit.bottom << " "
- << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n";
- }
+ CFX_ByteString csAP_D_OFF = csAP_D_ON;
- CPWL_Color crText = GetTextPWLColor();
- sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n" << "Q\nEMC\n";
- }
+ csAP_N_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient,nStyle,crText);
+ csAP_D_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient,nStyle,crText);
- IFX_Edit::DelEdit(pEdit);
- }
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_ON, pControl->GetCheckedAPState());
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off");
- sBody << CPWL_Utils::GetDropButtonAppStream(rcButton);
+ WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl->GetCheckedAPState());
+ WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off");
- CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + sLines.GetByteString() + sBody.GetByteString();
+ CFX_ByteString csAS = GetAppState();
+ if (csAS.IsEmpty())
+ SetAppState("Off");
+}
+
+void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue)
+{
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+ CPDF_FormField* pField = pControl->GetField();
+ ASSERT(pField != NULL);
+
+ CFX_ByteTextBuf sBody, sLines;
+
+ CPDF_Rect rcClient = GetClientRect();
+ CPDF_Rect rcButton = rcClient;
+ rcButton.left = rcButton.right - 13;
+ rcButton.Normalize();
+
+ if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
+ {
+ pEdit->EnableRefresh(FALSE);
+
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ ASSERT(pDoc != NULL);
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+ CBA_FontMap FontMap(this,pEnv->GetSysHandler());
+ FontMap.Initial();
+ pEdit->SetFontMap(&FontMap);
+
+ CPDF_Rect rcEdit = rcClient;
+ rcEdit.right = rcButton.left;
+ rcEdit.Normalize();
+
+ pEdit->SetPlateRect(rcEdit);
+ pEdit->SetAlignmentV(1);
+
+ FX_FLOAT fFontSize = GetFontSize();
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
+
+ pEdit->Initialize();
+
+ if (sValue)
+ pEdit->SetText(sValue);
+ else
+ {
+ int32_t nCurSel = pField->GetSelectedIndex(0);
+
+ if (nCurSel < 0)
+ pEdit->SetText(pField->GetValue().c_str());
+ else
+ pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str());
+ }
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
+ CPDF_Rect rcContent = pEdit->GetContentRect();
+
+ CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,0.0f));
+ if (sEdit.GetLength() > 0)
+ {
+ sBody << "/Tx BMC\n" << "q\n";
+ if (rcContent.Width() > rcEdit.Width() ||
+ rcContent.Height() > rcEdit.Height())
+ {
+ sBody << rcEdit.left << " " << rcEdit.bottom << " "
+ << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n";
+ }
+
+ CPWL_Color crText = GetTextPWLColor();
+ sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n" << "Q\nEMC\n";
+ }
+
+ IFX_Edit::DelEdit(pEdit);
+ }
+
+ sBody << CPWL_Utils::GetDropButtonAppStream(rcButton);
+
+ CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + sLines.GetByteString() + sBody.GetByteString();
+
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
void CPDFSDK_Widget::ResetAppearance_ListBox()
{
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
- CPDF_FormField* pField = pControl->GetField();
- ASSERT(pField != NULL);
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+ CPDF_FormField* pField = pControl->GetField();
+ ASSERT(pField != NULL);
- CPDF_Rect rcClient = GetClientRect();
+ CPDF_Rect rcClient = GetClientRect();
- CFX_ByteTextBuf sBody, sLines;
+ CFX_ByteTextBuf sBody, sLines;
- if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
- {
- pEdit->EnableRefresh(FALSE);
+ if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
+ {
+ pEdit->EnableRefresh(FALSE);
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- ASSERT(pDoc != NULL);
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ ASSERT(pDoc != NULL);
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap FontMap(this,pEnv->GetSysHandler());
- FontMap.Initial();
- pEdit->SetFontMap(&FontMap);
+ CBA_FontMap FontMap(this,pEnv->GetSysHandler());
+ FontMap.Initial();
+ pEdit->SetFontMap(&FontMap);
- pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,0.0f));
+ pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,0.0f));
- FX_FLOAT fFontSize = GetFontSize();
+ FX_FLOAT fFontSize = GetFontSize();
- if (IsFloatZero(fFontSize))
- pEdit->SetFontSize(12.0f);
- else
- pEdit->SetFontSize(fFontSize);
+ if (IsFloatZero(fFontSize))
+ pEdit->SetFontSize(12.0f);
+ else
+ pEdit->SetFontSize(fFontSize);
- pEdit->Initialize();
+ pEdit->Initialize();
- CFX_ByteTextBuf sList;
- FX_FLOAT fy = rcClient.top;
+ CFX_ByteTextBuf sList;
+ FX_FLOAT fy = rcClient.top;
- int32_t nTop = pField->GetTopVisibleIndex();
- int32_t nCount = pField->CountOptions();
- int32_t nSelCount = pField->CountSelectedItems();
+ int32_t nTop = pField->GetTopVisibleIndex();
+ int32_t nCount = pField->CountOptions();
+ int32_t nSelCount = pField->CountSelectedItems();
- for (int32_t i=nTop; i<nCount; i++)
- {
- FX_BOOL bSelected = FALSE;
- for (int32_t j=0; j<nSelCount; j++)
- {
- if (pField->GetSelectedIndex(j) == i)
- {
- bSelected = TRUE;
- break;
- }
- }
+ for (int32_t i=nTop; i<nCount; i++)
+ {
+ FX_BOOL bSelected = FALSE;
+ for (int32_t j=0; j<nSelCount; j++)
+ {
+ if (pField->GetSelectedIndex(j) == i)
+ {
+ bSelected = TRUE;
+ break;
+ }
+ }
- pEdit->SetText(pField->GetOptionLabel(i).c_str());
+ pEdit->SetText(pField->GetOptionLabel(i).c_str());
- CPDF_Rect rcContent = pEdit->GetContentRect();
- FX_FLOAT fItemHeight = rcContent.Height();
+ CPDF_Rect rcContent = pEdit->GetContentRect();
+ FX_FLOAT fItemHeight = rcContent.Height();
- if (bSelected)
- {
- CPDF_Rect rcItem = CPDF_Rect(rcClient.left,fy-fItemHeight,rcClient.right,fy);
- sList << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB,0,51.0f/255.0f,113.0f/255.0f),TRUE)
- << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n";
+ if (bSelected)
+ {
+ CPDF_Rect rcItem = CPDF_Rect(rcClient.left,fy-fItemHeight,rcClient.right,fy);
+ sList << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB,0,51.0f/255.0f,113.0f/255.0f),TRUE)
+ << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n";
- sList << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY,1),TRUE) <<
- CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n";
- }
- else
- {
- CPWL_Color crText = GetTextPWLColor();
- sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) <<
- CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n";
- }
+ sList << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY,1),TRUE) <<
+ CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n";
+ }
+ else
+ {
+ CPWL_Color crText = GetTextPWLColor();
+ sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) <<
+ CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n";
+ }
- fy -= fItemHeight;
- }
+ fy -= fItemHeight;
+ }
- if (sList.GetSize() > 0)
- {
- sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
- sBody << sList << "Q\nEMC\n";
- }
+ if (sList.GetSize() > 0)
+ {
+ sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " << rcClient.bottom << " "
+ << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
+ sBody << sList << "Q\nEMC\n";
+ }
- IFX_Edit::DelEdit(pEdit);
- }
+ IFX_Edit::DelEdit(pEdit);
+ }
- CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + sLines.GetByteString() + sBody.GetByteString();
+ CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + sLines.GetByteString() + sBody.GetByteString();
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue)
{
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
- CPDF_FormField* pField = pControl->GetField();
- ASSERT(pField != NULL);
-
- CFX_ByteTextBuf sBody, sLines;
-
- if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
- {
- pEdit->EnableRefresh(FALSE);
-
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- ASSERT(pDoc != NULL);
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
-
- CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSystemHandler(m_pBaseForm->GetEnv()));
- FontMap.Initial();
- pEdit->SetFontMap(&FontMap);
-
- CPDF_Rect rcClient = GetClientRect();
- pEdit->SetPlateRect(rcClient);
- pEdit->SetAlignmentH(pControl->GetControlAlignment());
-
- FX_DWORD dwFieldFlags = pField->GetFieldFlags();
- FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1;
-
- if (bMultiLine)
- {
- pEdit->SetMultiLine(TRUE);
- pEdit->SetAutoReturn(TRUE);
- }
- else
- {
- pEdit->SetAlignmentV(1);
- }
-
- FX_WORD subWord = 0;
- if ((dwFieldFlags >> 13) & 1)
- {
- subWord = '*';
- pEdit->SetPasswordChar(subWord);
- }
-
- int nMaxLen = pField->GetMaxLen();
- FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1;
- FX_FLOAT fFontSize = GetFontSize();
-
- if (nMaxLen > 0)
- {
- if (bCharArray)
- {
- pEdit->SetCharArray(nMaxLen);
-
- if (IsFloatZero(fFontSize))
- {
- fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetPDFFont(0),rcClient,nMaxLen);
- }
- }
- else
- {
- if (sValue)
- nMaxLen = wcslen((const wchar_t*)sValue);
- pEdit->SetLimitChar(nMaxLen);
- }
- }
-
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
-
- if (sValue)
- pEdit->SetText(sValue);
- else
- pEdit->SetText(pField->GetValue().c_str());
-
- CPDF_Rect rcContent = pEdit->GetContentRect();
-
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,0.0f),
- NULL,!bCharArray,subWord);
-
- if (sEdit.GetLength() > 0)
- {
- sBody << "/Tx BMC\n" << "q\n";
- if (rcContent.Width() > rcClient.Width() ||
- rcContent.Height() > rcClient.Height())
- {
- sBody << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
- }
- CPWL_Color crText = GetTextPWLColor();
- sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n" << "Q\nEMC\n";
- }
-
- if (bCharArray)
- {
- switch (GetBorderStyle())
- {
- case BBS_SOLID:
- {
- CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE);
- if (sColor.GetLength() > 0)
- {
- sLines << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE) << " 2 J 0 j\n";
-
- for (int32_t i=1;i<nMaxLen;i++)
- {
- sLines << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
- << rcClient.bottom << " m\n"
- << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
- << rcClient.top << " l S\n";
- }
-
- sLines << "Q\n";
- }
- }
- break;
- case BBS_DASH:
- {
- CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE);
- if (sColor.GetLength() > 0)
- {
- CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0);
-
- sLines << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE)
- << "[" << dsBorder.nDash << " "
- << dsBorder.nGap << "] "
- << dsBorder.nPhase << " d\n";
-
- for (int32_t i=1;i<nMaxLen;i++)
- {
- sLines << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
- << rcClient.bottom << " m\n"
- << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
- << rcClient.top << " l S\n";
- }
-
- sLines << "Q\n";
- }
- }
- break;
- }
- }
-
- IFX_Edit::DelEdit(pEdit);
- }
-
- CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + sLines.GetByteString() + sBody.GetByteString();
- WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+ CPDF_FormField* pField = pControl->GetField();
+ ASSERT(pField != NULL);
+
+ CFX_ByteTextBuf sBody, sLines;
+
+ if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
+ {
+ pEdit->EnableRefresh(FALSE);
+
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ ASSERT(pDoc != NULL);
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+
+ CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSystemHandler(m_pBaseForm->GetEnv()));
+ FontMap.Initial();
+ pEdit->SetFontMap(&FontMap);
+
+ CPDF_Rect rcClient = GetClientRect();
+ pEdit->SetPlateRect(rcClient);
+ pEdit->SetAlignmentH(pControl->GetControlAlignment());
+
+ FX_DWORD dwFieldFlags = pField->GetFieldFlags();
+ FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1;
+
+ if (bMultiLine)
+ {
+ pEdit->SetMultiLine(TRUE);
+ pEdit->SetAutoReturn(TRUE);
+ }
+ else
+ {
+ pEdit->SetAlignmentV(1);
+ }
+
+ FX_WORD subWord = 0;
+ if ((dwFieldFlags >> 13) & 1)
+ {
+ subWord = '*';
+ pEdit->SetPasswordChar(subWord);
+ }
+
+ int nMaxLen = pField->GetMaxLen();
+ FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1;
+ FX_FLOAT fFontSize = GetFontSize();
+
+ if (nMaxLen > 0)
+ {
+ if (bCharArray)
+ {
+ pEdit->SetCharArray(nMaxLen);
+
+ if (IsFloatZero(fFontSize))
+ {
+ fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetPDFFont(0),rcClient,nMaxLen);
+ }
+ }
+ else
+ {
+ if (sValue)
+ nMaxLen = wcslen((const wchar_t*)sValue);
+ pEdit->SetLimitChar(nMaxLen);
+ }
+ }
+
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
+
+ pEdit->Initialize();
+
+ if (sValue)
+ pEdit->SetText(sValue);
+ else
+ pEdit->SetText(pField->GetValue().c_str());
+
+ CPDF_Rect rcContent = pEdit->GetContentRect();
+
+ CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,0.0f),
+ NULL,!bCharArray,subWord);
+
+ if (sEdit.GetLength() > 0)
+ {
+ sBody << "/Tx BMC\n" << "q\n";
+ if (rcContent.Width() > rcClient.Width() ||
+ rcContent.Height() > rcClient.Height())
+ {
+ sBody << rcClient.left << " " << rcClient.bottom << " "
+ << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
+ }
+ CPWL_Color crText = GetTextPWLColor();
+ sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n" << "Q\nEMC\n";
+ }
+
+ if (bCharArray)
+ {
+ switch (GetBorderStyle())
+ {
+ case BBS_SOLID:
+ {
+ CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE);
+ if (sColor.GetLength() > 0)
+ {
+ sLines << "q\n" << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE) << " 2 J 0 j\n";
+
+ for (int32_t i=1;i<nMaxLen;i++)
+ {
+ sLines << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
+ << rcClient.bottom << " m\n"
+ << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
+ << rcClient.top << " l S\n";
+ }
+
+ sLines << "Q\n";
+ }
+ }
+ break;
+ case BBS_DASH:
+ {
+ CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE);
+ if (sColor.GetLength() > 0)
+ {
+ CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0);
+
+ sLines << "q\n" << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE)
+ << "[" << dsBorder.nDash << " "
+ << dsBorder.nGap << "] "
+ << dsBorder.nPhase << " d\n";
+
+ for (int32_t i=1;i<nMaxLen;i++)
+ {
+ sLines << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
+ << rcClient.bottom << " m\n"
+ << rcClient.left + ((rcClient.right - rcClient.left)/nMaxLen)*i << " "
+ << rcClient.top << " l S\n";
+ }
+
+ sLines << "Q\n";
+ }
+ }
+ break;
+ }
+ }
+
+ IFX_Edit::DelEdit(pEdit);
+ }
+
+ CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + sLines.GetByteString() + sBody.GetByteString();
+ WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
CPDF_Rect CPDFSDK_Widget::GetClientRect() const
{
- CPDF_Rect rcWindow = GetRotatedRect();
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- switch (GetBorderStyle())
- {
- case BBS_BEVELED:
- case BBS_INSET:
- fBorderWidth *= 2.0f;
- break;
- }
+ CPDF_Rect rcWindow = GetRotatedRect();
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ switch (GetBorderStyle())
+ {
+ case BBS_BEVELED:
+ case BBS_INSET:
+ fBorderWidth *= 2.0f;
+ break;
+ }
- return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth);
+ return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth);
}
CPDF_Rect CPDFSDK_Widget::GetRotatedRect() const
{
- CPDF_Rect rectAnnot = GetRect();
- FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
- FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
-
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
-
- CPDF_Rect rcPDFWindow;
- switch(abs(pControl->GetRotation() % 360))
- {
- case 0:
- case 180:
- default:
- rcPDFWindow = CPDF_Rect(0, 0, fWidth, fHeight);
- break;
- case 90:
- case 270:
- rcPDFWindow = CPDF_Rect(0, 0, fHeight, fWidth);
- break;
- }
+ CPDF_Rect rectAnnot = GetRect();
+ FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
+ FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
+
+ CPDF_FormControl* pControl = GetFormControl();
+ CPDF_Rect rcPDFWindow;
+ switch(abs(pControl->GetRotation() % 360))
+ {
+ case 0:
+ case 180:
+ default:
+ rcPDFWindow = CPDF_Rect(0, 0, fWidth, fHeight);
+ break;
+ case 90:
+ case 270:
+ rcPDFWindow = CPDF_Rect(0, 0, fHeight, fWidth);
+ break;
+ }
- return rcPDFWindow;
+ return rcPDFWindow;
}
CFX_ByteString CPDFSDK_Widget::GetBackgroundAppStream() const
{
- CPWL_Color crBackground = GetFillPWLColor();
- if (crBackground.nColorType != COLORTYPE_TRANSPARENT)
- return CPWL_Utils::GetRectFillAppStream(GetRotatedRect(), crBackground);
- else
- return "";
+ CPWL_Color crBackground = GetFillPWLColor();
+ if (crBackground.nColorType != COLORTYPE_TRANSPARENT) {
+ return CPWL_Utils::GetRectFillAppStream(GetRotatedRect(), crBackground);
+ }
+ return "";
}
CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const
{
- CPDF_Rect rcWindow = GetRotatedRect();
- CPWL_Color crBorder = GetBorderPWLColor();
- CPWL_Color crBackground = GetFillPWLColor();
- CPWL_Color crLeftTop, crRightBottom;
-
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
- CPWL_Dash dsBorder(3,0,0);
-
- switch (GetBorderStyle())
- {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
- dsBorder = CPWL_Dash(3, 3, 0);
- break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
- crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
- break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
- fBorderWidth *= 2;
- crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
- crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
- break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
- default:
- nBorderStyle = PBS_SOLID;
- break;
- }
-
- return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop,
- crRightBottom, nBorderStyle, dsBorder);
+ CPDF_Rect rcWindow = GetRotatedRect();
+ CPWL_Color crBorder = GetBorderPWLColor();
+ CPWL_Color crBackground = GetFillPWLColor();
+ CPWL_Color crLeftTop, crRightBottom;
+
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ int32_t nBorderStyle = 0;
+ CPWL_Dash dsBorder(3,0,0);
+
+ switch (GetBorderStyle())
+ {
+ case BBS_DASH:
+ nBorderStyle = PBS_DASH;
+ dsBorder = CPWL_Dash(3, 3, 0);
+ break;
+ case BBS_BEVELED:
+ nBorderStyle = PBS_BEVELED;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
+ crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
+ break;
+ case BBS_INSET:
+ nBorderStyle = PBS_INSET;
+ fBorderWidth *= 2;
+ crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
+ crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
+ break;
+ case BBS_UNDERLINE:
+ nBorderStyle = PBS_UNDERLINED;
+ break;
+ default:
+ nBorderStyle = PBS_SOLID;
+ break;
+ }
+
+ return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder);
}
CPDF_Matrix CPDFSDK_Widget::GetMatrix() const
{
- CPDF_Matrix mt;
- CPDF_FormControl* pControl = GetFormControl();
- ASSERT(pControl != NULL);
-
- CPDF_Rect rcAnnot = GetRect();
- FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left;
- FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom;
-
-
-
- switch (abs(pControl->GetRotation() % 360))
- {
- case 0:
- default:
- mt = CPDF_Matrix(1, 0, 0, 1, 0, 0);
- break;
- case 90:
- mt = CPDF_Matrix(0, 1, -1, 0, fWidth, 0);
- break;
- case 180:
- mt = CPDF_Matrix(-1, 0, 0, -1, fWidth, fHeight);
- break;
- case 270:
- mt = CPDF_Matrix(0, -1, 1, 0, 0, fHeight);
- break;
- }
+ CPDF_Matrix mt;
+ CPDF_FormControl* pControl = GetFormControl();
+ ASSERT(pControl != NULL);
+
+ CPDF_Rect rcAnnot = GetRect();
+ FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left;
+ FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom;
+
+
+
+ switch (abs(pControl->GetRotation() % 360))
+ {
+ case 0:
+ default:
+ mt = CPDF_Matrix(1, 0, 0, 1, 0, 0);
+ break;
+ case 90:
+ mt = CPDF_Matrix(0, 1, -1, 0, fWidth, 0);
+ break;
+ case 180:
+ mt = CPDF_Matrix(-1, 0, 0, -1, fWidth, fHeight);
+ break;
+ case 270:
+ mt = CPDF_Matrix(0, -1, 1, 0, 0, fHeight);
+ break;
+ }
- return mt;
+ return mt;
}
CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const
{
- CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0);
+ CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0);
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance();
- if (da.HasColor())
- {
- int32_t iColorType;
- FX_FLOAT fc[4];
- da.GetColor(iColorType, fc);
- crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
- }
+ CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance();
+ if (da.HasColor())
+ {
+ int32_t iColorType;
+ FX_FLOAT fc[4];
+ da.GetColor(iColorType, fc);
+ crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+ }
- return crText;
+ return crText;
}
CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const
{
- CPWL_Color crBorder;
+ CPWL_Color crBorder;
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- int32_t iColorType;
- FX_FLOAT fc[4];
- pFormCtrl->GetOriginalBorderColor(iColorType, fc);
- if (iColorType > 0)
- crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+ int32_t iColorType;
+ FX_FLOAT fc[4];
+ pFormCtrl->GetOriginalBorderColor(iColorType, fc);
+ if (iColorType > 0)
+ crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
- return crBorder;
+ return crBorder;
}
CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const
{
- CPWL_Color crFill;
+ CPWL_Color crFill;
- CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
- int32_t iColorType;
- FX_FLOAT fc[4];
- pFormCtrl->GetOriginalBackgroundColor(iColorType, fc);
- if (iColorType > 0)
- crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
+ int32_t iColorType;
+ FX_FLOAT fc[4];
+ pFormCtrl->GetOriginalBackgroundColor(iColorType, fc);
+ if (iColorType > 0)
+ crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
- return crFill;
+ return crFill;
}
void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage)
{
- ASSERT(pImage != NULL);
+ ASSERT(pImage != NULL);
- CPDF_Document* pDoc = m_pPageView->GetPDFDocument();//pDocument->GetDocument();
- ASSERT(pDoc != NULL);
+ CPDF_Document* pDoc = m_pPageView->GetPDFDocument();//pDocument->GetDocument();
+ ASSERT(pDoc != NULL);
- CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
- ASSERT(pAPDict != NULL);
+ CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
+ ASSERT(pAPDict != NULL);
- CPDF_Stream* pStream = pAPDict->GetStream(sAPType);
- ASSERT(pStream != NULL);
+ CPDF_Stream* pStream = pAPDict->GetStream(sAPType);
+ ASSERT(pStream != NULL);
- CPDF_Dictionary* pStreamDict = pStream->GetDict();
- ASSERT(pStreamDict != NULL);
+ CPDF_Dictionary* pStreamDict = pStream->GetDict();
+ ASSERT(pStreamDict != NULL);
- CFX_ByteString sImageAlias = "IMG";
+ CFX_ByteString sImageAlias = "IMG";
- if (CPDF_Dictionary* pImageDict = pImage->GetDict())
- {
- sImageAlias = pImageDict->GetString("Name");
- if (sImageAlias.IsEmpty())
- sImageAlias = "IMG";
- }
+ if (CPDF_Dictionary* pImageDict = pImage->GetDict())
+ {
+ sImageAlias = pImageDict->GetString("Name");
+ if (sImageAlias.IsEmpty())
+ sImageAlias = "IMG";
+ }
- CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources");
- if (!pStreamResList)
- {
- pStreamResList = new CPDF_Dictionary();
- pStreamDict->SetAt("Resources", pStreamResList);
- }
+ CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources");
+ if (!pStreamResList)
+ {
+ pStreamResList = new CPDF_Dictionary();
+ pStreamDict->SetAt("Resources", pStreamResList);
+ }
- if (pStreamResList)
- {
- CPDF_Dictionary* pXObject = new CPDF_Dictionary;
- pXObject->SetAtReference(sImageAlias, pDoc, pImage);
- pStreamResList->SetAt("XObject", pXObject);
- }
+ if (pStreamResList)
+ {
+ CPDF_Dictionary* pXObject = new CPDF_Dictionary;
+ pXObject->SetAtReference(sImageAlias, pDoc, pImage);
+ pStreamResList->SetAt("XObject", pXObject);
+ }
}
void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType)
{
- if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"))
- {
- pAPDict->RemoveAt(sAPType);
- }
+ if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"))
+ {
+ pAPDict->RemoveAt(sAPType);
+ }
}
FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, CPDFSDK_PageView* pPageView)
{
- CPDF_Action action = GetAAction(type);
-
- if (action && action.GetType() != CPDF_Action::Unknown)
- {
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- ASSERT(pDocument != NULL);
+ CPDF_Action action = GetAAction(type);
- CPDFDoc_Environment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv != NULL);
+ if (action && action.GetType() != CPDF_Action::Unknown)
+ {
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
- CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();/*(CPDFSDK_ActionHandler*)pApp->GetActionHandler();*/
- ASSERT(pActionHandler != NULL);
+ CPDFDoc_Environment* pEnv = pDocument->GetEnv();
+ ASSERT(pEnv != NULL);
- return pActionHandler->DoAction_Field(action, type, pDocument, GetFormField(), data);
- }
+ CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();/*(CPDFSDK_ActionHandler*)pApp->GetActionHandler();*/
+ ASSERT(pActionHandler != NULL);
- return FALSE;
-}
-
-CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT)
-{
- switch (eAAT)
- {
- case CPDF_AAction::CursorEnter:
- case CPDF_AAction::CursorExit:
- case CPDF_AAction::ButtonDown:
- case CPDF_AAction::ButtonUp:
- case CPDF_AAction::GetFocus:
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::PageOpen:
- case CPDF_AAction::PageClose:
- case CPDF_AAction::PageVisible:
- case CPDF_AAction::PageInvisible:
- return CPDFSDK_Annot::GetAAction(eAAT);
-
- case CPDF_AAction::KeyStroke:
- case CPDF_AAction::Format:
- case CPDF_AAction::Validate:
- case CPDF_AAction::Calculate:
- {
- CPDF_FormField* pField = GetFormField();
- if (CPDF_AAction aa = pField->GetAdditionalAction())
- return aa.GetAction(eAAT);
+ return pActionHandler->DoAction_Field(action, type, pDocument, GetFormField(), data);
+ }
- return CPDFSDK_Annot::GetAAction(eAAT);
- }
- default:
- break;
- }
+ return FALSE;
+}
+
+CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT)
+{
+ switch (eAAT)
+ {
+ case CPDF_AAction::CursorEnter:
+ case CPDF_AAction::CursorExit:
+ case CPDF_AAction::ButtonDown:
+ case CPDF_AAction::ButtonUp:
+ case CPDF_AAction::GetFocus:
+ case CPDF_AAction::LoseFocus:
+ case CPDF_AAction::PageOpen:
+ case CPDF_AAction::PageClose:
+ case CPDF_AAction::PageVisible:
+ case CPDF_AAction::PageInvisible:
+ return CPDFSDK_Annot::GetAAction(eAAT);
+
+ case CPDF_AAction::KeyStroke:
+ case CPDF_AAction::Format:
+ case CPDF_AAction::Validate:
+ case CPDF_AAction::Calculate:
+ {
+ CPDF_FormField* pField = GetFormField();
+ if (CPDF_AAction aa = pField->GetAdditionalAction())
+ return aa.GetAction(eAAT);
+
+ return CPDFSDK_Annot::GetAAction(eAAT);
+ }
+ default:
+ break;
+ }
- return CPDF_Action();
+ return CPDF_Action();
}
CFX_WideString CPDFSDK_Widget::GetAlternateName() const
{
- CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
- return pFormField->GetAlternateName();
+ return pFormField->GetAlternateName();
}
-int32_t CPDFSDK_Widget::GetAppearanceAge() const
+int32_t CPDFSDK_Widget::GetAppearanceAge() const
{
- return m_nAppAge;
+ return m_nAppAge;
}
int32_t CPDFSDK_Widget::GetValueAge() const
{
- return m_nValueAge;
+ return m_nValueAge;
}
-FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY)
+FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY)
{
- CPDF_Annot* pAnnot = GetPDFAnnot();
- CFX_FloatRect annotRect;
- pAnnot->GetRect(annotRect);
- if(annotRect.Contains(pageX, pageY))
- {
- if (!IsVisible()) return FALSE;
+ CPDF_Annot* pAnnot = GetPDFAnnot();
+ CFX_FloatRect annotRect;
+ pAnnot->GetRect(annotRect);
+ if(annotRect.Contains(pageX, pageY))
+ {
+ if (!IsVisible()) return FALSE;
- int nFieldFlags = GetFieldFlags();
- if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
- return FALSE;
+ int nFieldFlags = GetFieldFlags();
+ if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
+ return FALSE;
- return TRUE;
- }
- return FALSE;
+ return TRUE;
+ }
+ return FALSE;
}
CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
- :m_pDocument(pDocument),
- m_pInterForm(NULL),
- m_bCalculate(TRUE),
- m_bBusy(FALSE)
+ :m_pDocument(pDocument),
+ m_pInterForm(NULL),
+ m_bCalculate(TRUE),
+ m_bBusy(FALSE)
{
- ASSERT(m_pDocument != NULL);
- m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), FALSE);
- ASSERT(m_pInterForm != NULL);
- m_pInterForm->SetFormNotify(this);
+ ASSERT(m_pDocument != NULL);
+ m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), FALSE);
+ ASSERT(m_pInterForm != NULL);
+ m_pInterForm->SetFormNotify(this);
- for(int i=0; i<6; i++)
- m_bNeedHightlight[i] = FALSE;
- m_iHighlightAlpha = 0;
+ for(int i=0; i<6; i++)
+ m_bNeedHightlight[i] = FALSE;
+ m_iHighlightAlpha = 0;
}
CPDFSDK_InterForm::~CPDFSDK_InterForm()
@@ -1673,7 +1667,7 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm()
FX_BOOL CPDFSDK_InterForm::HighlightWidgets()
{
- return FALSE;
+ return FALSE;
}
CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const
@@ -1725,57 +1719,57 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const
void CPDFSDK_InterForm::GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets)
{
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pInterForm != NULL);
- for (int i=0,sz=m_pInterForm->CountFields(sFieldName); i<sz; i++)
- {
- CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName);
- ASSERT(pFormField != NULL);
+ for (int i=0,sz=m_pInterForm->CountFields(sFieldName); i<sz; i++)
+ {
+ CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName);
+ ASSERT(pFormField != NULL);
- GetWidgets(pFormField, widgets);
- }
+ GetWidgets(pFormField, widgets);
+ }
}
void CPDFSDK_InterForm::GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets)
{
- ASSERT(pField != NULL);
+ ASSERT(pField != NULL);
- for (int i=0,isz=pField->CountControls(); i<isz; i++)
- {
- CPDF_FormControl* pFormCtrl = pField->GetControl(i);
- ASSERT(pFormCtrl != NULL);
+ for (int i=0,isz=pField->CountControls(); i<isz; i++)
+ {
+ CPDF_FormControl* pFormCtrl = pField->GetControl(i);
+ ASSERT(pFormCtrl != NULL);
- CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl);
+ CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl);
- if (pWidget)
- widgets.Add(pWidget);
- }
+ if (pWidget)
+ widgets.Add(pWidget);
+ }
}
int CPDFSDK_InterForm::GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const
{
- ASSERT(pDocument != NULL);
- ASSERT(pAnnotDict != NULL);
-
- for (int i=0,sz=pDocument->GetPageCount(); i<sz; i++)
- {
- if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i))
- {
- if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots"))
- {
- for (int j=0,jsz=pAnnots->GetCount(); j<jsz; j++)
- {
- CPDF_Object* pDict = pAnnots->GetElementValue(j);
- if (pAnnotDict == pDict)
- {
- return i;
- }
- }
- }
- }
- }
-
- return -1;
+ ASSERT(pDocument != NULL);
+ ASSERT(pAnnotDict != NULL);
+
+ for (int i=0,sz=pDocument->GetPageCount(); i<sz; i++)
+ {
+ if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i))
+ {
+ if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots"))
+ {
+ for (int j=0,jsz=pAnnots->GetCount(); j<jsz; j++)
+ {
+ CPDF_Object* pDict = pAnnots->GetElementValue(j);
+ if (pAnnotDict == pDict)
+ {
+ return i;
+ }
+ }
+ }
+ }
+ }
+
+ return -1;
}
void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget)
@@ -1790,772 +1784,726 @@ void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl)
void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled)
{
- m_bCalculate = bEnabled;
+ m_bCalculate = bEnabled;
}
FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const
{
- return m_bCalculate;
+ return m_bCalculate;
}
#ifdef _WIN32
CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile)
{
- ASSERT(m_pDocument != NULL);
- CPDF_Document* pDocument = m_pDocument->GetDocument();
- ASSERT(pDocument != NULL);
-
- CPDF_Stream* pRetStream = NULL;
-
- if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str()))
- {
- int nWidth = pBmp->GetWidth();
- int nHeight = pBmp->GetHeight();
-
- CPDF_Image Image(pDocument);
- Image.SetImage(pBmp, FALSE);
- CPDF_Stream* pImageStream = Image.GetStream();
- if (pImageStream)
- {
- if (pImageStream->GetObjNum() == 0)
- pDocument->AddIndirectObject(pImageStream);
-
- CPDF_Dictionary* pStreamDict = new CPDF_Dictionary();
- pStreamDict->SetAtName("Subtype", "Form");
- pStreamDict->SetAtName("Name", "IMG");
- CPDF_Array* pMatrix = new CPDF_Array();
- pStreamDict->SetAt("Matrix", pMatrix);
- pMatrix->AddInteger(1);
- pMatrix->AddInteger(0);
- pMatrix->AddInteger(0);
- pMatrix->AddInteger(1);
- pMatrix->AddInteger(-nWidth / 2);
- pMatrix->AddInteger(-nHeight / 2);
- CPDF_Dictionary* pResource = new CPDF_Dictionary();
- pStreamDict->SetAt("Resources", pResource);
- CPDF_Dictionary* pXObject = new CPDF_Dictionary();
- pResource->SetAt("XObject", pXObject);
- pXObject->SetAtReference("Img", pDocument, pImageStream);
- CPDF_Array* pProcSet = new CPDF_Array();
- pResource->SetAt("ProcSet", pProcSet);
- pProcSet->AddName("PDF");
- pProcSet->AddName("ImageC");
- pStreamDict->SetAtName("Type", "XObject");
- CPDF_Array* pBBox = new CPDF_Array();
- pStreamDict->SetAt("BBox", pBBox);
- pBBox->AddInteger(0);
- pBBox->AddInteger(0);
- pBBox->AddInteger(nWidth);
- pBBox->AddInteger(nHeight);
- pStreamDict->SetAtInteger("FormType", 1);
-
- pRetStream = new CPDF_Stream(NULL, 0, NULL);
- CFX_ByteString csStream;
- csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight);
- pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(), pStreamDict);
- pDocument->AddIndirectObject(pRetStream);
- }
-
- delete pBmp;
- }
-
- return pRetStream;
+ ASSERT(m_pDocument != NULL);
+ CPDF_Document* pDocument = m_pDocument->GetDocument();
+ ASSERT(pDocument != NULL);
+
+ CPDF_Stream* pRetStream = NULL;
+
+ if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str()))
+ {
+ int nWidth = pBmp->GetWidth();
+ int nHeight = pBmp->GetHeight();
+
+ CPDF_Image Image(pDocument);
+ Image.SetImage(pBmp, FALSE);
+ CPDF_Stream* pImageStream = Image.GetStream();
+ if (pImageStream)
+ {
+ if (pImageStream->GetObjNum() == 0)
+ pDocument->AddIndirectObject(pImageStream);
+
+ CPDF_Dictionary* pStreamDict = new CPDF_Dictionary();
+ pStreamDict->SetAtName("Subtype", "Form");
+ pStreamDict->SetAtName("Name", "IMG");
+ CPDF_Array* pMatrix = new CPDF_Array();
+ pStreamDict->SetAt("Matrix", pMatrix);
+ pMatrix->AddInteger(1);
+ pMatrix->AddInteger(0);
+ pMatrix->AddInteger(0);
+ pMatrix->AddInteger(1);
+ pMatrix->AddInteger(-nWidth / 2);
+ pMatrix->AddInteger(-nHeight / 2);
+ CPDF_Dictionary* pResource = new CPDF_Dictionary();
+ pStreamDict->SetAt("Resources", pResource);
+ CPDF_Dictionary* pXObject = new CPDF_Dictionary();
+ pResource->SetAt("XObject", pXObject);
+ pXObject->SetAtReference("Img", pDocument, pImageStream);
+ CPDF_Array* pProcSet = new CPDF_Array();
+ pResource->SetAt("ProcSet", pProcSet);
+ pProcSet->AddName("PDF");
+ pProcSet->AddName("ImageC");
+ pStreamDict->SetAtName("Type", "XObject");
+ CPDF_Array* pBBox = new CPDF_Array();
+ pStreamDict->SetAt("BBox", pBBox);
+ pBBox->AddInteger(0);
+ pBBox->AddInteger(0);
+ pBBox->AddInteger(nWidth);
+ pBBox->AddInteger(nHeight);
+ pStreamDict->SetAtInteger("FormType", 1);
+
+ pRetStream = new CPDF_Stream(NULL, 0, NULL);
+ CFX_ByteString csStream;
+ csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight);
+ pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(), pStreamDict);
+ pDocument->AddIndirectObject(pRetStream);
+ }
+
+ delete pBmp;
+ }
+
+ return pRetStream;
}
#endif
void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField)
{
- ASSERT(m_pDocument != NULL);
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv);
- if(!pEnv->IsJSInitiated())
- return;
-
- if (m_bBusy) return;
-
- m_bBusy = TRUE;
-
- if (IsCalculateEnabled())
- {
- IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime();
- ASSERT(pRuntime != NULL);
-
- pRuntime->SetReaderDocument(m_pDocument);
-
- int nSize = m_pInterForm->CountFieldsInCalculationOrder();
- for (int i=0; i<nSize; i++)
- {
- if(CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i))
- {
-// ASSERT(pField != NULL);
- int nType = pField->GetFieldType();
- if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
- {
- CPDF_AAction aAction = pField->GetAdditionalAction();
- if (aAction && aAction.ActionExist(CPDF_AAction::Calculate))
- {
- CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate);
- if (action)
- {
- CFX_WideString csJS = action.GetJavaScript();
- if (!csJS.IsEmpty())
- {
- IFXJS_Context* pContext = pRuntime->NewContext();
- ASSERT(pContext != NULL);
-
- CFX_WideString sOldValue = pField->GetValue();
- CFX_WideString sValue = sOldValue;
- FX_BOOL bRC = TRUE;
- pContext->OnField_Calculate(pFormField, pField, sValue, bRC);
-
- CFX_WideString sInfo;
- FX_BOOL bRet = pContext->RunScript(csJS, sInfo);
- pRuntime->ReleaseContext(pContext);
-
- if (bRet)
- {
- if (bRC)
- {
- if (sValue.Compare(sOldValue) != 0)
- pField->SetValue(sValue, TRUE);
- }
- }
- }
- }
- }
- }
- }
- }
-
-
- }
-
- m_bBusy = FALSE;
+ ASSERT(m_pDocument != NULL);
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv);
+ if(!pEnv->IsJSInitiated())
+ return;
+
+ if (m_bBusy) return;
+
+ m_bBusy = TRUE;
+
+ if (IsCalculateEnabled())
+ {
+ IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime();
+ ASSERT(pRuntime != NULL);
+
+ pRuntime->SetReaderDocument(m_pDocument);
+
+ int nSize = m_pInterForm->CountFieldsInCalculationOrder();
+ for (int i=0; i<nSize; i++)
+ {
+ if(CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i))
+ {
+// ASSERT(pField != NULL);
+ int nType = pField->GetFieldType();
+ if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
+ {
+ CPDF_AAction aAction = pField->GetAdditionalAction();
+ if (aAction && aAction.ActionExist(CPDF_AAction::Calculate))
+ {
+ CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate);
+ if (action)
+ {
+ CFX_WideString csJS = action.GetJavaScript();
+ if (!csJS.IsEmpty())
+ {
+ IFXJS_Context* pContext = pRuntime->NewContext();
+ ASSERT(pContext != NULL);
+
+ CFX_WideString sOldValue = pField->GetValue();
+ CFX_WideString sValue = sOldValue;
+ FX_BOOL bRC = TRUE;
+ pContext->OnField_Calculate(pFormField, pField, sValue, bRC);
+
+ CFX_WideString sInfo;
+ FX_BOOL bRet = pContext->RunScript(csJS, sInfo);
+ pRuntime->ReleaseContext(pContext);
+
+ if (bRet)
+ {
+ if (bRC)
+ {
+ if (sValue.Compare(sOldValue) != 0)
+ pField->SetValue(sValue, TRUE);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ }
+
+ m_bBusy = FALSE;
}
CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormated)
{
- ASSERT(m_pDocument != NULL);
- ASSERT(pFormField != NULL);
-
- CFX_WideString sValue = pFormField->GetValue();
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv);
- if(!pEnv->IsJSInitiated())
- {
- bFormated = FALSE;
- return sValue;
- }
-
- IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime();
- ASSERT(pRuntime != NULL);
-
- pRuntime->SetReaderDocument(m_pDocument);
-
- if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)
- {
- if (pFormField->CountSelectedItems() > 0)
- {
- int index = pFormField->GetSelectedIndex(0);
- if (index >= 0)
- sValue = pFormField->GetOptionLabel(index);
- }
- }
-
- bFormated = FALSE;
-
- CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format))
- {
- CPDF_Action action = aAction.GetAction(CPDF_AAction::Format);
- if (action)
- {
- CFX_WideString script = action.GetJavaScript();
- if (!script.IsEmpty())
- {
- CFX_WideString Value = sValue;
-
- IFXJS_Context* pContext = pRuntime->NewContext();
- ASSERT(pContext != NULL);
-
- pContext->OnField_Format(pFormField, Value, TRUE);
-
- CFX_WideString sInfo;
- FX_BOOL bRet = pContext->RunScript(script, sInfo);
- pRuntime->ReleaseContext(pContext);
-
- if (bRet)
- {
- sValue = Value;
- bFormated = TRUE;
- }
- }
- }
- }
-
- return sValue;
+ ASSERT(m_pDocument != NULL);
+ ASSERT(pFormField != NULL);
+
+ CFX_WideString sValue = pFormField->GetValue();
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv);
+ if(!pEnv->IsJSInitiated())
+ {
+ bFormated = FALSE;
+ return sValue;
+ }
+
+ IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime();
+ ASSERT(pRuntime != NULL);
+
+ pRuntime->SetReaderDocument(m_pDocument);
+
+ if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)
+ {
+ if (pFormField->CountSelectedItems() > 0)
+ {
+ int index = pFormField->GetSelectedIndex(0);
+ if (index >= 0)
+ sValue = pFormField->GetOptionLabel(index);
+ }
+ }
+
+ bFormated = FALSE;
+
+ CPDF_AAction aAction = pFormField->GetAdditionalAction();
+ if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format))
+ {
+ CPDF_Action action = aAction.GetAction(CPDF_AAction::Format);
+ if (action)
+ {
+ CFX_WideString script = action.GetJavaScript();
+ if (!script.IsEmpty())
+ {
+ CFX_WideString Value = sValue;
+
+ IFXJS_Context* pContext = pRuntime->NewContext();
+ ASSERT(pContext != NULL);
+
+ pContext->OnField_Format(pFormField, Value, TRUE);
+
+ CFX_WideString sInfo;
+ FX_BOOL bRet = pContext->RunScript(script, sInfo);
+ pRuntime->ReleaseContext(pContext);
+
+ if (bRet)
+ {
+ sValue = Value;
+ bFormated = TRUE;
+ }
+ }
+ }
+ }
+
+ return sValue;
}
void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, const FX_WCHAR* sValue, FX_BOOL bValueChanged)
{
- ASSERT(pFormField != NULL);
+ ASSERT(pFormField != NULL);
- for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
- {
- CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
- ASSERT(pFormCtrl != NULL);
+ for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
+ {
+ CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
+ ASSERT(pFormCtrl != NULL);
- ASSERT(m_pInterForm != NULL);
- if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
- pWidget->ResetAppearance(sValue, bValueChanged);
- }
+ ASSERT(m_pInterForm != NULL);
+ if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
+ pWidget->ResetAppearance(sValue, bValueChanged);
+ }
}
void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField)
{
- ASSERT(pFormField != NULL);
+ ASSERT(pFormField != NULL);
- for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
- {
- CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
- ASSERT(pFormCtrl != NULL);
+ for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
+ {
+ CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
+ ASSERT(pFormCtrl != NULL);
- if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
- {
- CPDFDoc_Environment * pEnv = m_pDocument->GetEnv();
- CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller();
+ if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
+ {
+ CPDFDoc_Environment * pEnv = m_pDocument->GetEnv();
+ CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller();
- CPDF_Page * pPage = pWidget->GetPDFPage();
- CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(pPage,FALSE);
+ CPDF_Page * pPage = pWidget->GetPDFPage();
+ CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(pPage,FALSE);
- FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget);
+ FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget);
- pEnv->FFI_Invalidate(pPage,rcBBox.left, rcBBox.top, rcBBox.right, rcBBox.bottom);
- }
- }
+ pEnv->FFI_Invalidate(pPage,rcBBox.left, rcBBox.top, rcBBox.right, rcBBox.bottom);
+ }
+ }
}
void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC)
{
- ASSERT(pFormField != NULL);
-
- CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke))
- {
- CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
- if (action)
- {
- ASSERT(m_pDocument != NULL);
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv != NULL);
-
- CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
- ASSERT(pActionHandler != NULL);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
- fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
- fa.sValue = csValue;
+ ASSERT(pFormField != NULL);
- pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke,
- m_pDocument, pFormField, fa);
- bRC = fa.bRC;
- }
- }
+ CPDF_AAction aAction = pFormField->GetAdditionalAction();
+ if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke))
+ {
+ CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
+ if (action)
+ {
+ ASSERT(m_pDocument != NULL);
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv != NULL);
+
+ CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
+ ASSERT(pActionHandler != NULL);
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
+ fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
+ fa.sValue = csValue;
+
+ pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke,
+ m_pDocument, pFormField, fa);
+ bRC = fa.bRC;
+ }
+ }
}
void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC)
{
- ASSERT(pFormField != NULL);
+ ASSERT(pFormField != NULL);
- CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate))
- {
- CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
- if (action)
- {
- ASSERT(m_pDocument != NULL);
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv != NULL);
+ CPDF_AAction aAction = pFormField->GetAdditionalAction();
+ if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate))
+ {
+ CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
+ if (action)
+ {
+ ASSERT(m_pDocument != NULL);
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv != NULL);
- CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
- ASSERT(pActionHandler != NULL);
+ CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
+ ASSERT(pActionHandler != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
- fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
- fa.sValue = csValue;
+ PDFSDK_FieldAction fa;
+ fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0);
+ fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0);
+ fa.sValue = csValue;
- pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, m_pDocument, pFormField, fa);
- bRC = fa.bRC;
+ pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, m_pDocument, pFormField, fa);
+ bRC = fa.bRC;
- }
- }
+ }
+ }
}
/* ----------------------------- action ----------------------------- */
FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action)
{
- ASSERT(action);
-
- CPDF_ActionFields af = action.GetWidgets();
- CFX_PtrArray fieldObjects;
- af.GetAllFields(fieldObjects);
- CFX_PtrArray widgetArray;
- CFX_PtrArray fields;
- GetFieldFromObjects(fieldObjects, fields);
-
- FX_BOOL bHide = action.GetHideStatus();
-
- FX_BOOL bChanged = FALSE;
-
- for (int i=0, sz=fields.GetSize(); i<sz; i++)
- {
- CPDF_FormField* pField = (CPDF_FormField*)fields[i];
- ASSERT(pField != NULL);
-
-
- for (int j=0,jsz=pField->CountControls(); j<jsz; j++)
- {
- CPDF_FormControl* pControl = pField->GetControl(j);
- ASSERT(pControl != NULL);
-
- if (CPDFSDK_Widget* pWidget = GetWidget(pControl))
- {
- int nFlags = pWidget->GetFlags();
- if (bHide)
- {
- nFlags &= (~ANNOTFLAG_INVISIBLE);
- nFlags &= (~ANNOTFLAG_NOVIEW);
- nFlags |= (ANNOTFLAG_HIDDEN);
- }
- else
- {
- nFlags &= (~ANNOTFLAG_INVISIBLE);
- nFlags &= (~ANNOTFLAG_HIDDEN);
- nFlags &= (~ANNOTFLAG_NOVIEW);
- }
- pWidget->SetFlags(nFlags);
-
- CPDFSDK_PageView* pPageView = pWidget->GetPageView();
- ASSERT(pPageView != NULL);
-
- pPageView->UpdateView(pWidget);
-
- bChanged = TRUE;
- }
- }
- }
+ ASSERT(action);
+
+ CPDF_ActionFields af = action.GetWidgets();
+ CFX_PtrArray fieldObjects;
+ af.GetAllFields(fieldObjects);
+ CFX_PtrArray widgetArray;
+ CFX_PtrArray fields;
+ GetFieldFromObjects(fieldObjects, fields);
+
+ FX_BOOL bHide = action.GetHideStatus();
+
+ FX_BOOL bChanged = FALSE;
+
+ for (int i=0, sz=fields.GetSize(); i<sz; i++)
+ {
+ CPDF_FormField* pField = (CPDF_FormField*)fields[i];
+ ASSERT(pField != NULL);
+
+
+ for (int j=0,jsz=pField->CountControls(); j<jsz; j++)
+ {
+ CPDF_FormControl* pControl = pField->GetControl(j);
+ ASSERT(pControl != NULL);
+
+ if (CPDFSDK_Widget* pWidget = GetWidget(pControl))
+ {
+ int nFlags = pWidget->GetFlags();
+ if (bHide)
+ {
+ nFlags &= (~ANNOTFLAG_INVISIBLE);
+ nFlags &= (~ANNOTFLAG_NOVIEW);
+ nFlags |= (ANNOTFLAG_HIDDEN);
+ }
+ else
+ {
+ nFlags &= (~ANNOTFLAG_INVISIBLE);
+ nFlags &= (~ANNOTFLAG_HIDDEN);
+ nFlags &= (~ANNOTFLAG_NOVIEW);
+ }
+ pWidget->SetFlags(nFlags);
+
+ CPDFSDK_PageView* pPageView = pWidget->GetPageView();
+ ASSERT(pPageView != NULL);
+
+ pPageView->UpdateView(pWidget);
+
+ bChanged = TRUE;
+ }
+ }
+ }
- return bChanged;
+ return bChanged;
}
FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action)
{
- ASSERT(action);
- ASSERT(m_pInterForm != NULL);
-
- CFX_WideString sDestination = action.GetFilePath();
- if (sDestination.IsEmpty()) return FALSE;
-
- CPDF_Dictionary* pActionDict = action.GetDict();
- if (pActionDict->KeyExist("Fields"))
- {
- CPDF_ActionFields af = action.GetWidgets();
- FX_DWORD dwFlags = action.GetFlags();
-
- CFX_PtrArray fieldObjects;
- af.GetAllFields(fieldObjects);
- CFX_PtrArray fields;
- GetFieldFromObjects(fieldObjects, fields);
-
- if (fields.GetSize() != 0)
- {
- FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01);
- if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude))
- {
- return FALSE;
- }
- return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE);
- }
- else
- {
- if ( m_pInterForm->CheckRequiredFields())
- {
- return FALSE;
- }
-
- return SubmitForm(sDestination, FALSE);
- }
- }
- else
- {
- if ( m_pInterForm->CheckRequiredFields())
- {
- return FALSE;
- }
-
- return SubmitForm(sDestination, FALSE);
- }
+ ASSERT(m_pInterForm != NULL);
+ CFX_WideString sDestination = action.GetFilePath();
+ if (sDestination.IsEmpty())
+ return FALSE;
+
+ CPDF_Dictionary* pActionDict = action.GetDict();
+ if (pActionDict->KeyExist("Fields"))
+ {
+ CPDF_ActionFields af = action.GetWidgets();
+ FX_DWORD dwFlags = action.GetFlags();
+ CFX_PtrArray fieldObjects;
+ af.GetAllFields(fieldObjects);
+
+ CFX_PtrArray fields;
+ GetFieldFromObjects(fieldObjects, fields);
+ if (fields.GetSize() != 0)
+ {
+ FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01);
+ if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude))
+ return FALSE;
+
+ return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE);
+ }
+ }
+ if (m_pInterForm->CheckRequiredFields())
+ return FALSE;
+
+ return SubmitForm(sDestination, FALSE);
}
FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, const CFX_PtrArray& fields,
- FX_BOOL bIncludeOrExclude, FX_BOOL bUrlEncoded)
+ FX_BOOL bIncludeOrExclude, FX_BOOL bUrlEncoded)
{
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv != NULL);
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv != NULL);
- CFX_ByteTextBuf textBuf;
- ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf);
+ CFX_ByteTextBuf textBuf;
+ ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf);
- uint8_t* pBuffer = textBuf.GetBuffer();
- FX_STRSIZE nBufSize = textBuf.GetLength();
+ uint8_t* pBuffer = textBuf.GetBuffer();
+ FX_STRSIZE nBufSize = textBuf.GetLength();
- if (bUrlEncoded)
- {
- if(!FDFToURLEncodedData(pBuffer, nBufSize))
- return FALSE;
- }
+ if (bUrlEncoded)
+ {
+ if(!FDFToURLEncodedData(pBuffer, nBufSize))
+ return FALSE;
+ }
- pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str());
+ pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str());
- return TRUE;
+ return TRUE;
}
void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer)
{
- ASSERT(m_pDocument != NULL);
-
- if (CFDF_Document *pFDFDocument = CFDF_Document::ParseMemory((const unsigned char *)sBuffer.GetBuffer(sBuffer.GetLength()), sBuffer.GetLength()))
- {
- CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot();
- if(pRootDic)
- {
- CPDF_Dictionary * pFDFDict=pRootDic->GetDict("FDF");
- if(pFDFDict)
- {
- CPDF_Dictionary * pJSDict = pFDFDict->GetDict("JavaScript");
- if(pJSDict)
- {
- CFX_WideString csJS;
-
- CPDF_Object* pJS = pJSDict->GetElementValue("Before");
- if (pJS != NULL)
- {
- int iType = pJS->GetType();
- if (iType == PDFOBJ_STRING)
- csJS = pJSDict->GetUnicodeText("Before");
- else if (iType == PDFOBJ_STREAM)
- csJS = pJS->GetUnicodeText();
- }
-
- }
- }
- }
- delete pFDFDocument;
- }
-
- sBuffer.ReleaseBuffer();
+ ASSERT(m_pDocument != NULL);
+
+ if (CFDF_Document *pFDFDocument = CFDF_Document::ParseMemory((const unsigned char *)sBuffer.GetBuffer(sBuffer.GetLength()), sBuffer.GetLength()))
+ {
+ CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot();
+ if(pRootDic)
+ {
+ CPDF_Dictionary * pFDFDict=pRootDic->GetDict("FDF");
+ if(pFDFDict)
+ {
+ CPDF_Dictionary * pJSDict = pFDFDict->GetDict("JavaScript");
+ if(pJSDict)
+ {
+ CFX_WideString csJS;
+
+ CPDF_Object* pJS = pJSDict->GetElementValue("Before");
+ if (pJS != NULL)
+ {
+ int iType = pJS->GetType();
+ if (iType == PDFOBJ_STRING)
+ csJS = pJSDict->GetUnicodeText("Before");
+ else if (iType == PDFOBJ_STREAM)
+ csJS = pJS->GetUnicodeText();
+ }
+
+ }
+ }
+ }
+ delete pFDFDocument;
+ }
+
+ sBuffer.ReleaseBuffer();
}
FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_WideString csTxtFile)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize)
{
- CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize);
- if (pFDF)
- {
- CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF");
- if (pMainDict == NULL) return FALSE;
-
- // Get fields
- CPDF_Array* pFields = pMainDict->GetArray("Fields");
- if (pFields == NULL) return FALSE;
-
- CFX_ByteTextBuf fdfEncodedData;
-
- for (FX_DWORD i = 0; i < pFields->GetCount(); i ++)
- {
- CPDF_Dictionary* pField = pFields->GetDict(i);
- if (pField == NULL) continue;
- CFX_WideString name;
- name = pField->GetUnicodeText("T");
- CFX_ByteString name_b = CFX_ByteString::FromUnicode(name);
- CFX_ByteString csBValue = pField->GetString("V");
- CFX_WideString csWValue = PDF_DecodeText(csBValue);
- CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue);
-
- fdfEncodedData = fdfEncodedData<<name_b.GetBuffer(name_b.GetLength());
- name_b.ReleaseBuffer();
- fdfEncodedData = fdfEncodedData<<"=";
- fdfEncodedData = fdfEncodedData<<csValue_b.GetBuffer(csValue_b.GetLength());
- csValue_b.ReleaseBuffer();
- if(i != pFields->GetCount()-1)
- fdfEncodedData = fdfEncodedData<<"&";
- }
-
- nBufSize = fdfEncodedData.GetLength();
- pBuf = FX_Alloc(uint8_t, nBufSize);
- FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
- }
- return TRUE;
+ CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize);
+ if (pFDF)
+ {
+ CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF");
+ if (pMainDict == NULL) return FALSE;
+
+ // Get fields
+ CPDF_Array* pFields = pMainDict->GetArray("Fields");
+ if (pFields == NULL) return FALSE;
+
+ CFX_ByteTextBuf fdfEncodedData;
+
+ for (FX_DWORD i = 0; i < pFields->GetCount(); i ++)
+ {
+ CPDF_Dictionary* pField = pFields->GetDict(i);
+ if (pField == NULL) continue;
+ CFX_WideString name;
+ name = pField->GetUnicodeText("T");
+ CFX_ByteString name_b = CFX_ByteString::FromUnicode(name);
+ CFX_ByteString csBValue = pField->GetString("V");
+ CFX_WideString csWValue = PDF_DecodeText(csBValue);
+ CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue);
+
+ fdfEncodedData = fdfEncodedData<<name_b.GetBuffer(name_b.GetLength());
+ name_b.ReleaseBuffer();
+ fdfEncodedData = fdfEncodedData<<"=";
+ fdfEncodedData = fdfEncodedData<<csValue_b.GetBuffer(csValue_b.GetLength());
+ csValue_b.ReleaseBuffer();
+ if(i != pFields->GetCount()-1)
+ fdfEncodedData = fdfEncodedData<<"&";
+ }
+
+ nBufSize = fdfEncodedData.GetLength();
+ pBuf = FX_Alloc(uint8_t, nBufSize);
+ FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
+ }
+ return TRUE;
}
FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,FX_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf)
{
- ASSERT(m_pDocument != NULL);
- ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pDocument != NULL);
+ ASSERT(m_pInterForm != NULL);
- CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(CFX_PtrArray&)fields, bIncludeOrExclude);
- if (!pFDF) return FALSE;
- FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;//
- delete pFDF;
+ CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(CFX_PtrArray&)fields, bIncludeOrExclude);
+ if (!pFDF) return FALSE;
+ FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;//
+ delete pFDF;
- return bRet;
+ return bRet;
}
CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName(const CFX_WideString& sFileExt)
{
- CFX_WideString sFileName;
- return L"";
+ CFX_WideString sFileName;
+ return L"";
}
FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded)
{
- if (sDestination.IsEmpty()) return FALSE;
+ if (sDestination.IsEmpty()) return FALSE;
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv != NULL);
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv != NULL);
- if(NULL == m_pDocument) return FALSE;
- CFX_WideString wsPDFFilePath = m_pDocument->GetPath();
+ if(NULL == m_pDocument) return FALSE;
+ CFX_WideString wsPDFFilePath = m_pDocument->GetPath();
- if(NULL == m_pInterForm) return FALSE;
- CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath);
- if (NULL == pFDFDoc) return FALSE;
+ if(NULL == m_pInterForm) return FALSE;
+ CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath);
+ if (NULL == pFDFDoc) return FALSE;
- CFX_ByteTextBuf FdfBuffer;
- FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer);
- delete pFDFDoc;
- if (!bRet) return FALSE;
+ CFX_ByteTextBuf FdfBuffer;
+ FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer);
+ delete pFDFDoc;
+ if (!bRet) return FALSE;
- uint8_t* pBuffer = FdfBuffer.GetBuffer();
- FX_STRSIZE nBufSize = FdfBuffer.GetLength();
+ uint8_t* pBuffer = FdfBuffer.GetBuffer();
+ FX_STRSIZE nBufSize = FdfBuffer.GetLength();
- if (bUrlEncoded)
- {
- if(!FDFToURLEncodedData(pBuffer, nBufSize))
- return FALSE;
- }
+ if (bUrlEncoded)
+ {
+ if(!FDFToURLEncodedData(pBuffer, nBufSize))
+ return FALSE;
+ }
- pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str());
+ pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str());
- if (bUrlEncoded && pBuffer)
- {
- FX_Free(pBuffer);
- pBuffer = NULL;
- }
+ if (bUrlEncoded && pBuffer)
+ {
+ FX_Free(pBuffer);
+ pBuffer = NULL;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf)
{
- ASSERT(m_pInterForm != NULL);
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pInterForm != NULL);
+ ASSERT(m_pDocument != NULL);
- CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath());
- if (!pFDF) return FALSE;
+ CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath());
+ if (!pFDF) return FALSE;
- FX_BOOL bRet = pFDF->WriteBuf(textBuf);
- delete pFDF;
+ FX_BOOL bRet = pFDF->WriteBuf(textBuf);
+ delete pFDF;
- return bRet;
+ return bRet;
}
FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action)
{
- ASSERT(action);
+ ASSERT(action);
- CPDF_Dictionary* pActionDict = action.GetDict();
- if (pActionDict->KeyExist("Fields"))
- {
- CPDF_ActionFields af = action.GetWidgets();
- FX_DWORD dwFlags = action.GetFlags();
+ CPDF_Dictionary* pActionDict = action.GetDict();
+ if (pActionDict->KeyExist("Fields"))
+ {
+ CPDF_ActionFields af = action.GetWidgets();
+ FX_DWORD dwFlags = action.GetFlags();
- CFX_PtrArray fieldObjects;
- af.GetAllFields(fieldObjects);
- CFX_PtrArray fields;
- GetFieldFromObjects(fieldObjects, fields);
- return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE);
- }
+ CFX_PtrArray fieldObjects;
+ af.GetAllFields(fieldObjects);
+ CFX_PtrArray fields;
+ GetFieldFromObjects(fieldObjects, fields);
+ return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE);
+ }
- return m_pInterForm->ResetForm(TRUE);
+ return m_pInterForm->ResetForm(TRUE);
}
FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action)
{
- return FALSE;
+ return FALSE;
}
void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_PtrArray& fields)
{
- ASSERT(m_pInterForm != NULL);
-
- int iCount = objects.GetSize();
- for (int i = 0; i < iCount; i ++)
- {
- CPDF_Object* pObject = (CPDF_Object*)objects[i];
- if (pObject == NULL) continue;
-
- int iType = pObject->GetType();
- if (iType == PDFOBJ_STRING)
- {
- CFX_WideString csName = pObject->GetUnicodeText();
- CPDF_FormField* pField = m_pInterForm->GetField(0, csName);
- if (pField != NULL)
- fields.Add(pField);
- }
- else if (iType == PDFOBJ_DICTIONARY)
- {
- if (m_pInterForm->IsValidFormField(pObject))
- fields.Add(pObject);
- }
- }
+ ASSERT(m_pInterForm != NULL);
+
+ int iCount = objects.GetSize();
+ for (int i = 0; i < iCount; i ++)
+ {
+ CPDF_Object* pObject = (CPDF_Object*)objects[i];
+ if (pObject == NULL) continue;
+
+ int iType = pObject->GetType();
+ if (iType == PDFOBJ_STRING)
+ {
+ CFX_WideString csName = pObject->GetUnicodeText();
+ CPDF_FormField* pField = m_pInterForm->GetField(0, csName);
+ if (pField != NULL)
+ fields.Add(pField);
+ }
+ else if (iType == PDFOBJ_DICTIONARY)
+ {
+ if (m_pInterForm->IsValidFormField(pObject))
+ fields.Add(pObject);
+ }
+ }
}
/* ----------------------------- CPDF_FormNotify ----------------------------- */
-int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue)
-{
- ASSERT(pField != NULL);
-
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
-
- int nType = pFormField->GetFieldType();
- if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
- {
- FX_BOOL bRC = TRUE;
- OnKeyStrokeCommit(pFormField, csValue, bRC);
- if (bRC)
- {
- OnValidate(pFormField, csValue, bRC);
- if (bRC)
- return 1;
- else
- return -1;
- }
- else
- return -1;
- }
- else
- return 0;
+int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue)
+{
+ CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+ int nType = pFormField->GetFieldType();
+ if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
+ {
+ FX_BOOL bRC = TRUE;
+ OnKeyStrokeCommit(pFormField, csValue, bRC);
+ if (bRC)
+ {
+ OnValidate(pFormField, csValue, bRC);
+ return bRC ? 1 : -1;
+ }
+ return -1;
+ }
+ return 0;
}
-int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField)
-{
- ASSERT(pField != NULL);
-
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- int nType = pFormField->GetFieldType();
-
- if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
- {
- OnCalculate(pFormField);
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = OnFormat(pFormField, bFormated);
- if (bFormated)
- ResetFieldAppearance(pFormField, sValue.c_str(), TRUE);
- else
- ResetFieldAppearance(pFormField, NULL, TRUE);
- UpdateField(pFormField);
- }
-
- return 0;
+int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField)
+{
+ CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+ int nType = pFormField->GetFieldType();
+ if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
+ {
+ OnCalculate(pFormField);
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = OnFormat(pFormField, bFormated);
+ if (bFormated)
+ ResetFieldAppearance(pFormField, sValue.c_str(), TRUE);
+ else
+ ResetFieldAppearance(pFormField, NULL, TRUE);
+ UpdateField(pFormField);
+ }
+ return 0;
}
-int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue)
+int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue)
{
- ASSERT(pField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+ if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+ return 0;
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+ FX_BOOL bRC = TRUE;
+ OnKeyStrokeCommit(pFormField, csValue, bRC);
+ if (!bRC)
+ return -1;
- int nType = pFormField->GetFieldType();
- if (nType == FIELDTYPE_LISTBOX)
- {
- FX_BOOL bRC = TRUE;
- OnKeyStrokeCommit(pFormField, csValue, bRC);
- if (bRC)
- {
- OnValidate(pFormField, csValue, bRC);
- if (bRC)
- return 1;
- else
- return -1;
- }
- else
- return -1;
- }
- else
- return 0;
+ OnValidate(pFormField, csValue, bRC);
+ if (!bRC)
+ return -1;
+
+ return 1;
}
-int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField)
+int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField)
{
- ASSERT(pField != NULL);
-
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- int nType = pFormField->GetFieldType();
-
- if (nType == FIELDTYPE_LISTBOX)
- {
- OnCalculate(pFormField);
- ResetFieldAppearance(pFormField, NULL, TRUE);
- UpdateField(pFormField);
- }
-
- return 0;
+ CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+ if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX)
+ {
+ OnCalculate(pFormField);
+ ResetFieldAppearance(pFormField, NULL, TRUE);
+ UpdateField(pFormField);
+ }
+ return 0;
}
-int CPDFSDK_InterForm::AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray)
+int CPDFSDK_InterForm::AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray)
{
- ASSERT(pField != NULL);
-
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- int nType = pFormField->GetFieldType();
-
- if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON)
- {
- OnCalculate(pFormField);
- UpdateField(pFormField);
- }
-
- return 0;
+ CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+ int nType = pFormField->GetFieldType();
+ if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON)
+ {
+ OnCalculate(pFormField);
+ UpdateField(pFormField);
+ }
+ return 0;
}
-int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm)
+int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm)
{
- return 0;
+ return 0;
}
-int CPDFSDK_InterForm::AfterFormReset(const CPDF_InterForm* pForm)
+int CPDFSDK_InterForm::AfterFormReset(const CPDF_InterForm* pForm)
{
OnCalculate(nullptr);
return 0;
}
-int CPDFSDK_InterForm::BeforeFormImportData(const CPDF_InterForm* pForm)
+int CPDFSDK_InterForm::BeforeFormImportData(const CPDF_InterForm* pForm)
{
- return 0;
+ return 0;
}
-int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm)
+int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm)
{
OnCalculate(nullptr);
return 0;
@@ -2563,382 +2511,368 @@ int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm)
FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType)
{
- if(nFieldType <1 || nFieldType > 6)
- return FALSE;
- return m_bNeedHightlight[nFieldType-1];
+ if(nFieldType <1 || nFieldType > 6)
+ return FALSE;
+ return m_bNeedHightlight[nFieldType-1];
}
void CPDFSDK_InterForm::RemoveAllHighLight()
{
- memset((void*)m_bNeedHightlight, 0, 6*sizeof(FX_BOOL));
+ memset((void*)m_bNeedHightlight, 0, 6*sizeof(FX_BOOL));
}
void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType)
{
- if(nFieldType <0 || nFieldType > 6) return;
- switch(nFieldType)
- {
- case 0:
- {
- for(int i=0; i<6; i++)
- {
- m_aHighlightColor[i] = clr;
- m_bNeedHightlight[i] = TRUE;
- }
- break;
- }
- default:
- {
- m_aHighlightColor[nFieldType-1] = clr;
- m_bNeedHightlight[nFieldType-1] = TRUE;
- break;
- }
- }
+ if(nFieldType <0 || nFieldType > 6) return;
+ switch(nFieldType)
+ {
+ case 0:
+ {
+ for(int i=0; i<6; i++)
+ {
+ m_aHighlightColor[i] = clr;
+ m_bNeedHightlight[i] = TRUE;
+ }
+ break;
+ }
+ default:
+ {
+ m_aHighlightColor[nFieldType-1] = clr;
+ m_bNeedHightlight[nFieldType-1] = TRUE;
+ break;
+ }
+ }
}
FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType)
{
- if(nFieldType <0 || nFieldType >6) return FXSYS_RGB(255,255,255);
- if(nFieldType == 0)
- return m_aHighlightColor[0];
- else
- return m_aHighlightColor[nFieldType-1];
+ if (nFieldType < 0 || nFieldType > 6)
+ return FXSYS_RGB(255,255,255);
+ if (nFieldType == 0)
+ return m_aHighlightColor[0];
+ return m_aHighlightColor[nFieldType-1];
}
/* ------------------------- CBA_AnnotIterator ------------------------- */
CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_ByteString& sType, const CFX_ByteString& sSubType)
- :m_pPageView(pPageView),
- m_sType(sType),
- m_sSubType(sSubType),
- m_nTabs(BAI_STRUCTURE)
+ :m_pPageView(pPageView),
+ m_sType(sType),
+ m_sSubType(sSubType),
+ m_nTabs(BAI_STRUCTURE)
{
- ASSERT(m_pPageView != NULL);
+ ASSERT(m_pPageView != NULL);
- CPDF_Page* pPDFPage = m_pPageView->GetPDFPage();
- ASSERT(pPDFPage != NULL);
- ASSERT(pPDFPage->m_pFormDict != NULL);
+ CPDF_Page* pPDFPage = m_pPageView->GetPDFPage();
+ ASSERT(pPDFPage != NULL);
+ ASSERT(pPDFPage->m_pFormDict != NULL);
- CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs");
+ CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs");
- if (sTabs == "R")
- {
- m_nTabs = BAI_ROW;
- }
- else if (sTabs == "C")
- {
- m_nTabs = BAI_COLUMN;
- }
- else
- {
- m_nTabs = BAI_STRUCTURE;
- }
+ if (sTabs == "R")
+ {
+ m_nTabs = BAI_ROW;
+ }
+ else if (sTabs == "C")
+ {
+ m_nTabs = BAI_COLUMN;
+ }
+ else
+ {
+ m_nTabs = BAI_STRUCTURE;
+ }
- GenerateResults();
+ GenerateResults();
}
CBA_AnnotIterator::~CBA_AnnotIterator()
{
- m_Annots.RemoveAll();
+ m_Annots.RemoveAll();
}
CPDFSDK_Annot* CBA_AnnotIterator::GetFirstAnnot()
{
- if (m_Annots.GetSize() > 0)
- return m_Annots[0];
+ if (m_Annots.GetSize() > 0)
+ return m_Annots[0];
- return NULL;
+ return NULL;
}
CPDFSDK_Annot* CBA_AnnotIterator::GetLastAnnot()
{
- if (m_Annots.GetSize() > 0)
- return m_Annots[m_Annots.GetSize() - 1];
+ if (m_Annots.GetSize() > 0)
+ return m_Annots[m_Annots.GetSize() - 1];
- return NULL;
+ return NULL;
}
CPDFSDK_Annot* CBA_AnnotIterator::GetNextAnnot(CPDFSDK_Annot* pAnnot)
{
- for (int i=0,sz=m_Annots.GetSize(); i<sz; i++)
- {
- if (m_Annots[i] == pAnnot)
- {
- if (i+1 < sz)
- return m_Annots[i+1];
- else
- return m_Annots[0];
- }
- }
-
- return NULL;
+ for (int i = 0, sz = m_Annots.GetSize(); i < sz; ++i) {
+ if (m_Annots[i] == pAnnot)
+ return (i + 1 < sz) ? m_Annots[i+1] : m_Annots[0];
+ }
+ return NULL;
}
CPDFSDK_Annot* CBA_AnnotIterator::GetPrevAnnot(CPDFSDK_Annot* pAnnot)
{
- for (int i=0,sz=m_Annots.GetSize(); i<sz; i++)
- {
- if (m_Annots[i] == pAnnot)
- {
- if (i-1 >= 0)
- return m_Annots[i-1];
- else
- return m_Annots[sz-1];
- }
- }
-
- return NULL;
+ for (int i = 0, sz = m_Annots.GetSize(); i < sz; ++i) {
+ if (m_Annots[i] == pAnnot)
+ return (i - 1 >= 0) ? m_Annots[i-1] : m_Annots[sz-1];
+ }
+ return NULL;
}
int CBA_AnnotIterator::CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
{
- ASSERT(p1 != NULL);
- ASSERT(p2 != NULL);
+ ASSERT(p1);
+ ASSERT(p2);
- CPDF_Rect rcAnnot1 = GetAnnotRect(p1);
- CPDF_Rect rcAnnot2 = GetAnnotRect(p2);
+ CPDF_Rect rcAnnot1 = GetAnnotRect(p1);
+ CPDF_Rect rcAnnot2 = GetAnnotRect(p2);
- if (rcAnnot1.left < rcAnnot2.left)
- return -1;
- if (rcAnnot1.left > rcAnnot2.left)
- return 1;
- return 0;
+ if (rcAnnot1.left < rcAnnot2.left)
+ return -1;
+ if (rcAnnot1.left > rcAnnot2.left)
+ return 1;
+ return 0;
}
int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
{
- ASSERT(p1 != NULL);
- ASSERT(p2 != NULL);
+ ASSERT(p1 != NULL);
+ ASSERT(p2 != NULL);
- CPDF_Rect rcAnnot1 = GetAnnotRect(p1);
- CPDF_Rect rcAnnot2 = GetAnnotRect(p2);
+ CPDF_Rect rcAnnot1 = GetAnnotRect(p1);
+ CPDF_Rect rcAnnot2 = GetAnnotRect(p2);
- if (rcAnnot1.top < rcAnnot2.top)
- return -1;
- if (rcAnnot1.top > rcAnnot2.top)
- return 1;
- return 0;
+ if (rcAnnot1.top < rcAnnot2.top)
+ return -1;
+ if (rcAnnot1.top > rcAnnot2.top)
+ return 1;
+ return 0;
}
void CBA_AnnotIterator::GenerateResults()
{
- ASSERT(m_pPageView != NULL);
-
- switch (m_nTabs)
- {
- case BAI_STRUCTURE:
- {
- for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++)
- {
- CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
- ASSERT(pAnnot != NULL);
-
- if (pAnnot->GetType() == m_sType
- && pAnnot->GetSubType() == m_sSubType)
- m_Annots.Add(pAnnot);
- }
- }
- break;
- case BAI_ROW:
- {
- CPDFSDK_SortAnnots sa;
-
- {
-
- for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++)
- {
- CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
- ASSERT(pAnnot != NULL);
-
- if (pAnnot->GetType() == m_sType
- && pAnnot->GetSubType() == m_sSubType)
- sa.Add(pAnnot);
- }
- }
-
- if (sa.GetSize() > 0)
- {
- sa.Sort(CBA_AnnotIterator::CompareByLeft);
- }
-
- while (sa.GetSize() > 0)
- {
- int nLeftTopIndex = -1;
-
- {
- FX_FLOAT fTop = 0.0f;
-
- for (int i=sa.GetSize()-1; i>=0; i--)
- {
- CPDFSDK_Annot* pAnnot = sa.GetAt(i);
- ASSERT(pAnnot != NULL);
-
- CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
-
- if (rcAnnot.top > fTop)
- {
- nLeftTopIndex = i;
- fTop = rcAnnot.top;
- }
- }
- }
-
- if (nLeftTopIndex >= 0)
- {
- CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(nLeftTopIndex);
- ASSERT(pLeftTopAnnot != NULL);
-
- CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot);
-
- m_Annots.Add(pLeftTopAnnot);
- sa.RemoveAt(nLeftTopIndex);
-
- CFX_ArrayTemplate<int> aSelect;
-
- {
- for (int i=0,sz=sa.GetSize(); i<sz; i++)
- {
- CPDFSDK_Annot* pAnnot = sa.GetAt(i);
- ASSERT(pAnnot != NULL);
-
- CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
-
- FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f;
-
- if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top)
- aSelect.Add(i);
- }
- }
-
- {
- for (int i=0,sz=aSelect.GetSize(); i<sz; i++)
- {
- m_Annots.Add(sa[aSelect[i]]);
- }
- }
-
- {
- for (int i=aSelect.GetSize()-1; i>=0; i--)
- {
- sa.RemoveAt(aSelect[i]);
- }
- }
-
- aSelect.RemoveAll();
- }
- }
- sa.RemoveAll();
- }
- break;
- case BAI_COLUMN:
- {
- CPDFSDK_SortAnnots sa;
-
- {
- for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++)
- {
- CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
- ASSERT(pAnnot != NULL);
-
- if (pAnnot->GetType() == m_sType
- && pAnnot->GetSubType() == m_sSubType)
- sa.Add(pAnnot);
- }
- }
-
- if (sa.GetSize() > 0)
- {
- sa.Sort(CBA_AnnotIterator::CompareByTop, FALSE);
- }
-
- while (sa.GetSize() > 0)
- {
- int nLeftTopIndex = -1;
-
- {
- FX_FLOAT fLeft = -1.0f;
-
- for (int i=sa.GetSize()-1; i>=0; i--)
- {
- CPDFSDK_Annot* pAnnot = sa.GetAt(i);
- ASSERT(pAnnot != NULL);
-
- CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
-
- if (fLeft < 0)
- {
- nLeftTopIndex = 0;
- fLeft = rcAnnot.left;
- }
- else if (rcAnnot.left < fLeft)
- {
- nLeftTopIndex = i;
- fLeft = rcAnnot.left;
- }
- }
- }
-
- if (nLeftTopIndex >= 0)
- {
- CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(nLeftTopIndex);
- ASSERT(pLeftTopAnnot != NULL);
-
- CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot);
-
- m_Annots.Add(pLeftTopAnnot);
- sa.RemoveAt(nLeftTopIndex);
-
- CFX_ArrayTemplate<int> aSelect;
-
- {
- for (int i=0,sz=sa.GetSize(); i<sz; i++)
- {
- CPDFSDK_Annot* pAnnot = sa.GetAt(i);
- ASSERT(pAnnot != NULL);
-
- CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
-
- FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f;
-
- if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right)
- aSelect.Add(i);
- }
- }
-
- {
- for (int i=0,sz=aSelect.GetSize(); i<sz; i++)
- {
- m_Annots.Add(sa[aSelect[i]]);
- }
- }
-
- {
- for (int i=aSelect.GetSize()-1; i>=0; i--)
- {
- sa.RemoveAt(aSelect[i]);
- }
- }
-
- aSelect.RemoveAll();
- }
- }
- sa.RemoveAll();
- }
- break;
- }
+ ASSERT(m_pPageView != NULL);
+
+ switch (m_nTabs)
+ {
+ case BAI_STRUCTURE:
+ {
+ for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++)
+ {
+ CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
+ ASSERT(pAnnot != NULL);
+
+ if (pAnnot->GetType() == m_sType
+ && pAnnot->GetSubType() == m_sSubType)
+ m_Annots.Add(pAnnot);
+ }
+ }
+ break;
+ case BAI_ROW:
+ {
+ CPDFSDK_SortAnnots sa;
+
+ {
+
+ for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++)
+ {
+ CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
+ ASSERT(pAnnot != NULL);
+
+ if (pAnnot->GetType() == m_sType
+ && pAnnot->GetSubType() == m_sSubType)
+ sa.Add(pAnnot);
+ }
+ }
+
+ if (sa.GetSize() > 0)
+ {
+ sa.Sort(CBA_AnnotIterator::CompareByLeft);
+ }
+
+ while (sa.GetSize() > 0)
+ {
+ int nLeftTopIndex = -1;
+
+ {
+ FX_FLOAT fTop = 0.0f;
+
+ for (int i=sa.GetSize()-1; i>=0; i--)
+ {
+ CPDFSDK_Annot* pAnnot = sa.GetAt(i);
+ ASSERT(pAnnot != NULL);
+
+ CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
+
+ if (rcAnnot.top > fTop)
+ {
+ nLeftTopIndex = i;
+ fTop = rcAnnot.top;
+ }
+ }
+ }
+
+ if (nLeftTopIndex >= 0)
+ {
+ CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(nLeftTopIndex);
+ ASSERT(pLeftTopAnnot != NULL);
+
+ CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot);
+
+ m_Annots.Add(pLeftTopAnnot);
+ sa.RemoveAt(nLeftTopIndex);
+
+ CFX_ArrayTemplate<int> aSelect;
+
+ {
+ for (int i=0,sz=sa.GetSize(); i<sz; i++)
+ {
+ CPDFSDK_Annot* pAnnot = sa.GetAt(i);
+ ASSERT(pAnnot != NULL);
+
+ CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
+
+ FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f;
+
+ if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top)
+ aSelect.Add(i);
+ }
+ }
+
+ {
+ for (int i=0,sz=aSelect.GetSize(); i<sz; i++)
+ {
+ m_Annots.Add(sa[aSelect[i]]);
+ }
+ }
+
+ {
+ for (int i=aSelect.GetSize()-1; i>=0; i--)
+ {
+ sa.RemoveAt(aSelect[i]);
+ }
+ }
+
+ aSelect.RemoveAll();
+ }
+ }
+ sa.RemoveAll();
+ }
+ break;
+ case BAI_COLUMN:
+ {
+ CPDFSDK_SortAnnots sa;
+
+ {
+ for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++)
+ {
+ CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
+ ASSERT(pAnnot != NULL);
+
+ if (pAnnot->GetType() == m_sType
+ && pAnnot->GetSubType() == m_sSubType)
+ sa.Add(pAnnot);
+ }
+ }
+
+ if (sa.GetSize() > 0)
+ {
+ sa.Sort(CBA_AnnotIterator::CompareByTop, FALSE);
+ }
+
+ while (sa.GetSize() > 0)
+ {
+ int nLeftTopIndex = -1;
+
+ {
+ FX_FLOAT fLeft = -1.0f;
+
+ for (int i=sa.GetSize()-1; i>=0; i--)
+ {
+ CPDFSDK_Annot* pAnnot = sa.GetAt(i);
+ ASSERT(pAnnot != NULL);
+
+ CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
+
+ if (fLeft < 0)
+ {
+ nLeftTopIndex = 0;
+ fLeft = rcAnnot.left;
+ }
+ else if (rcAnnot.left < fLeft)
+ {
+ nLeftTopIndex = i;
+ fLeft = rcAnnot.left;
+ }
+ }
+ }
+
+ if (nLeftTopIndex >= 0)
+ {
+ CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(nLeftTopIndex);
+ ASSERT(pLeftTopAnnot != NULL);
+
+ CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot);
+
+ m_Annots.Add(pLeftTopAnnot);
+ sa.RemoveAt(nLeftTopIndex);
+
+ CFX_ArrayTemplate<int> aSelect;
+
+ {
+ for (int i=0,sz=sa.GetSize(); i<sz; i++)
+ {
+ CPDFSDK_Annot* pAnnot = sa.GetAt(i);
+ ASSERT(pAnnot != NULL);
+
+ CPDF_Rect rcAnnot = GetAnnotRect(pAnnot);
+
+ FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f;
+
+ if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right)
+ aSelect.Add(i);
+ }
+ }
+
+ {
+ for (int i=0,sz=aSelect.GetSize(); i<sz; i++)
+ {
+ m_Annots.Add(sa[aSelect[i]]);
+ }
+ }
+
+ {
+ for (int i=aSelect.GetSize()-1; i>=0; i--)
+ {
+ sa.RemoveAt(aSelect[i]);
+ }
+ }
+
+ aSelect.RemoveAll();
+ }
+ }
+ sa.RemoveAll();
+ }
+ break;
+ }
}
CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- ASSERT(pPDFAnnot != NULL);
+ CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+ ASSERT(pPDFAnnot != NULL);
- CPDF_Rect rcAnnot;
- pPDFAnnot->GetRect(rcAnnot);
+ CPDF_Rect rcAnnot;
+ pPDFAnnot->GetRect(rcAnnot);
- return rcAnnot;
+ return rcAnnot;
}
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index e54202a3e4..05c1a3dd89 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -141,9 +141,6 @@ CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset)
FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName)
{
CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
-// FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
-// FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
-
if(pFontMgr)
{
CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper;
@@ -166,19 +163,17 @@ FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteStri
}
return FALSE;
-// pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont);
-// return (pFont!=NULL);
}
static int CharSet2CP(int charset)
{
- if(charset == 128)
+ if (charset == 128)
return 932;
- else if(charset == 134)
+ if (charset == 134)
return 936;
- else if(charset == 129)
+ if (charset == 129)
return 949;
- else if(charset == 136)
+ if (charset == 136)
return 950;
return 0;
}
@@ -938,23 +933,18 @@ FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag)
pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point);
return TRUE;
}
- else
+ if(m_bOnWidget)
{
- if(m_bOnWidget)
+ m_bOnWidget = FALSE;
+ m_bExitWidget = TRUE;
+ m_bEnterWidget = FALSE;
+ if(m_CaptureWidget)
{
- m_bOnWidget = FALSE;
- m_bExitWidget = TRUE;
- m_bEnterWidget = FALSE;
- if(m_CaptureWidget)
- {
- pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
- m_CaptureWidget = NULL;
- }
+ pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
+ m_CaptureWidget = NULL;
}
- return FALSE;
}
-
- return FALSE;;
+ return FALSE;
}
FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag)
diff --git a/fpdfsdk/src/fsdk_rendercontext.cpp b/fpdfsdk/src/fsdk_rendercontext.cpp
index 4b7242d2b9..f96db94150 100644
--- a/fpdfsdk/src/fsdk_rendercontext.cpp
+++ b/fpdfsdk/src/fsdk_rendercontext.cpp
@@ -8,14 +8,14 @@
void CRenderContext::Clear()
{
- m_pDevice = NULL;
- m_pContext = NULL;
- m_pRenderer = NULL;
- m_pAnnots = NULL;
- m_pOptions = NULL;
+ m_pDevice = NULL;
+ m_pContext = NULL;
+ m_pRenderer = NULL;
+ m_pAnnots = NULL;
+ m_pOptions = NULL;
#ifdef _WIN32_WCE
- m_pBitmap = NULL;
- m_hBitmap = NULL;
+ m_pBitmap = NULL;
+ m_hBitmap = NULL;
#endif
}
@@ -35,15 +35,13 @@ CRenderContext::~CRenderContext()
IFSDK_PAUSE_Adapter::IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause )
{
- m_IPause = IPause;
+ m_IPause = IPause;
}
FX_BOOL IFSDK_PAUSE_Adapter::NeedToPauseNow()
{
- if (m_IPause->NeedToPauseNow)
- {
- return m_IPause->NeedToPauseNow(m_IPause);
- }else{
- return FALSE;
- }
+ if (m_IPause->NeedToPauseNow) {
+ return m_IPause->NeedToPauseNow(m_IPause);
+ }
+ return FALSE;
}
diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp
index 8e109b5cf8..63115c2626 100644
--- a/fpdfsdk/src/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/src/fxedit/fxet_edit.cpp
@@ -7,13 +7,13 @@
#include "../../include/fxedit/fxet_stub.h"
#include "../../include/fxedit/fxet_edit.h"
-#define FX_EDIT_UNDO_MAXITEM 10000
+#define FX_EDIT_UNDO_MAXITEM 10000
/* ---------------------------- CFX_Edit_Iterator ---------------------------- */
CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator * pVTIterator) :
- m_pEdit(pEdit),
- m_pVTIterator(pVTIterator)
+ m_pEdit(pEdit),
+ m_pVTIterator(pVTIterator)
{
}
@@ -21,121 +21,97 @@ CFX_Edit_Iterator::~CFX_Edit_Iterator()
{
}
-FX_BOOL CFX_Edit_Iterator::NextWord()
+FX_BOOL CFX_Edit_Iterator::NextWord()
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->NextWord();
+ return m_pVTIterator->NextWord();
}
FX_BOOL CFX_Edit_Iterator::NextLine()
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->NextLine();
+ return m_pVTIterator->NextLine();
}
FX_BOOL CFX_Edit_Iterator::NextSection()
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->NextSection();
+ return m_pVTIterator->NextSection();
}
-FX_BOOL CFX_Edit_Iterator::PrevWord()
+FX_BOOL CFX_Edit_Iterator::PrevWord()
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->PrevWord();
+ return m_pVTIterator->PrevWord();
}
-FX_BOOL CFX_Edit_Iterator::PrevLine()
+FX_BOOL CFX_Edit_Iterator::PrevLine()
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->PrevLine();
+ return m_pVTIterator->PrevLine();
}
-FX_BOOL CFX_Edit_Iterator::PrevSection()
+FX_BOOL CFX_Edit_Iterator::PrevSection()
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->PrevSection();
+ return m_pVTIterator->PrevSection();
}
FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word & word) const
{
- ASSERT(m_pEdit != NULL);
- ASSERT(m_pVTIterator != NULL);
-
- if (m_pVTIterator->GetWord(word))
- {
- word.ptWord = m_pEdit->VTToEdit(word.ptWord);
- return TRUE;
- }
+ ASSERT(m_pEdit);
- return FALSE;
+ if (m_pVTIterator->GetWord(word))
+ {
+ word.ptWord = m_pEdit->VTToEdit(word.ptWord);
+ return TRUE;
+ }
+ return FALSE;
}
FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line & line) const
{
- ASSERT(m_pEdit != NULL);
- ASSERT(m_pVTIterator != NULL);
+ ASSERT(m_pEdit);
- if (m_pVTIterator->GetLine(line))
- {
- line.ptLine = m_pEdit->VTToEdit(line.ptLine);
- return TRUE;
- }
-
- return FALSE;
+ if (m_pVTIterator->GetLine(line))
+ {
+ line.ptLine = m_pEdit->VTToEdit(line.ptLine);
+ return TRUE;
+ }
+ return FALSE;
}
FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section & section) const
{
- ASSERT(m_pEdit != NULL);
- ASSERT(m_pVTIterator != NULL);
-
- if (m_pVTIterator->GetSection(section))
- {
- section.rcSection = m_pEdit->VTToEdit(section.rcSection);
- return TRUE;
- }
+ ASSERT(m_pEdit);
- return FALSE;
+ if (m_pVTIterator->GetSection(section))
+ {
+ section.rcSection = m_pEdit->VTToEdit(section.rcSection);
+ return TRUE;
+ }
+ return FALSE;
}
void CFX_Edit_Iterator::SetAt(int32_t nWordIndex)
{
- ASSERT(m_pVTIterator != NULL);
-
- m_pVTIterator->SetAt(nWordIndex);
+ m_pVTIterator->SetAt(nWordIndex);
}
void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace & place)
{
- ASSERT(m_pVTIterator != NULL);
-
- m_pVTIterator->SetAt(place);
+ m_pVTIterator->SetAt(place);
}
const CPVT_WordPlace & CFX_Edit_Iterator::GetAt() const
{
- ASSERT(m_pVTIterator != NULL);
-
- return m_pVTIterator->GetAt();
+ return m_pVTIterator->GetAt();
}
IFX_Edit* CFX_Edit_Iterator::GetEdit() const
{
- return m_pEdit;
+ return m_pEdit;
}
/* --------------------------- CFX_Edit_Provider ------------------------------- */
CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap * pFontMap) : m_pFontMap(pFontMap)
{
- ASSERT(m_pFontMap != NULL);
+ ASSERT(m_pFontMap != NULL);
}
CFX_Edit_Provider::~CFX_Edit_Provider()
@@ -144,56 +120,56 @@ CFX_Edit_Provider::~CFX_Edit_Provider()
IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap()
{
- return m_pFontMap;
+ return m_pFontMap;
}
int32_t CFX_Edit_Provider::GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle)
{
- if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
- {
- FX_DWORD charcode = word;
+ if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
+ {
+ FX_DWORD charcode = word;
- if (pPDFFont->IsUnicodeCompatible())
- charcode = pPDFFont->CharCodeFromUnicode(word);
- else
- charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word);
+ if (pPDFFont->IsUnicodeCompatible())
+ charcode = pPDFFont->CharCodeFromUnicode(word);
+ else
+ charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word);
- if (charcode != -1)
- return pPDFFont->GetCharWidthF(charcode);
- }
+ if (charcode != -1)
+ return pPDFFont->GetCharWidthF(charcode);
+ }
- return 0;
+ return 0;
}
int32_t CFX_Edit_Provider::GetTypeAscent(int32_t nFontIndex)
{
- if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
- return pPDFFont->GetTypeAscent();
+ if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
+ return pPDFFont->GetTypeAscent();
- return 0;
+ return 0;
}
int32_t CFX_Edit_Provider::GetTypeDescent(int32_t nFontIndex)
{
- if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
- return pPDFFont->GetTypeDescent();
+ if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
+ return pPDFFont->GetTypeDescent();
- return 0;
+ return 0;
}
int32_t CFX_Edit_Provider::GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex)
{
- return m_pFontMap->GetWordFontIndex(word,charset,nFontIndex);
+ return m_pFontMap->GetWordFontIndex(word,charset,nFontIndex);
}
int32_t CFX_Edit_Provider::GetDefaultFontIndex()
{
- return 0;
+ return 0;
}
-FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word)
+FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word)
{
- return FX_EDIT_ISLATINWORD(word);
+ return FX_EDIT_ISLATINWORD(word);
}
/* --------------------------------- CFX_Edit_Refresh --------------------------------- */
@@ -208,272 +184,269 @@ CFX_Edit_Refresh::~CFX_Edit_Refresh()
void CFX_Edit_Refresh::BeginRefresh()
{
- m_RefreshRects.Empty();
- m_OldLineRects = m_NewLineRects;
+ m_RefreshRects.Empty();
+ m_OldLineRects = m_NewLineRects;
}
void CFX_Edit_Refresh::Push(const CPVT_WordRange & linerange,const CPDF_Rect & rect)
{
- m_NewLineRects.Add(linerange,rect);
+ m_NewLineRects.Add(linerange,rect);
}
void CFX_Edit_Refresh::NoAnalyse()
{
- {
- for (int32_t i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++)
- if (CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i))
- m_RefreshRects.Add(pOldRect->m_rcLine);
- }
+ {
+ for (int32_t i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++)
+ if (CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i))
+ m_RefreshRects.Add(pOldRect->m_rcLine);
+ }
- {
- for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++)
- if (CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i))
- m_RefreshRects.Add(pNewRect->m_rcLine);
- }
+ {
+ for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++)
+ if (CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i))
+ m_RefreshRects.Add(pNewRect->m_rcLine);
+ }
}
void CFX_Edit_Refresh::Analyse(int32_t nAlignment)
{
- FX_BOOL bLineTopChanged = FALSE;
- CPDF_Rect rcResult;
- FX_FLOAT fWidthDiff;
-
- int32_t szMax = FX_EDIT_MAX(m_OldLineRects.GetSize(),m_NewLineRects.GetSize());
- int32_t i = 0;
-
- while (i < szMax)
- {
- CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i);
- CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i);
-
- if (pOldRect)
- {
- if (pNewRect)
- {
- if (bLineTopChanged)
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- m_RefreshRects.Add(rcResult);
- }
- else
- {
- if (*pNewRect != *pOldRect)
- {
- if (!pNewRect->IsSameTop(*pOldRect) || !pNewRect->IsSameHeight(*pOldRect))
- {
- bLineTopChanged = TRUE;
- continue;
- }
-
- if (nAlignment == 0)
- {
- if (pNewRect->m_wrLine.BeginPos != pOldRect->m_wrLine.BeginPos)
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- m_RefreshRects.Add(rcResult);
- }
- else
- {
- if (!pNewRect->IsSameLeft(*pOldRect))
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- }
- else
- {
- fWidthDiff = pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width();
- rcResult = pNewRect->m_rcLine;
- if (fWidthDiff > 0.0f)
- rcResult.left = rcResult.right - fWidthDiff;
- else
- {
- rcResult.left = rcResult.right;
- rcResult.right += (-fWidthDiff);
- }
- }
- m_RefreshRects.Add(rcResult);
- }
- }
- else
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- m_RefreshRects.Add(rcResult);
- }
- }
- else
- {
- //don't need to do anything
- }
- }
- }
- else
- {
- m_RefreshRects.Add(pOldRect->m_rcLine);
- }
- }
- else
- {
- if (pNewRect)
- {
- m_RefreshRects.Add(pNewRect->m_rcLine);
- }
- else
- {
- //error
- }
- }
- i++;
- }
+ FX_BOOL bLineTopChanged = FALSE;
+ CPDF_Rect rcResult;
+ FX_FLOAT fWidthDiff;
+
+ int32_t szMax = FX_EDIT_MAX(m_OldLineRects.GetSize(),m_NewLineRects.GetSize());
+ int32_t i = 0;
+
+ while (i < szMax)
+ {
+ CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i);
+ CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i);
+
+ if (pOldRect)
+ {
+ if (pNewRect)
+ {
+ if (bLineTopChanged)
+ {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ m_RefreshRects.Add(rcResult);
+ }
+ else
+ {
+ if (*pNewRect != *pOldRect)
+ {
+ if (!pNewRect->IsSameTop(*pOldRect) || !pNewRect->IsSameHeight(*pOldRect))
+ {
+ bLineTopChanged = TRUE;
+ continue;
+ }
+
+ if (nAlignment == 0)
+ {
+ if (pNewRect->m_wrLine.BeginPos != pOldRect->m_wrLine.BeginPos)
+ {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ m_RefreshRects.Add(rcResult);
+ }
+ else
+ {
+ if (!pNewRect->IsSameLeft(*pOldRect))
+ {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ }
+ else
+ {
+ fWidthDiff = pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width();
+ rcResult = pNewRect->m_rcLine;
+ if (fWidthDiff > 0.0f)
+ rcResult.left = rcResult.right - fWidthDiff;
+ else
+ {
+ rcResult.left = rcResult.right;
+ rcResult.right += (-fWidthDiff);
+ }
+ }
+ m_RefreshRects.Add(rcResult);
+ }
+ }
+ else
+ {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ m_RefreshRects.Add(rcResult);
+ }
+ }
+ else
+ {
+ //don't need to do anything
+ }
+ }
+ }
+ else
+ {
+ m_RefreshRects.Add(pOldRect->m_rcLine);
+ }
+ }
+ else
+ {
+ if (pNewRect)
+ {
+ m_RefreshRects.Add(pNewRect->m_rcLine);
+ }
+ else
+ {
+ //error
+ }
+ }
+ i++;
+ }
}
void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect & rect)
{
- m_RefreshRects.Add(rect);
+ m_RefreshRects.Add(rect);
}
const CFX_Edit_RectArray * CFX_Edit_Refresh::GetRefreshRects() const
{
- return &m_RefreshRects;
+ return &m_RefreshRects;
}
void CFX_Edit_Refresh::EndRefresh()
{
- m_RefreshRects.Empty();
+ m_RefreshRects.Empty();
}
/* ------------------------------------- CFX_Edit_Undo ------------------------------------- */
CFX_Edit_Undo::CFX_Edit_Undo(int32_t nBufsize) : m_nCurUndoPos(0),
- m_nBufSize(nBufsize),
- m_bModified(FALSE),
- m_bVirgin(TRUE),
- m_bWorking(FALSE)
+ m_nBufSize(nBufsize),
+ m_bModified(FALSE),
+ m_bVirgin(TRUE),
+ m_bWorking(FALSE)
{
}
CFX_Edit_Undo::~CFX_Edit_Undo()
{
- Reset();
+ Reset();
}
FX_BOOL CFX_Edit_Undo::CanUndo() const
{
- return m_nCurUndoPos > 0;
+ return m_nCurUndoPos > 0;
}
void CFX_Edit_Undo::Undo()
{
- m_bWorking = TRUE;
+ m_bWorking = TRUE;
- if (m_nCurUndoPos > 0)
- {
- IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos-1);
- ASSERT(pItem != NULL);
+ if (m_nCurUndoPos > 0)
+ {
+ IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos-1);
+ ASSERT(pItem != NULL);
- pItem->Undo();
+ pItem->Undo();
- m_nCurUndoPos--;
- m_bModified = (m_nCurUndoPos != 0);
- }
+ m_nCurUndoPos--;
+ m_bModified = (m_nCurUndoPos != 0);
+ }
- m_bWorking = FALSE;
+ m_bWorking = FALSE;
}
-FX_BOOL CFX_Edit_Undo::CanRedo() const
+FX_BOOL CFX_Edit_Undo::CanRedo() const
{
- return m_nCurUndoPos < m_UndoItemStack.GetSize();
+ return m_nCurUndoPos < m_UndoItemStack.GetSize();
}
void CFX_Edit_Undo::Redo()
{
- m_bWorking = TRUE;
+ m_bWorking = TRUE;
- int32_t nStackSize = m_UndoItemStack.GetSize();
+ int32_t nStackSize = m_UndoItemStack.GetSize();
- if (m_nCurUndoPos < nStackSize)
- {
- IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos);
- ASSERT(pItem != NULL);
+ if (m_nCurUndoPos < nStackSize)
+ {
+ IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos);
+ ASSERT(pItem != NULL);
- pItem->Redo();
+ pItem->Redo();
- m_nCurUndoPos++;
- m_bModified = (m_nCurUndoPos != 0);
- }
+ m_nCurUndoPos++;
+ m_bModified = (m_nCurUndoPos != 0);
+ }
- m_bWorking = FALSE;
+ m_bWorking = FALSE;
}
-FX_BOOL CFX_Edit_Undo::IsWorking() const
+FX_BOOL CFX_Edit_Undo::IsWorking() const
{
- return m_bWorking;
+ return m_bWorking;
}
void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem)
{
- ASSERT(!m_bWorking);
- ASSERT(pItem != NULL);
- ASSERT(m_nBufSize > 1);
+ ASSERT(!m_bWorking);
+ ASSERT(pItem != NULL);
+ ASSERT(m_nBufSize > 1);
- if (m_nCurUndoPos < m_UndoItemStack.GetSize())
- RemoveTails();
+ if (m_nCurUndoPos < m_UndoItemStack.GetSize())
+ RemoveTails();
- if (m_UndoItemStack.GetSize() >= m_nBufSize)
- {
- RemoveHeads();
- m_bVirgin = FALSE;
- }
+ if (m_UndoItemStack.GetSize() >= m_nBufSize)
+ {
+ RemoveHeads();
+ m_bVirgin = FALSE;
+ }
- m_UndoItemStack.Add(pItem);
- m_nCurUndoPos = m_UndoItemStack.GetSize();
+ m_UndoItemStack.Add(pItem);
+ m_nCurUndoPos = m_UndoItemStack.GetSize();
- m_bModified = (m_nCurUndoPos != 0);
+ m_bModified = (m_nCurUndoPos != 0);
}
-FX_BOOL CFX_Edit_Undo::IsModified() const
+FX_BOOL CFX_Edit_Undo::IsModified() const
{
- if (m_bVirgin)
- return m_bModified;
- else
- return TRUE;
+ return m_bVirgin ? m_bModified : TRUE;
}
IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex)
{
- if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize())
- return m_UndoItemStack.GetAt(nIndex);
+ if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize())
+ return m_UndoItemStack.GetAt(nIndex);
- return NULL;
+ return NULL;
}
void CFX_Edit_Undo::RemoveHeads()
{
- ASSERT(m_UndoItemStack.GetSize() > 1);
+ ASSERT(m_UndoItemStack.GetSize() > 1);
- delete m_UndoItemStack.GetAt(0);
- m_UndoItemStack.RemoveAt(0);
+ delete m_UndoItemStack.GetAt(0);
+ m_UndoItemStack.RemoveAt(0);
}
void CFX_Edit_Undo::RemoveTails()
{
- for (int32_t i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--)
- {
- delete m_UndoItemStack.GetAt(i);
- m_UndoItemStack.RemoveAt(i);
- }
+ for (int32_t i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--)
+ {
+ delete m_UndoItemStack.GetAt(i);
+ m_UndoItemStack.RemoveAt(i);
+ }
}
void CFX_Edit_Undo::Reset()
{
- for (int32_t i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++)
- {
- delete m_UndoItemStack.GetAt(i);
- }
- m_nCurUndoPos = 0;
- m_UndoItemStack.RemoveAll();
+ for (int32_t i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++)
+ {
+ delete m_UndoItemStack.GetAt(i);
+ }
+ m_nCurUndoPos = 0;
+ m_UndoItemStack.RemoveAll();
}
/* -------------------------------- CFX_Edit_GroupUndoItem -------------------------------- */
@@ -484,76 +457,76 @@ CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) : m
CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem()
{
- for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
- {
- delete m_Items[i];
- }
+ for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
+ {
+ delete m_Items[i];
+ }
- m_Items.RemoveAll();
+ m_Items.RemoveAll();
}
void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem)
{
- ASSERT(pUndoItem != NULL);
+ ASSERT(pUndoItem != NULL);
- pUndoItem->SetFirst(FALSE);
- pUndoItem->SetLast(FALSE);
+ pUndoItem->SetFirst(FALSE);
+ pUndoItem->SetLast(FALSE);
- m_Items.Add(pUndoItem);
+ m_Items.Add(pUndoItem);
- if (m_sTitle.IsEmpty())
- m_sTitle = pUndoItem->GetUndoTitle();
+ if (m_sTitle.IsEmpty())
+ m_sTitle = pUndoItem->GetUndoTitle();
}
void CFX_Edit_GroupUndoItem::UpdateItems()
{
- if (m_Items.GetSize() > 0)
- {
- CFX_Edit_UndoItem* pFirstItem = m_Items[0];
- ASSERT(pFirstItem != NULL);
- pFirstItem->SetFirst(TRUE);
+ if (m_Items.GetSize() > 0)
+ {
+ CFX_Edit_UndoItem* pFirstItem = m_Items[0];
+ ASSERT(pFirstItem != NULL);
+ pFirstItem->SetFirst(TRUE);
- CFX_Edit_UndoItem* pLastItem = m_Items[m_Items.GetSize() - 1];
- ASSERT(pLastItem != NULL);
- pLastItem->SetLast(TRUE);
- }
+ CFX_Edit_UndoItem* pLastItem = m_Items[m_Items.GetSize() - 1];
+ ASSERT(pLastItem != NULL);
+ pLastItem->SetLast(TRUE);
+ }
}
void CFX_Edit_GroupUndoItem::Undo()
{
- for (int i=m_Items.GetSize()-1; i>=0; i--)
- {
- CFX_Edit_UndoItem* pUndoItem = m_Items[i];
- ASSERT(pUndoItem != NULL);
+ for (int i=m_Items.GetSize()-1; i>=0; i--)
+ {
+ CFX_Edit_UndoItem* pUndoItem = m_Items[i];
+ ASSERT(pUndoItem != NULL);
- pUndoItem->Undo();
- }
+ pUndoItem->Undo();
+ }
}
void CFX_Edit_GroupUndoItem::Redo()
{
- for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
- {
- CFX_Edit_UndoItem* pUndoItem = m_Items[i];
- ASSERT(pUndoItem != NULL);
+ for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
+ {
+ CFX_Edit_UndoItem* pUndoItem = m_Items[i];
+ ASSERT(pUndoItem != NULL);
- pUndoItem->Redo();
- }
+ pUndoItem->Redo();
+ }
}
CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle()
{
- return m_sTitle;
+ return m_sTitle;
}
/* ------------------------------------- CFX_Edit_UndoItem derived classes ------------------------------------- */
CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- FX_WORD word, int32_t charset, const CPVT_WordProps * pWordProps)
- : m_pEdit(pEdit), m_wpOld(wpOldPlace), m_wpNew(wpNewPlace), m_Word(word), m_nCharset(charset), m_WordProps()
+ FX_WORD word, int32_t charset, const CPVT_WordProps * pWordProps)
+ : m_pEdit(pEdit), m_wpOld(wpOldPlace), m_wpNew(wpNewPlace), m_Word(word), m_nCharset(charset), m_WordProps()
{
- if (pWordProps)
- m_WordProps = *pWordProps;
+ if (pWordProps)
+ m_WordProps = *pWordProps;
}
CFXEU_InsertWord::~CFXEU_InsertWord()
@@ -562,38 +535,38 @@ CFXEU_InsertWord::~CFXEU_InsertWord()
void CFXEU_InsertWord::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
+ }
}
void CFXEU_InsertWord::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- m_pEdit->Backspace(FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ m_pEdit->Backspace(FALSE,TRUE);
+ }
}
/* -------------------------------------------------------------------------- */
CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_SecProps(),
- m_WordProps()
+ const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) :
+ m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_SecProps(),
+ m_WordProps()
{
- if (pSecProps)
- m_SecProps = *pSecProps;
- if (pWordProps)
- m_WordProps = *pWordProps;
+ if (pSecProps)
+ m_SecProps = *pSecProps;
+ if (pWordProps)
+ m_WordProps = *pWordProps;
}
CFXEU_InsertReturn::~CFXEU_InsertReturn()
@@ -602,37 +575,37 @@ CFXEU_InsertReturn::~CFXEU_InsertReturn()
void CFXEU_InsertReturn::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
+ }
}
void CFXEU_InsertReturn::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- m_pEdit->Backspace(FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ m_pEdit->Backspace(FALSE,TRUE);
+ }
}
/* -------------------------------------------------------------------------- */
//CFXEU_Backspace
CFXEU_Backspace::CFXEU_Backspace(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- FX_WORD word, int32_t charset,
- const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_Word(word),
- m_nCharset(charset),
- m_SecProps(SecProps),
- m_WordProps(WordProps)
+ FX_WORD word, int32_t charset,
+ const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps) :
+ m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_Word(word),
+ m_nCharset(charset),
+ m_SecProps(SecProps),
+ m_WordProps(WordProps)
{
}
@@ -642,45 +615,45 @@ CFXEU_Backspace::~CFXEU_Backspace()
void CFXEU_Backspace::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->Backspace(FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->Backspace(FALSE,TRUE);
+ }
}
void CFXEU_Backspace::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- if (m_wpNew.SecCmp(m_wpOld) != 0)
- {
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
- }
- else
- {
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ if (m_wpNew.SecCmp(m_wpOld) != 0)
+ {
+ m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
+ }
+ else
+ {
+ m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
//CFXEU_Delete
CFXEU_Delete::CFXEU_Delete(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- FX_WORD word, int32_t charset,
- const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps, FX_BOOL bSecEnd) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_Word(word),
- m_nCharset(charset),
- m_SecProps(SecProps),
- m_WordProps(WordProps),
- m_bSecEnd(bSecEnd)
+ FX_WORD word, int32_t charset,
+ const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps, FX_BOOL bSecEnd) :
+ m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_Word(word),
+ m_nCharset(charset),
+ m_SecProps(SecProps),
+ m_WordProps(WordProps),
+ m_bSecEnd(bSecEnd)
{
}
@@ -690,38 +663,38 @@ CFXEU_Delete::~CFXEU_Delete()
void CFXEU_Delete::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->Delete(FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->Delete(FALSE,TRUE);
+ }
}
void CFXEU_Delete::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- if (m_bSecEnd)
- {
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
- }
- else
- {
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ if (m_bSecEnd)
+ {
+ m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
+ }
+ else
+ {
+ m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
//CFXEU_Clear
CFXEU_Clear::CFXEU_Clear(CFX_Edit * pEdit, const CPVT_WordRange & wrSel, const CFX_WideString & swText) :
- m_pEdit(pEdit),
- m_wrSel(wrSel),
- m_swText(swText)
+ m_pEdit(pEdit),
+ m_wrSel(wrSel),
+ m_swText(swText)
{
}
@@ -731,39 +704,39 @@ CFXEU_Clear::~CFXEU_Clear()
void CFXEU_Clear::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- m_pEdit->Clear(FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
+ m_pEdit->Clear(FALSE,TRUE);
+ }
}
void CFXEU_Clear::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wrSel.BeginPos);
- m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, TRUE);
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wrSel.BeginPos);
+ m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, TRUE);
+ m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
+ }
}
/* -------------------------------------------------------------------------- */
//CFXEU_ClearRich
CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- const CPVT_WordRange & wrSel, FX_WORD word, int32_t charset,
- const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_wrSel(wrSel),
- m_Word(word),
- m_nCharset(charset),
- m_SecProps(SecProps),
- m_WordProps(WordProps)
+ const CPVT_WordRange & wrSel, FX_WORD word, int32_t charset,
+ const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps) :
+ m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_wrSel(wrSel),
+ m_Word(word),
+ m_nCharset(charset),
+ m_SecProps(SecProps),
+ m_WordProps(WordProps)
{
}
@@ -773,54 +746,54 @@ CFXEU_ClearRich::~CFXEU_ClearRich()
void CFXEU_ClearRich::Redo()
{
- if (m_pEdit && IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- m_pEdit->Clear(FALSE,TRUE);
- }
+ if (m_pEdit && IsLast())
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
+ m_pEdit->Clear(FALSE,TRUE);
+ }
}
void CFXEU_ClearRich::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- if (m_wpNew.SecCmp(m_wpOld) != 0)
- {
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,FALSE);
- }
- else
- {
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,FALSE);
- }
-
- if (IsFirst())
- {
- m_pEdit->PaintInsertText(m_wrSel.BeginPos,m_wrSel.EndPos);
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ if (m_wpNew.SecCmp(m_wpOld) != 0)
+ {
+ m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,FALSE);
+ }
+ else
+ {
+ m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,FALSE);
+ }
+
+ if (IsFirst())
+ {
+ m_pEdit->PaintInsertText(m_wrSel.BeginPos,m_wrSel.EndPos);
+ m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
//CFXEU_InsertText
CFXEU_InsertText::CFXEU_InsertText(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- const CFX_WideString & swText, int32_t charset,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_swText(swText),
- m_nCharset(charset),
- m_SecProps(),
- m_WordProps()
-{
- if (pSecProps)
- m_SecProps = *pSecProps;
- if (pWordProps)
- m_WordProps = *pWordProps;
+ const CFX_WideString & swText, int32_t charset,
+ const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) :
+ m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_swText(swText),
+ m_nCharset(charset),
+ m_SecProps(),
+ m_WordProps()
+{
+ if (pSecProps)
+ m_SecProps = *pSecProps;
+ if (pWordProps)
+ m_WordProps = *pWordProps;
}
CFXEU_InsertText::~CFXEU_InsertText()
@@ -829,37 +802,37 @@ CFXEU_InsertText::~CFXEU_InsertText()
void CFXEU_InsertText::Redo()
{
- if (m_pEdit && IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps, FALSE, TRUE);
- }
+ if (m_pEdit && IsLast())
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps, FALSE, TRUE);
+ }
}
void CFXEU_InsertText::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetSel(m_wpOld,m_wpNew);
- m_pEdit->Clear(FALSE,TRUE);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->SetSel(m_wpOld,m_wpNew);
+ m_pEdit->Clear(FALSE,TRUE);
+ }
}
/* -------------------------------------------------------------------------- */
CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit * pEdit, const CPVT_WordPlace & place, EDIT_PROPS_E ep,
- const CPVT_SecProps & oldsecprops, const CPVT_WordProps & oldwordprops,
- const CPVT_SecProps & newsecprops, const CPVT_WordProps & newwordprops, const CPVT_WordRange & range)
- : m_pEdit(pEdit),
- m_wpPlace(place),
- m_wrPlace(range),
- m_eProps(ep),
- m_OldSecProps(oldsecprops),
- m_NewSecProps(newsecprops),
- m_OldWordProps(oldwordprops),
- m_NewWordProps(newwordprops)
+ const CPVT_SecProps & oldsecprops, const CPVT_WordProps & oldwordprops,
+ const CPVT_SecProps & newsecprops, const CPVT_WordProps & newwordprops, const CPVT_WordRange & range)
+ : m_pEdit(pEdit),
+ m_wpPlace(place),
+ m_wrPlace(range),
+ m_eProps(ep),
+ m_OldSecProps(oldsecprops),
+ m_NewSecProps(newsecprops),
+ m_OldWordProps(oldwordprops),
+ m_NewWordProps(newwordprops)
{
}
@@ -869,42 +842,42 @@ CFXEU_SetSecProps::~CFXEU_SetSecProps()
void CFXEU_SetSecProps::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_NewSecProps,&m_NewWordProps,m_wrPlace,FALSE);
- if (IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_NewSecProps,&m_NewWordProps,m_wrPlace,FALSE);
+ if (IsLast())
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
+ }
+ }
}
void CFXEU_SetSecProps::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_OldSecProps,&m_OldWordProps,m_wrPlace,FALSE);
- if (IsFirst())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_OldSecProps,&m_OldWordProps,m_wrPlace,FALSE);
+ if (IsFirst())
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit * pEdit, const CPVT_WordPlace & place, EDIT_PROPS_E ep,
- const CPVT_WordProps & oldprops, const CPVT_WordProps & newprops, const CPVT_WordRange & range)
- : m_pEdit(pEdit),
- m_wpPlace(place),
- m_wrPlace(range),
- m_eProps(ep),
- m_OldWordProps(oldprops),
- m_NewWordProps(newprops)
+ const CPVT_WordProps & oldprops, const CPVT_WordProps & newprops, const CPVT_WordRange & range)
+ : m_pEdit(pEdit),
+ m_wpPlace(place),
+ m_wrPlace(range),
+ m_eProps(ep),
+ m_OldWordProps(oldprops),
+ m_NewWordProps(newprops)
{
}
@@ -914,59 +887,59 @@ CFXEU_SetWordProps::~CFXEU_SetWordProps()
void CFXEU_SetWordProps::Redo()
{
- if (m_pEdit)
- {
- m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_NewWordProps,m_wrPlace,FALSE);
- if (IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_NewWordProps,m_wrPlace,FALSE);
+ if (IsLast())
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
+ }
+ }
}
void CFXEU_SetWordProps::Undo()
{
- if (m_pEdit)
- {
- m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_OldWordProps,m_wrPlace,FALSE);
- if (IsFirst())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_OldWordProps,m_wrPlace,FALSE);
+ if (IsFirst())
+ {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
+ }
+ }
}
/* ------------------------------------- CFX_Edit ------------------------------------- */
CFX_Edit::CFX_Edit(IPDF_VariableText * pVT) :
- m_pVT(pVT),
- m_pNotify(NULL),
- m_pOprNotify(NULL),
- m_pVTProvide(NULL),
- m_wpCaret(-1,-1,-1),
- m_wpOldCaret(-1,-1,-1),
- m_SelState(),
- m_ptScrollPos(0,0),
- m_ptRefreshScrollPos(0,0),
- m_bEnableScroll(FALSE),
- m_pIterator(NULL),
- m_ptCaret(0.0f,0.0f),
- m_Undo(FX_EDIT_UNDO_MAXITEM),
- m_nAlignment(0),
- m_bNotifyFlag(FALSE),
- m_bEnableOverflow(FALSE),
- m_bEnableRefresh(TRUE),
- m_rcOldContent(0.0f,0.0f,0.0f,0.0f),
- m_bEnableUndo(TRUE),
- m_bNotify(TRUE),
- m_bOprNotify(FALSE),
- m_pGroupUndoItem(NULL)
-{
- ASSERT(pVT != NULL);
+ m_pVT(pVT),
+ m_pNotify(NULL),
+ m_pOprNotify(NULL),
+ m_pVTProvide(NULL),
+ m_wpCaret(-1,-1,-1),
+ m_wpOldCaret(-1,-1,-1),
+ m_SelState(),
+ m_ptScrollPos(0,0),
+ m_ptRefreshScrollPos(0,0),
+ m_bEnableScroll(FALSE),
+ m_pIterator(NULL),
+ m_ptCaret(0.0f,0.0f),
+ m_Undo(FX_EDIT_UNDO_MAXITEM),
+ m_nAlignment(0),
+ m_bNotifyFlag(FALSE),
+ m_bEnableOverflow(FALSE),
+ m_bEnableRefresh(TRUE),
+ m_rcOldContent(0.0f,0.0f,0.0f,0.0f),
+ m_bEnableUndo(TRUE),
+ m_bNotify(TRUE),
+ m_bOprNotify(FALSE),
+ m_pGroupUndoItem(NULL)
+{
+ ASSERT(pVT != NULL);
}
CFX_Edit::~CFX_Edit()
@@ -982,9 +955,9 @@ CFX_Edit::~CFX_Edit()
void CFX_Edit::Initialize()
{
- m_pVT->Initialize();
- SetCaret(m_pVT->GetBeginWordPlace());
- SetCaretOrigin();
+ m_pVT->Initialize();
+ SetCaret(m_pVT->GetBeginWordPlace());
+ SetCaretOrigin();
}
void CFX_Edit::SetFontMap(IFX_Edit_FontMap * pFontMap)
@@ -995,2458 +968,2458 @@ void CFX_Edit::SetFontMap(IFX_Edit_FontMap * pFontMap)
void CFX_Edit::SetVTProvider(IPDF_VariableText_Provider* pProvider)
{
- m_pVT->SetProvider(pProvider);
+ m_pVT->SetProvider(pProvider);
}
void CFX_Edit::SetNotify(IFX_Edit_Notify* pNotify)
{
- m_pNotify = pNotify;
+ m_pNotify = pNotify;
}
void CFX_Edit::SetOprNotify(IFX_Edit_OprNotify* pOprNotify)
{
- m_pOprNotify = pOprNotify;
+ m_pOprNotify = pOprNotify;
}
IFX_Edit_Iterator * CFX_Edit::GetIterator()
{
- if (!m_pIterator)
- m_pIterator = new CFX_Edit_Iterator(this,m_pVT->GetIterator());
+ if (!m_pIterator)
+ m_pIterator = new CFX_Edit_Iterator(this,m_pVT->GetIterator());
- return m_pIterator;
+ return m_pIterator;
}
-IPDF_VariableText * CFX_Edit::GetVariableText()
+IPDF_VariableText * CFX_Edit::GetVariableText()
{
- return m_pVT;
+ return m_pVT;
}
IFX_Edit_FontMap* CFX_Edit::GetFontMap()
{
- if (m_pVTProvide)
- return m_pVTProvide->GetFontMap();
+ if (m_pVTProvide)
+ return m_pVTProvide->GetFontMap();
- return NULL;
+ return NULL;
}
void CFX_Edit::SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetPlateRect(rect);
- m_ptScrollPos = CPDF_Point(rect.left,rect.top);
- if (bPaint) Paint();
+ m_pVT->SetPlateRect(rect);
+ m_ptScrollPos = CPDF_Point(rect.left,rect.top);
+ if (bPaint) Paint();
}
void CFX_Edit::SetAlignmentH(int32_t nFormat/* =0 */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetAlignment(nFormat);
- if (bPaint) Paint();
+ m_pVT->SetAlignment(nFormat);
+ if (bPaint) Paint();
}
void CFX_Edit::SetAlignmentV(int32_t nFormat/* =0 */, FX_BOOL bPaint/* = TRUE*/)
{
- m_nAlignment = nFormat;
- if (bPaint) Paint();
+ m_nAlignment = nFormat;
+ if (bPaint) Paint();
}
void CFX_Edit::SetPasswordChar(FX_WORD wSubWord/* ='*' */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetPasswordChar(wSubWord);
- if (bPaint) Paint();
+ m_pVT->SetPasswordChar(wSubWord);
+ if (bPaint) Paint();
}
void CFX_Edit::SetLimitChar(int32_t nLimitChar/* =0 */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetLimitChar(nLimitChar);
- if (bPaint) Paint();
+ m_pVT->SetLimitChar(nLimitChar);
+ if (bPaint) Paint();
}
void CFX_Edit::SetCharArray(int32_t nCharArray/* =0 */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetCharArray(nCharArray);
- if (bPaint) Paint();
+ m_pVT->SetCharArray(nCharArray);
+ if (bPaint) Paint();
}
void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace/* =0.0f */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetCharSpace(fCharSpace);
- if (bPaint) Paint();
+ m_pVT->SetCharSpace(fCharSpace);
+ if (bPaint) Paint();
}
void CFX_Edit::SetHorzScale(int32_t nHorzScale/* =100 */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetHorzScale(nHorzScale);
- if (bPaint) Paint();
+ m_pVT->SetHorzScale(nHorzScale);
+ if (bPaint) Paint();
}
void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetMultiLine(bMultiLine);
- if (bPaint) Paint();
+ m_pVT->SetMultiLine(bMultiLine);
+ if (bPaint) Paint();
}
void CFX_Edit::SetAutoReturn(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetAutoReturn(bAuto);
- if (bPaint) Paint();
+ m_pVT->SetAutoReturn(bAuto);
+ if (bPaint) Paint();
}
void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetLineLeading(fLineLeading);
- if (bPaint) Paint();
+ m_pVT->SetLineLeading(fLineLeading);
+ if (bPaint) Paint();
}
void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetAutoFontSize(bAuto);
- if (bPaint) Paint();
+ m_pVT->SetAutoFontSize(bAuto);
+ if (bPaint) Paint();
}
void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetFontSize(fFontSize);
- if (bPaint) Paint();
+ m_pVT->SetFontSize(fFontSize);
+ if (bPaint) Paint();
}
void CFX_Edit::SetAutoScroll(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
{
- m_bEnableScroll = bAuto;
- if (bPaint) Paint();
+ m_bEnableScroll = bAuto;
+ if (bPaint) Paint();
}
void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed /*= FALSE*/, FX_BOOL bPaint/* = TRUE*/)
{
- m_bEnableOverflow = bAllowed;
- if (bPaint) Paint();
+ m_bEnableOverflow = bAllowed;
+ if (bPaint) Paint();
}
void CFX_Edit::SetSel(int32_t nStartChar,int32_t nEndChar)
{
- if (m_pVT->IsValid())
- {
- if (nStartChar == 0 && nEndChar < 0)
- {
- SelectAll();
- }
- else if (nStartChar < 0)
- {
- SelectNone();
- }
- else
- {
- if (nStartChar < nEndChar)
- {
- SetSel(m_pVT->WordIndexToWordPlace(nStartChar),m_pVT->WordIndexToWordPlace(nEndChar));
- }
- else
- {
- SetSel(m_pVT->WordIndexToWordPlace(nEndChar),m_pVT->WordIndexToWordPlace(nStartChar));
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (nStartChar == 0 && nEndChar < 0)
+ {
+ SelectAll();
+ }
+ else if (nStartChar < 0)
+ {
+ SelectNone();
+ }
+ else
+ {
+ if (nStartChar < nEndChar)
+ {
+ SetSel(m_pVT->WordIndexToWordPlace(nStartChar),m_pVT->WordIndexToWordPlace(nEndChar));
+ }
+ else
+ {
+ SetSel(m_pVT->WordIndexToWordPlace(nEndChar),m_pVT->WordIndexToWordPlace(nStartChar));
+ }
+ }
+ }
}
void CFX_Edit::SetSel(const CPVT_WordPlace & begin,const CPVT_WordPlace & end)
{
- if (m_pVT->IsValid())
- {
- SelectNone();
+ if (m_pVT->IsValid())
+ {
+ SelectNone();
- m_SelState.Set(begin,end);
+ m_SelState.Set(begin,end);
- SetCaret(m_SelState.EndPos);
+ SetCaret(m_SelState.EndPos);
- if (m_SelState.IsExist())
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_SelState.BeginPos,m_SelState.EndPos);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretInfo();
- }
- else
- {
- ScrollToCaret();
- SetCaretInfo();
- }
- }
+ if (m_SelState.IsExist())
+ {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_SelState.BeginPos,m_SelState.EndPos);
+ Refresh(RP_OPTIONAL,&wr);
+ SetCaretInfo();
+ }
+ else
+ {
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ }
}
void CFX_Edit::GetSel(int32_t & nStartChar, int32_t & nEndChar) const
{
- nStartChar = -1;
- nEndChar = -1;
-
- if (m_pVT->IsValid())
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
- {
- nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
- nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
- }
- else
- {
- nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
- nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
- }
- }
- else
- {
- nStartChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
- nEndChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
- }
- }
+ nStartChar = -1;
+ nEndChar = -1;
+
+ if (m_pVT->IsValid())
+ {
+ if (m_SelState.IsExist())
+ {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
+ {
+ nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
+ nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
+ }
+ else
+ {
+ nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
+ nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
+ }
+ }
+ else
+ {
+ nStartChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
+ nEndChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
+ }
+ }
}
int32_t CFX_Edit::GetCaret() const
{
- if (m_pVT->IsValid())
- return m_pVT->WordPlaceToWordIndex(m_wpCaret);
+ if (m_pVT->IsValid())
+ return m_pVT->WordPlaceToWordIndex(m_wpCaret);
- return -1;
+ return -1;
}
CPVT_WordPlace CFX_Edit::GetCaretWordPlace() const
{
- return m_wpCaret;
+ return m_wpCaret;
}
CFX_WideString CFX_Edit::GetText() const
{
- CFX_WideString swRet;
+ CFX_WideString swRet;
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- FX_BOOL bRich = m_pVT->IsRichText();
+ if (m_pVT->IsValid())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ FX_BOOL bRich = m_pVT->IsRichText();
- pIterator->SetAt(0);
+ pIterator->SetAt(0);
- CPVT_Word wordinfo;
- CPVT_WordPlace oldplace = pIterator->GetAt();
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
+ CPVT_Word wordinfo;
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+ while (pIterator->NextWord())
+ {
+ CPVT_WordPlace place = pIterator->GetAt();
- if (pIterator->GetWord(wordinfo))
- {
- if (bRich)
- {
- swRet += wordinfo.Word;
- }
- else
- {
- swRet += wordinfo.Word;
- }
- }
+ if (pIterator->GetWord(wordinfo))
+ {
+ if (bRich)
+ {
+ swRet += wordinfo.Word;
+ }
+ else
+ {
+ swRet += wordinfo.Word;
+ }
+ }
- if (oldplace.SecCmp(place) != 0)
- {
- swRet += 0x0D;
- swRet += 0x0A;
- }
+ if (oldplace.SecCmp(place) != 0)
+ {
+ swRet += 0x0D;
+ swRet += 0x0A;
+ }
- oldplace = place;
- }
- }
- }
+ oldplace = place;
+ }
+ }
+ }
- return swRet;
+ return swRet;
}
CFX_WideString CFX_Edit::GetRangeText(const CPVT_WordRange & range) const
{
- CFX_WideString swRet;
-
- if (m_pVT->IsValid())
- {
- FX_BOOL bRich = m_pVT->IsRichText();
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = range;
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
-
- CPVT_Word wordinfo;
- CPVT_WordPlace oldplace = wrTemp.BeginPos;
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0)break;
-
- if (pIterator->GetWord(wordinfo))
- {
- if (bRich)
- {
- swRet += wordinfo.Word;
- }
- else
- {
- swRet += wordinfo.Word;
- }
- }
-
- if (oldplace.SecCmp(place) != 0)
- {
- swRet += 0x0D;
- swRet += 0x0A;
- }
-
- oldplace = place;
- }
- }
- }
-
- return swRet;
+ CFX_WideString swRet;
+
+ if (m_pVT->IsValid())
+ {
+ FX_BOOL bRich = m_pVT->IsRichText();
+
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordRange wrTemp = range;
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
+
+ CPVT_Word wordinfo;
+ CPVT_WordPlace oldplace = wrTemp.BeginPos;
+ while (pIterator->NextWord())
+ {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)break;
+
+ if (pIterator->GetWord(wordinfo))
+ {
+ if (bRich)
+ {
+ swRet += wordinfo.Word;
+ }
+ else
+ {
+ swRet += wordinfo.Word;
+ }
+ }
+
+ if (oldplace.SecCmp(place) != 0)
+ {
+ swRet += 0x0D;
+ swRet += 0x0A;
+ }
+
+ oldplace = place;
+ }
+ }
+ }
+
+ return swRet;
}
CFX_WideString CFX_Edit::GetSelText() const
{
- return GetRangeText(m_SelState.ConvertToWordRange());
+ return GetRangeText(m_SelState.ConvertToWordRange());
}
int32_t CFX_Edit::GetTotalWords() const
{
- return m_pVT->GetTotalWords();
+ return m_pVT->GetTotalWords();
}
int32_t CFX_Edit::GetTotalLines() const
{
- int32_t nLines = 0;
+ int32_t nLines = 0;
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(0);
- while (pIterator->NextLine())
- nLines++;
- }
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(0);
+ while (pIterator->NextLine())
+ nLines++;
+ }
- return nLines+1;
+ return nLines+1;
}
CPVT_WordRange CFX_Edit::GetSelectWordRange() const
{
- return m_SelState.ConvertToWordRange();
+ return m_SelState.ConvertToWordRange();
}
CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange & wr1, const CPVT_WordRange & wr2)
{
- CPVT_WordRange wrRet;
+ CPVT_WordRange wrRet;
- if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0)
- {
- wrRet.BeginPos = wr1.BeginPos;
- }
- else
- {
- wrRet.BeginPos = wr2.BeginPos;
- }
+ if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0)
+ {
+ wrRet.BeginPos = wr1.BeginPos;
+ }
+ else
+ {
+ wrRet.BeginPos = wr2.BeginPos;
+ }
- if (wr1.EndPos.WordCmp(wr2.EndPos) < 0)
- {
- wrRet.EndPos = wr2.EndPos;
- }
- else
- {
- wrRet.EndPos = wr1.EndPos;
- }
+ if (wr1.EndPos.WordCmp(wr2.EndPos) < 0)
+ {
+ wrRet.EndPos = wr2.EndPos;
+ }
+ else
+ {
+ wrRet.EndPos = wr1.EndPos;
+ }
- return wrRet;
+ return wrRet;
}
-FX_BOOL CFX_Edit::IsRichText() const
+FX_BOOL CFX_Edit::IsRichText() const
{
- return m_pVT->IsRichText();
+ return m_pVT->IsRichText();
}
void CFX_Edit::SetRichText(FX_BOOL bRichText/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
{
- m_pVT->SetRichText(bRichText);
- if (bPaint) Paint();
+ m_pVT->SetRichText(bRichText);
+ if (bPaint) Paint();
}
FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex)
{
- CPVT_WordProps WordProps;
- WordProps.nFontIndex = nFontIndex;
- return SetRichTextProps(EP_FONTINDEX,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ WordProps.nFontIndex = nFontIndex;
+ return SetRichTextProps(EP_FONTINDEX,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize)
{
- CPVT_WordProps WordProps;
- WordProps.fFontSize = fFontSize;
- return SetRichTextProps(EP_FONTSIZE,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ WordProps.fFontSize = fFontSize;
+ return SetRichTextProps(EP_FONTSIZE,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor)
{
- CPVT_WordProps WordProps;
- WordProps.dwWordColor = dwColor;
- return SetRichTextProps(EP_WORDCOLOR,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ WordProps.dwWordColor = dwColor;
+ return SetRichTextProps(EP_WORDCOLOR,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextScript(int32_t nScriptType)
{
- CPVT_WordProps WordProps;
- WordProps.nScriptType = nScriptType;
- return SetRichTextProps(EP_SCRIPTTYPE,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ WordProps.nScriptType = nScriptType;
+ return SetRichTextProps(EP_SCRIPTTYPE,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold)
{
- CPVT_WordProps WordProps;
- if (bBold)
- WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- return SetRichTextProps(EP_BOLD,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ if (bBold)
+ WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ return SetRichTextProps(EP_BOLD,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic)
{
- CPVT_WordProps WordProps;
- if (bItalic)
- WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- return SetRichTextProps(EP_ITALIC,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ if (bItalic)
+ WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ return SetRichTextProps(EP_ITALIC,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline)
{
- CPVT_WordProps WordProps;
- if (bUnderline)
- WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- return SetRichTextProps(EP_UNDERLINE,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ if (bUnderline)
+ WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ return SetRichTextProps(EP_UNDERLINE,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout)
{
- CPVT_WordProps WordProps;
- if (bCrossout)
- WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- return SetRichTextProps(EP_CROSSOUT,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ if (bCrossout)
+ WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ return SetRichTextProps(EP_CROSSOUT,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace)
{
- CPVT_WordProps WordProps;
- WordProps.fCharSpace = fCharSpace;
- return SetRichTextProps(EP_CHARSPACE,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ WordProps.fCharSpace = fCharSpace;
+ return SetRichTextProps(EP_CHARSPACE,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale /*= 100*/)
{
- CPVT_WordProps WordProps;
- WordProps.nHorzScale = nHorzScale;
- return SetRichTextProps(EP_HORZSCALE,NULL,&WordProps);
+ CPVT_WordProps WordProps;
+ WordProps.nHorzScale = nHorzScale;
+ return SetRichTextProps(EP_HORZSCALE,NULL,&WordProps);
}
FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading)
{
- CPVT_SecProps SecProps;
- SecProps.fLineLeading = fLineLeading;
- return SetRichTextProps(EP_LINELEADING,&SecProps,NULL);
+ CPVT_SecProps SecProps;
+ SecProps.fLineLeading = fLineLeading;
+ return SetRichTextProps(EP_LINELEADING,&SecProps,NULL);
}
FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent)
{
- CPVT_SecProps SecProps;
- SecProps.fLineIndent = fLineIndent;
- return SetRichTextProps(EP_LINEINDENT,&SecProps,NULL);
+ CPVT_SecProps SecProps;
+ SecProps.fLineIndent = fLineIndent;
+ return SetRichTextProps(EP_LINEINDENT,&SecProps,NULL);
}
-FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment)
+FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment)
{
- CPVT_SecProps SecProps;
- SecProps.nAlignment = nAlignment;
- return SetRichTextProps(EP_ALIGNMENT,&SecProps,NULL);
+ CPVT_SecProps SecProps;
+ SecProps.nAlignment = nAlignment;
+ return SetRichTextProps(EP_ALIGNMENT,&SecProps,NULL);
}
FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps)
{
- FX_BOOL bSet = FALSE;
- FX_BOOL bSet1,bSet2;
- if (m_pVT->IsValid() && m_pVT->IsRichText())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
+ FX_BOOL bSet = FALSE;
+ FX_BOOL bSet1,bSet2;
+ if (m_pVT->IsValid() && m_pVT->IsRichText())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- BeginGroupUndo(L"");;
+ BeginGroupUndo(L"");;
- bSet = SetSecProps(eProps,wrTemp.BeginPos,pSecProps,pWordProps,wrTemp,TRUE);
+ bSet = SetSecProps(eProps,wrTemp.BeginPos,pSecProps,pWordProps,wrTemp,TRUE);
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0) break;
- bSet1 = SetSecProps(eProps,place,pSecProps,pWordProps,wrTemp,TRUE);
- bSet2 = SetWordProps(eProps,place,pWordProps,wrTemp,TRUE);
+ while (pIterator->NextWord())
+ {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0) break;
+ bSet1 = SetSecProps(eProps,place,pSecProps,pWordProps,wrTemp,TRUE);
+ bSet2 = SetWordProps(eProps,place,pWordProps,wrTemp,TRUE);
- if (!bSet)
- bSet = (bSet1 || bSet2);
- }
+ if (!bSet)
+ bSet = (bSet1 || bSet2);
+ }
- EndGroupUndo();
+ EndGroupUndo();
- if (bSet)
- {
- PaintSetProps(eProps,wrTemp);
- }
- }
- }
+ if (bSet)
+ {
+ PaintSetProps(eProps,wrTemp);
+ }
+ }
+ }
- return bSet;
+ return bSet;
}
void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange & wr)
{
- switch(eProps)
- {
- case EP_LINELEADING:
- case EP_LINEINDENT:
- case EP_ALIGNMENT:
- RearrangePart(wr);
- ScrollToCaret();
- Refresh(RP_ANALYSE);
- SetCaretOrigin();
- SetCaretInfo();
- break;
- case EP_WORDCOLOR:
- case EP_UNDERLINE:
- case EP_CROSSOUT:
- Refresh(RP_OPTIONAL,&wr);
- break;
- case EP_FONTINDEX:
- case EP_FONTSIZE:
- case EP_SCRIPTTYPE:
- case EP_CHARSPACE:
- case EP_HORZSCALE:
- case EP_BOLD:
- case EP_ITALIC:
- RearrangePart(wr);
- ScrollToCaret();
-
- CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos),
- m_pVT->GetSectionEndPlace(wr.EndPos));
- Refresh(RP_ANALYSE,&wrRefresh);
-
- SetCaretOrigin();
- SetCaretInfo();
- break;
- }
+ switch(eProps)
+ {
+ case EP_LINELEADING:
+ case EP_LINEINDENT:
+ case EP_ALIGNMENT:
+ RearrangePart(wr);
+ ScrollToCaret();
+ Refresh(RP_ANALYSE);
+ SetCaretOrigin();
+ SetCaretInfo();
+ break;
+ case EP_WORDCOLOR:
+ case EP_UNDERLINE:
+ case EP_CROSSOUT:
+ Refresh(RP_OPTIONAL,&wr);
+ break;
+ case EP_FONTINDEX:
+ case EP_FONTSIZE:
+ case EP_SCRIPTTYPE:
+ case EP_CHARSPACE:
+ case EP_HORZSCALE:
+ case EP_BOLD:
+ case EP_ITALIC:
+ RearrangePart(wr);
+ ScrollToCaret();
+
+ CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos),
+ m_pVT->GetSectionEndPlace(wr.EndPos));
+ Refresh(RP_ANALYSE,&wrRefresh);
+
+ SetCaretOrigin();
+ SetCaretInfo();
+ break;
+ }
}
FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps,
- const CPVT_WordRange & wr, FX_BOOL bAddUndo)
-{
- if (m_pVT->IsValid() && m_pVT->IsRichText())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- FX_BOOL bSet = FALSE;
- CPVT_Section secinfo;
- CPVT_Section OldSecinfo;
-
- CPVT_WordPlace oldplace = pIterator->GetAt();
-
- if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT || eProps == EP_ALIGNMENT)
- {
- if (pSecProps)
- {
- pIterator->SetAt(place);
- if (pIterator->GetSection(secinfo))
- {
- if (bAddUndo) OldSecinfo = secinfo;
-
- switch(eProps)
- {
- case EP_LINELEADING:
- if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading,pSecProps->fLineLeading))
- {
- secinfo.SecProps.fLineLeading = pSecProps->fLineLeading;
- bSet = TRUE;
- }
- break;
- case EP_LINEINDENT:
- if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent,pSecProps->fLineIndent))
- {
- secinfo.SecProps.fLineIndent = pSecProps->fLineIndent;
- bSet = TRUE;
- }
- break;
- case EP_ALIGNMENT:
- if (secinfo.SecProps.nAlignment != pSecProps->nAlignment)
- {
- secinfo.SecProps.nAlignment = pSecProps->nAlignment;
- bSet = TRUE;
- }
- break;
- default:
- break;
- }
- }
- }
- }
- else
- {
- if (pWordProps && place == m_pVT->GetSectionBeginPlace(place))
- {
- pIterator->SetAt(place);
- if (pIterator->GetSection(secinfo))
- {
- if (bAddUndo) OldSecinfo = secinfo;
-
- switch(eProps)
- {
- case EP_FONTINDEX:
- if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex)
- {
- secinfo.WordProps.nFontIndex = pWordProps->nFontIndex;
- bSet = TRUE;
- }
- break;
- case EP_FONTSIZE:
- if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize,pWordProps->fFontSize))
- {
- secinfo.WordProps.fFontSize = pWordProps->fFontSize;
- bSet = TRUE;
- }
- break;
- case EP_WORDCOLOR:
- if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor)
- {
- secinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
- bSet = TRUE;
- }
- break;
- case EP_SCRIPTTYPE:
- if (secinfo.WordProps.nScriptType != pWordProps->nScriptType)
- {
- secinfo.WordProps.nScriptType = pWordProps->nScriptType;
- bSet = TRUE;
- }
- break;
- case EP_CHARSPACE:
- if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace,pWordProps->fCharSpace))
- {
- secinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
- bSet = TRUE;
- }
- break;
- case EP_HORZSCALE:
- if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale)
- {
- secinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
- bSet = TRUE;
- }
- break;
- case EP_UNDERLINE:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- break;
- case EP_CROSSOUT:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- break;
- case EP_BOLD:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- break;
- case EP_ITALIC:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- break;
- default:
- break;
- }
- }
- }
- }
-
- if (bSet)
- {
- pIterator->SetSection(secinfo);
-
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_SetSecProps
- (this,place,eProps,OldSecinfo.SecProps,OldSecinfo.WordProps,secinfo.SecProps,secinfo.WordProps,wr));
- }
- }
-
- pIterator->SetAt(oldplace);
-
- return bSet;
- }
- }
-
- return FALSE;
+ const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps,
+ const CPVT_WordRange & wr, FX_BOOL bAddUndo)
+{
+ if (m_pVT->IsValid() && m_pVT->IsRichText())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ FX_BOOL bSet = FALSE;
+ CPVT_Section secinfo;
+ CPVT_Section OldSecinfo;
+
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+
+ if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT || eProps == EP_ALIGNMENT)
+ {
+ if (pSecProps)
+ {
+ pIterator->SetAt(place);
+ if (pIterator->GetSection(secinfo))
+ {
+ if (bAddUndo) OldSecinfo = secinfo;
+
+ switch(eProps)
+ {
+ case EP_LINELEADING:
+ if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading,pSecProps->fLineLeading))
+ {
+ secinfo.SecProps.fLineLeading = pSecProps->fLineLeading;
+ bSet = TRUE;
+ }
+ break;
+ case EP_LINEINDENT:
+ if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent,pSecProps->fLineIndent))
+ {
+ secinfo.SecProps.fLineIndent = pSecProps->fLineIndent;
+ bSet = TRUE;
+ }
+ break;
+ case EP_ALIGNMENT:
+ if (secinfo.SecProps.nAlignment != pSecProps->nAlignment)
+ {
+ secinfo.SecProps.nAlignment = pSecProps->nAlignment;
+ bSet = TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (pWordProps && place == m_pVT->GetSectionBeginPlace(place))
+ {
+ pIterator->SetAt(place);
+ if (pIterator->GetSection(secinfo))
+ {
+ if (bAddUndo) OldSecinfo = secinfo;
+
+ switch(eProps)
+ {
+ case EP_FONTINDEX:
+ if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex)
+ {
+ secinfo.WordProps.nFontIndex = pWordProps->nFontIndex;
+ bSet = TRUE;
+ }
+ break;
+ case EP_FONTSIZE:
+ if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize,pWordProps->fFontSize))
+ {
+ secinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ bSet = TRUE;
+ }
+ break;
+ case EP_WORDCOLOR:
+ if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor)
+ {
+ secinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ bSet = TRUE;
+ }
+ break;
+ case EP_SCRIPTTYPE:
+ if (secinfo.WordProps.nScriptType != pWordProps->nScriptType)
+ {
+ secinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ bSet = TRUE;
+ }
+ break;
+ case EP_CHARSPACE:
+ if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace,pWordProps->fCharSpace))
+ {
+ secinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ bSet = TRUE;
+ }
+ break;
+ case EP_HORZSCALE:
+ if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale)
+ {
+ secinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ bSet = TRUE;
+ }
+ break;
+ case EP_UNDERLINE:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE)
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0)
+ {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0)
+ {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_CROSSOUT:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT)
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0)
+ {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0)
+ {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_BOLD:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD)
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0)
+ {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0)
+ {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_ITALIC:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC)
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0)
+ {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0)
+ {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ if (bSet)
+ {
+ pIterator->SetSection(secinfo);
+
+ if (bAddUndo && m_bEnableUndo)
+ {
+ AddEditUndoItem(new CFXEU_SetSecProps
+ (this,place,eProps,OldSecinfo.SecProps,OldSecinfo.WordProps,secinfo.SecProps,secinfo.WordProps,wr));
+ }
+ }
+
+ pIterator->SetAt(oldplace);
+
+ return bSet;
+ }
+ }
+
+ return FALSE;
}
FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place,
- const CPVT_WordProps * pWordProps, const CPVT_WordRange & wr, FX_BOOL bAddUndo)
-{
- if (m_pVT->IsValid() && m_pVT->IsRichText())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- FX_BOOL bSet = FALSE;
- CPVT_Word wordinfo;
- CPVT_Word OldWordinfo;
-
- CPVT_WordPlace oldplace = pIterator->GetAt();
-
- if (pWordProps)
- {
- pIterator->SetAt(place);
- if (pIterator->GetWord(wordinfo))
- {
- if (bAddUndo) OldWordinfo = wordinfo;
-
- switch(eProps)
- {
- case EP_FONTINDEX:
- if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex)
- {
- if (IFX_Edit_FontMap* pFontMap = GetFontMap())
- {
- wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex(wordinfo.Word,wordinfo.nCharset,pWordProps->nFontIndex);
- }
- bSet = TRUE;
- }
- break;
- case EP_FONTSIZE:
- if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize,pWordProps->fFontSize))
- {
- wordinfo.WordProps.fFontSize = pWordProps->fFontSize;
- bSet = TRUE;
- }
- break;
- case EP_WORDCOLOR:
- if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor)
- {
- wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
- bSet = TRUE;
- }
- break;
- case EP_SCRIPTTYPE:
- if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType)
- {
- wordinfo.WordProps.nScriptType = pWordProps->nScriptType;
- bSet = TRUE;
- }
- break;
- case EP_CHARSPACE:
- if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace,pWordProps->fCharSpace))
- {
- wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
- bSet = TRUE;
- }
- break;
- case EP_HORZSCALE:
- if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale)
- {
- wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
- bSet = TRUE;
- }
- break;
- case EP_UNDERLINE:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- break;
- case EP_CROSSOUT:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- break;
- case EP_BOLD:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- break;
- case EP_ITALIC:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- break;
- default:
- break;
- }
- }
- }
-
- if (bSet)
- {
- pIterator->SetWord(wordinfo);
-
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_SetWordProps
- (this,place,eProps,OldWordinfo.WordProps,wordinfo.WordProps,wr));
- }
- }
-
- pIterator->SetAt(oldplace);
- return bSet;
- }
- }
-
- return FALSE;
+ const CPVT_WordProps * pWordProps, const CPVT_WordRange & wr, FX_BOOL bAddUndo)
+{
+ if (m_pVT->IsValid() && m_pVT->IsRichText())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ FX_BOOL bSet = FALSE;
+ CPVT_Word wordinfo;
+ CPVT_Word OldWordinfo;
+
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+
+ if (pWordProps)
+ {
+ pIterator->SetAt(place);
+ if (pIterator->GetWord(wordinfo))
+ {
+ if (bAddUndo) OldWordinfo = wordinfo;
+
+ switch(eProps)
+ {
+ case EP_FONTINDEX:
+ if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex)
+ {
+ if (IFX_Edit_FontMap* pFontMap = GetFontMap())
+ {
+ wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex(wordinfo.Word,wordinfo.nCharset,pWordProps->nFontIndex);
+ }
+ bSet = TRUE;
+ }
+ break;
+ case EP_FONTSIZE:
+ if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize,pWordProps->fFontSize))
+ {
+ wordinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ bSet = TRUE;
+ }
+ break;
+ case EP_WORDCOLOR:
+ if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor)
+ {
+ wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ bSet = TRUE;
+ }
+ break;
+ case EP_SCRIPTTYPE:
+ if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType)
+ {
+ wordinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ bSet = TRUE;
+ }
+ break;
+ case EP_CHARSPACE:
+ if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace,pWordProps->fCharSpace))
+ {
+ wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ bSet = TRUE;
+ }
+ break;
+ case EP_HORZSCALE:
+ if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale)
+ {
+ wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ bSet = TRUE;
+ }
+ break;
+ case EP_UNDERLINE:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE)
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0)
+ {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0)
+ {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_CROSSOUT:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT)
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0)
+ {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0)
+ {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_BOLD:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD)
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0)
+ {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0)
+ {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_ITALIC:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC)
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0)
+ {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ }
+ else
+ {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0)
+ {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (bSet)
+ {
+ pIterator->SetWord(wordinfo);
+
+ if (bAddUndo && m_bEnableUndo)
+ {
+ AddEditUndoItem(new CFXEU_SetWordProps
+ (this,place,eProps,OldWordinfo.WordProps,wordinfo.WordProps,wr));
+ }
+ }
+
+ pIterator->SetAt(oldplace);
+ return bSet;
+ }
+ }
+
+ return FALSE;
}
void CFX_Edit::SetText(const FX_WCHAR* text,int32_t charset /*= DEFAULT_CHARSET*/,
- const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
+ const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
{
- SetText(text,charset,pSecProps,pWordProps,TRUE,TRUE);
+ SetText(text,charset,pSecProps,pWordProps,TRUE,TRUE);
}
FX_BOOL CFX_Edit::InsertWord(FX_WORD word, int32_t charset /*= DEFAULT_CHARSET*/, const CPVT_WordProps * pWordProps /*= NULL*/)
{
- return InsertWord(word,charset,pWordProps,TRUE,TRUE);
+ return InsertWord(word,charset,pWordProps,TRUE,TRUE);
}
FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
{
- return InsertReturn(pSecProps,pWordProps,TRUE,TRUE);
+ return InsertReturn(pSecProps,pWordProps,TRUE,TRUE);
}
FX_BOOL CFX_Edit::Backspace()
{
- return Backspace(TRUE,TRUE);
+ return Backspace(TRUE,TRUE);
}
FX_BOOL CFX_Edit::Delete()
{
- return Delete(TRUE,TRUE);
+ return Delete(TRUE,TRUE);
}
FX_BOOL CFX_Edit::Clear()
{
- return Clear(TRUE,TRUE);
+ return Clear(TRUE,TRUE);
}
FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset /*= DEFAULT_CHARSET*/,
- const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
+ const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
{
- return InsertText(text,charset,pSecProps,pWordProps,TRUE,TRUE);
+ return InsertText(text,charset,pSecProps,pWordProps,TRUE,TRUE);
}
FX_FLOAT CFX_Edit::GetFontSize() const
{
- return m_pVT->GetFontSize();
+ return m_pVT->GetFontSize();
}
FX_WORD CFX_Edit::GetPasswordChar() const
{
- return m_pVT->GetPasswordChar();
+ return m_pVT->GetPasswordChar();
}
int32_t CFX_Edit::GetCharArray() const
{
- return m_pVT->GetCharArray();
+ return m_pVT->GetCharArray();
}
CPDF_Rect CFX_Edit::GetPlateRect() const
{
- return m_pVT->GetPlateRect();
+ return m_pVT->GetPlateRect();
}
CPDF_Rect CFX_Edit::GetContentRect() const
{
- return VTToEdit(m_pVT->GetContentRect());
+ return VTToEdit(m_pVT->GetContentRect());
}
int32_t CFX_Edit::GetHorzScale() const
{
- return m_pVT->GetHorzScale();
+ return m_pVT->GetHorzScale();
}
FX_FLOAT CFX_Edit::GetCharSpace() const
{
- return m_pVT->GetCharSpace();
+ return m_pVT->GetCharSpace();
}
// inner methods
CPVT_WordRange CFX_Edit::GetWholeWordRange() const
{
- if (m_pVT->IsValid())
- return CPVT_WordRange(m_pVT->GetBeginWordPlace(),m_pVT->GetEndWordPlace());
+ if (m_pVT->IsValid())
+ return CPVT_WordRange(m_pVT->GetBeginWordPlace(),m_pVT->GetEndWordPlace());
- return CPVT_WordRange();
+ return CPVT_WordRange();
}
CPVT_WordRange CFX_Edit::GetVisibleWordRange() const
{
- if (m_bEnableOverflow) return GetWholeWordRange();
+ if (m_bEnableOverflow) return GetWholeWordRange();
- if (m_pVT->IsValid())
- {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ if (m_pVT->IsValid())
+ {
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPVT_WordPlace place1 = m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.left,rcPlate.top)));
- CPVT_WordPlace place2 = m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.right,rcPlate.bottom)));
+ CPVT_WordPlace place1 = m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.left,rcPlate.top)));
+ CPVT_WordPlace place2 = m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.right,rcPlate.bottom)));
- return CPVT_WordRange(place1,place2);
- }
+ return CPVT_WordRange(place1,place2);
+ }
- return CPVT_WordRange();
+ return CPVT_WordRange();
}
CPVT_WordPlace CFX_Edit::SearchWordPlace(const CPDF_Point& point) const
{
- if (m_pVT->IsValid())
- {
- return m_pVT->SearchWordPlace(EditToVT(point));
- }
+ if (m_pVT->IsValid())
+ {
+ return m_pVT->SearchWordPlace(EditToVT(point));
+ }
- return CPVT_WordPlace();
+ return CPVT_WordPlace();
}
void CFX_Edit::Paint()
{
- if (m_pVT->IsValid())
- {
- RearrangeAll();
- ScrollToCaret();
- Refresh(RP_NOANALYSE);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ if (m_pVT->IsValid())
+ {
+ RearrangeAll();
+ ScrollToCaret();
+ Refresh(RP_NOANALYSE);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
void CFX_Edit::RearrangeAll()
{
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
- m_pVT->RearrangeAll();
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetScrollInfo();
- SetContentChanged();
- }
+ if (m_pVT->IsValid())
+ {
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ m_pVT->RearrangeAll();
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetScrollInfo();
+ SetContentChanged();
+ }
}
void CFX_Edit::RearrangePart(const CPVT_WordRange & range)
{
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
- m_pVT->RearrangePart(range);
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetScrollInfo();
- SetContentChanged();
- }
+ if (m_pVT->IsValid())
+ {
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ m_pVT->RearrangePart(range);
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetScrollInfo();
+ SetContentChanged();
+ }
}
void CFX_Edit::SetContentChanged()
{
- if (m_bNotify && m_pNotify)
- {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- if (rcContent.Width() != m_rcOldContent.Width() ||
- rcContent.Height() != m_rcOldContent.Height())
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnContentChange(rcContent);
- m_bNotifyFlag = FALSE;
- }
- m_rcOldContent = rcContent;
- }
- }
+ if (m_bNotify && m_pNotify)
+ {
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ if (rcContent.Width() != m_rcOldContent.Width() ||
+ rcContent.Height() != m_rcOldContent.Height())
+ {
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnContentChange(rcContent);
+ m_bNotifyFlag = FALSE;
+ }
+ m_rcOldContent = rcContent;
+ }
+ }
}
void CFX_Edit::SelectAll()
{
- if (m_pVT->IsValid())
- {
- m_SelState = GetWholeWordRange();
- SetCaret(m_SelState.EndPos);
+ if (m_pVT->IsValid())
+ {
+ m_SelState = GetWholeWordRange();
+ SetCaret(m_SelState.EndPos);
- ScrollToCaret();
- CPVT_WordRange wrVisible = GetVisibleWordRange();
- Refresh(RP_OPTIONAL,&wrVisible);
- SetCaretInfo();
- }
+ ScrollToCaret();
+ CPVT_WordRange wrVisible = GetVisibleWordRange();
+ Refresh(RP_OPTIONAL,&wrVisible);
+ SetCaretInfo();
+ }
}
void CFX_Edit::SelectNone()
{
- if (m_pVT->IsValid())
- {
- if (m_SelState.IsExist())
- {
- CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
- m_SelState.Default();
- Refresh(RP_OPTIONAL,&wrTemp);
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (m_SelState.IsExist())
+ {
+ CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
+ m_SelState.Default();
+ Refresh(RP_OPTIONAL,&wrTemp);
+ }
+ }
}
-FX_BOOL CFX_Edit::IsSelected() const
+FX_BOOL CFX_Edit::IsSelected() const
{
- return m_SelState.IsExist();
+ return m_SelState.IsExist();
}
CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point & point) const
{
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- FX_FLOAT fPadding = 0.0f;
+ FX_FLOAT fPadding = 0.0f;
- switch (m_nAlignment)
- {
- case 0:
- fPadding = 0.0f;
- break;
- case 1:
- fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
- break;
- case 2:
- fPadding = rcPlate.Height() - rcContent.Height();
- break;
- }
+ switch (m_nAlignment)
+ {
+ case 0:
+ fPadding = 0.0f;
+ break;
+ case 1:
+ fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
+ break;
+ case 2:
+ fPadding = rcPlate.Height() - rcContent.Height();
+ break;
+ }
- return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
- point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
+ point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
}
CPDF_Point CFX_Edit::EditToVT(const CPDF_Point & point) const
{
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- FX_FLOAT fPadding = 0.0f;
+ FX_FLOAT fPadding = 0.0f;
- switch (m_nAlignment)
- {
- case 0:
- fPadding = 0.0f;
- break;
- case 1:
- fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
- break;
- case 2:
- fPadding = rcPlate.Height() - rcContent.Height();
- break;
- }
+ switch (m_nAlignment)
+ {
+ case 0:
+ fPadding = 0.0f;
+ break;
+ case 1:
+ fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
+ break;
+ case 2:
+ fPadding = rcPlate.Height() - rcContent.Height();
+ break;
+ }
- return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
- point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
+ point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
}
CPDF_Rect CFX_Edit::VTToEdit(const CPDF_Rect & rect) const
{
- CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left,rect.bottom));
- CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right,rect.top));
+ CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left,rect.bottom));
+ CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right,rect.top));
- return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
+ return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
}
CPDF_Rect CFX_Edit::EditToVT(const CPDF_Rect & rect) const
{
- CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left,rect.bottom));
- CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right,rect.top));
+ CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left,rect.bottom));
+ CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right,rect.top));
- return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
+ return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
}
void CFX_Edit::SetScrollInfo()
{
- if (m_bNotify && m_pNotify)
- {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPDF_Rect rcContent = m_pVT->GetContentRect();
+ if (m_bNotify && m_pNotify)
+ {
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right,
- rcContent.left, rcContent.right, rcPlate.Width() / 3, rcPlate.Width());
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right,
+ rcContent.left, rcContent.right, rcPlate.Width() / 3, rcPlate.Width());
- m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
- rcContent.bottom, rcContent.top, rcPlate.Height() / 3, rcPlate.Height());
- m_bNotifyFlag = FALSE;
- }
- }
+ m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
+ rcContent.bottom, rcContent.top, rcPlate.Height() / 3, rcPlate.Height());
+ m_bNotifyFlag = FALSE;
+ }
+ }
}
void CFX_Edit::SetScrollPosX(FX_FLOAT fx)
{
- if (!m_bEnableScroll) return;
+ if (!m_bEnableScroll) return;
- if (m_pVT->IsValid())
- {
- if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x,fx))
- {
- m_ptScrollPos.x = fx;
- Refresh(RP_NOANALYSE);
+ if (m_pVT->IsValid())
+ {
+ if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x,fx))
+ {
+ m_ptScrollPos.x = fx;
+ Refresh(RP_NOANALYSE);
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollPosX(fx);
- m_bNotifyFlag = FALSE;
- }
- }
- }
- }
+ if (m_bNotify && m_pNotify)
+ {
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollPosX(fx);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+ }
+ }
}
void CFX_Edit::SetScrollPosY(FX_FLOAT fy)
{
- if (!m_bEnableScroll) return;
+ if (!m_bEnableScroll) return;
- if (m_pVT->IsValid())
- {
- if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y,fy))
- {
- m_ptScrollPos.y = fy;
- Refresh(RP_NOANALYSE);
+ if (m_pVT->IsValid())
+ {
+ if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y,fy))
+ {
+ m_ptScrollPos.y = fy;
+ Refresh(RP_NOANALYSE);
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollPosY(fy);
- m_bNotifyFlag = FALSE;
- }
- }
- }
- }
+ if (m_bNotify && m_pNotify)
+ {
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollPosY(fy);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+ }
+ }
}
void CFX_Edit::SetScrollPos(const CPDF_Point & point)
{
- SetScrollPosX(point.x);
- SetScrollPosY(point.y);
- SetScrollLimit();
- SetCaretInfo();
+ SetScrollPosX(point.x);
+ SetScrollPosY(point.y);
+ SetScrollLimit();
+ SetCaretInfo();
}
CPDF_Point CFX_Edit::GetScrollPos() const
{
- return m_ptScrollPos;
+ return m_ptScrollPos;
}
void CFX_Edit::SetScrollLimit()
{
- if (m_pVT->IsValid())
- {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
-
- if (rcPlate.Width() > rcContent.Width())
- {
- SetScrollPosX(rcPlate.left);
- }
- else
- {
- if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left))
- {
- SetScrollPosX(rcContent.left);
- }
- else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, rcContent.right - rcPlate.Width()))
- {
- SetScrollPosX(rcContent.right - rcPlate.Width());
- }
- }
-
- if (rcPlate.Height() > rcContent.Height())
- {
- SetScrollPosY(rcPlate.top);
- }
- else
- {
- if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, rcContent.bottom + rcPlate.Height()))
- {
- SetScrollPosY(rcContent.bottom + rcPlate.Height());
- }
- else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top))
- {
- SetScrollPosY(rcContent.top);
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+
+ if (rcPlate.Width() > rcContent.Width())
+ {
+ SetScrollPosX(rcPlate.left);
+ }
+ else
+ {
+ if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left))
+ {
+ SetScrollPosX(rcContent.left);
+ }
+ else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, rcContent.right - rcPlate.Width()))
+ {
+ SetScrollPosX(rcContent.right - rcPlate.Width());
+ }
+ }
+
+ if (rcPlate.Height() > rcContent.Height())
+ {
+ SetScrollPosY(rcPlate.top);
+ }
+ else
+ {
+ if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, rcContent.bottom + rcPlate.Height()))
+ {
+ SetScrollPosY(rcContent.bottom + rcPlate.Height());
+ }
+ else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top))
+ {
+ SetScrollPosY(rcContent.top);
+ }
+ }
+ }
}
void CFX_Edit::ScrollToCaret()
{
- SetScrollLimit();
-
- if (m_pVT->IsValid())
- {
- CPDF_Point ptHead(0,0);
- CPDF_Point ptFoot(0,0);
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
-
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- }
- else if (pIterator->GetLine(line))
- {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
-
- CPDF_Point ptHeadEdit = VTToEdit(ptHead);
- CPDF_Point ptFootEdit = VTToEdit(ptFoot);
-
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
-
- if (!FX_EDIT_IsFloatEqual(rcPlate.left,rcPlate.right))
- {
- if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
- FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left))
- {
- SetScrollPosX(ptHead.x);
- }
- else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right))
- {
- SetScrollPosX(ptHead.x - rcPlate.Width());
- }
- }
-
- if (!FX_EDIT_IsFloatEqual(rcPlate.top,rcPlate.bottom))
- {
- if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) ||
- FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom))
- {
- if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top))
- {
- SetScrollPosY(ptFoot.y + rcPlate.Height());
- }
- }
- else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top))
- {
- if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom))
- {
- SetScrollPosY(ptHead.y);
- }
- }
- }
- }
+ SetScrollLimit();
+
+ if (m_pVT->IsValid())
+ {
+ CPDF_Point ptHead(0,0);
+ CPDF_Point ptFoot(0,0);
+
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(m_wpCaret);
+
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word))
+ {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ }
+ else if (pIterator->GetLine(line))
+ {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
+ }
+ }
+
+ CPDF_Point ptHeadEdit = VTToEdit(ptHead);
+ CPDF_Point ptFootEdit = VTToEdit(ptFoot);
+
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+
+ if (!FX_EDIT_IsFloatEqual(rcPlate.left,rcPlate.right))
+ {
+ if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
+ FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left))
+ {
+ SetScrollPosX(ptHead.x);
+ }
+ else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right))
+ {
+ SetScrollPosX(ptHead.x - rcPlate.Width());
+ }
+ }
+
+ if (!FX_EDIT_IsFloatEqual(rcPlate.top,rcPlate.bottom))
+ {
+ if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) ||
+ FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom))
+ {
+ if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top))
+ {
+ SetScrollPosY(ptFoot.y + rcPlate.Height());
+ }
+ }
+ else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top))
+ {
+ if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom))
+ {
+ SetScrollPosY(ptHead.y);
+ }
+ }
+ }
+ }
}
void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan,const CPVT_WordRange * pRange1,const CPVT_WordRange * pRange2)
{
- if (m_bEnableRefresh && m_pVT->IsValid())
- {
- m_Refresh.BeginRefresh();
- RefreshPushLineRects(GetVisibleWordRange());
-
-// if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x) ||
-// !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollPos.y))
-// {
- m_Refresh.NoAnalyse();
- m_ptRefreshScrollPos = m_ptScrollPos;
-// }
-// else
-// {
-// switch (ePlan)
-// {
-// case RP_ANALYSE:
-// m_Refresh.Analyse(m_pVT->GetAlignment());
+ if (m_bEnableRefresh && m_pVT->IsValid())
+ {
+ m_Refresh.BeginRefresh();
+ RefreshPushLineRects(GetVisibleWordRange());
+
+// if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x) ||
+// !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollPos.y))
+// {
+ m_Refresh.NoAnalyse();
+ m_ptRefreshScrollPos = m_ptScrollPos;
+// }
+// else
+// {
+// switch (ePlan)
+// {
+// case RP_ANALYSE:
+// m_Refresh.Analyse(m_pVT->GetAlignment());
//
-// if (pRange1) RefreshPushRandomRects(*pRange1);
-// if (pRange2) RefreshPushRandomRects(*pRange2);
-// break;
-// case RP_NOANALYSE:
-// m_Refresh.NoAnalyse();
-// break;
-// case RP_OPTIONAL:
-// if (pRange1) RefreshPushRandomRects(*pRange1);
-// if (pRange2) RefreshPushRandomRects(*pRange2);
-// break;
-// }
-// }
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- if (const CFX_Edit_RectArray * pRects = m_Refresh.GetRefreshRects())
- {
- for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++)
- m_pNotify->IOnInvalidateRect(pRects->GetAt(i));
- }
- m_bNotifyFlag = FALSE;
- }
- }
-
- m_Refresh.EndRefresh();
- }
+// if (pRange1) RefreshPushRandomRects(*pRange1);
+// if (pRange2) RefreshPushRandomRects(*pRange2);
+// break;
+// case RP_NOANALYSE:
+// m_Refresh.NoAnalyse();
+// break;
+// case RP_OPTIONAL:
+// if (pRange1) RefreshPushRandomRects(*pRange1);
+// if (pRange2) RefreshPushRandomRects(*pRange2);
+// break;
+// }
+// }
+
+ if (m_bNotify && m_pNotify)
+ {
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ if (const CFX_Edit_RectArray * pRects = m_Refresh.GetRefreshRects())
+ {
+ for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++)
+ m_pNotify->IOnInvalidateRect(pRects->GetAt(i));
+ }
+ m_bNotifyFlag = FALSE;
+ }
+ }
+
+ m_Refresh.EndRefresh();
+ }
}
void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange & wr)
{
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordPlace wpBegin = wr.BeginPos;
- m_pVT->UpdateWordPlace(wpBegin);
- CPVT_WordPlace wpEnd = wr.EndPos;
- m_pVT->UpdateWordPlace(wpEnd);
- pIterator->SetAt(wpBegin);
+ if (m_pVT->IsValid())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordPlace wpBegin = wr.BeginPos;
+ m_pVT->UpdateWordPlace(wpBegin);
+ CPVT_WordPlace wpEnd = wr.EndPos;
+ m_pVT->UpdateWordPlace(wpEnd);
+ pIterator->SetAt(wpBegin);
- CPVT_Line lineinfo;
- do
- {
- if (!pIterator->GetLine(lineinfo))break;
- if (lineinfo.lineplace.LineCmp(wpEnd) > 0)break;
+ CPVT_Line lineinfo;
+ do
+ {
+ if (!pIterator->GetLine(lineinfo))break;
+ if (lineinfo.lineplace.LineCmp(wpEnd) > 0)break;
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CPDF_Rect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
- m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace,lineinfo.lineEnd),VTToEdit(rcLine));
+ m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace,lineinfo.lineEnd),VTToEdit(rcLine));
- }while (pIterator->NextLine());
- }
- }
+ }while (pIterator->NextLine());
+ }
+ }
}
void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange & wr)
{
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = wr;
-
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
-
- CPVT_Word wordinfo;
- CPVT_Line lineinfo;
- CPVT_WordPlace place;
-
- while (pIterator->NextWord())
- {
- place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0) break;
-
- pIterator->GetWord(wordinfo);
- pIterator->GetLine(lineinfo);
-
- if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp(wrTemp.EndPos) == 0)
- {
- CPDF_Rect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- m_Refresh.AddRefresh(VTToEdit(rcWord));
- }
- else
- {
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- m_Refresh.AddRefresh(VTToEdit(rcLine));
-
- pIterator->NextLine();
- }
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordRange wrTemp = wr;
+
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
+
+ CPVT_Word wordinfo;
+ CPVT_Line lineinfo;
+ CPVT_WordPlace place;
+
+ while (pIterator->NextWord())
+ {
+ place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0) break;
+
+ pIterator->GetWord(wordinfo);
+ pIterator->GetLine(lineinfo);
+
+ if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp(wrTemp.EndPos) == 0)
+ {
+ CPDF_Rect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ m_Refresh.AddRefresh(VTToEdit(rcWord));
+ }
+ else
+ {
+ CPDF_Rect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ m_Refresh.AddRefresh(VTToEdit(rcLine));
+
+ pIterator->NextLine();
+ }
+ }
+ }
+ }
}
void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr)
{
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = wr;
-
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
-
- CPVT_Word wordinfo;
- CPVT_Line lineinfo;
- CPVT_WordPlace place;
-
- while (pIterator->NextWord())
- {
- place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0) break;
-
- pIterator->GetWord(wordinfo);
- pIterator->GetLine(lineinfo);
-
- if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp(wrTemp.EndPos) == 0)
- {
- CPDF_Rect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = VTToEdit(rcWord);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
- }
- else
- {
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = VTToEdit(rcLine);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
-
- pIterator->NextLine();
- }
- }
- }
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordRange wrTemp = wr;
+
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
+
+ CPVT_Word wordinfo;
+ CPVT_Line lineinfo;
+ CPVT_WordPlace place;
+
+ while (pIterator->NextWord())
+ {
+ place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0) break;
+
+ pIterator->GetWord(wordinfo);
+ pIterator->GetLine(lineinfo);
+
+ if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp(wrTemp.EndPos) == 0)
+ {
+ CPDF_Rect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ if (m_bNotify && m_pNotify)
+ {
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ CPDF_Rect rcRefresh = VTToEdit(rcWord);
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+ }
+ else
+ {
+ CPDF_Rect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ if (m_bNotify && m_pNotify)
+ {
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ CPDF_Rect rcRefresh = VTToEdit(rcLine);
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+
+ pIterator->NextLine();
+ }
+ }
+ }
}
void CFX_Edit::SetCaret(const CPVT_WordPlace & place)
{
- m_wpOldCaret = m_wpCaret;
- m_wpCaret = place;
+ m_wpOldCaret = m_wpCaret;
+ m_wpCaret = place;
}
void CFX_Edit::SetCaretInfo()
{
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- CPDF_Point ptHead(0.0f,0.0f),ptFoot(0.0f,0.0f);
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- }
- else if (pIterator->GetLine(line))
- {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
-
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetCaret(!m_SelState.IsExist(),VTToEdit(ptHead),VTToEdit(ptFoot), m_wpCaret);
- m_bNotifyFlag = FALSE;
- }
- }
-
- SetCaretChange();
+ if (m_bNotify && m_pNotify)
+ {
+ if (!m_bNotifyFlag)
+ {
+ CPDF_Point ptHead(0.0f,0.0f),ptFoot(0.0f,0.0f);
+
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word))
+ {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ }
+ else if (pIterator->GetLine(line))
+ {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
+ }
+ }
+
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetCaret(!m_SelState.IsExist(),VTToEdit(ptHead),VTToEdit(ptFoot), m_wpCaret);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+
+ SetCaretChange();
}
void CFX_Edit::SetCaretChange()
{
- if (m_wpCaret == m_wpOldCaret) return;
+ if (m_wpCaret == m_wpOldCaret) return;
- if (m_bNotify && m_pVT->IsRichText() && m_pNotify)
- {
- CPVT_SecProps SecProps;
- CPVT_WordProps WordProps;
+ if (m_bNotify && m_pVT->IsRichText() && m_pNotify)
+ {
+ CPVT_SecProps SecProps;
+ CPVT_WordProps WordProps;
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Section section;
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Section section;
- if (pIterator->GetSection(section))
- {
- SecProps = section.SecProps;
- WordProps = section.WordProps;
- }
+ if (pIterator->GetSection(section))
+ {
+ SecProps = section.SecProps;
+ WordProps = section.WordProps;
+ }
- if (pIterator->GetWord(word))
- {
- WordProps = word.WordProps;
- }
- }
+ if (pIterator->GetWord(word))
+ {
+ WordProps = word.WordProps;
+ }
+ }
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnCaretChange(SecProps,WordProps);
- m_bNotifyFlag = FALSE;
- }
- }
+ if (!m_bNotifyFlag)
+ {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnCaretChange(SecProps,WordProps);
+ m_bNotifyFlag = FALSE;
+ }
+ }
}
void CFX_Edit::SetCaret(int32_t nPos)
{
- if (m_pVT->IsValid())
- {
- SelectNone();
- SetCaret(m_pVT->WordIndexToWordPlace(nPos));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ if (m_pVT->IsValid())
+ {
+ SelectNone();
+ SetCaret(m_pVT->WordIndexToWordPlace(nPos));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
void CFX_Edit::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- SelectNone();
- SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ if (m_pVT->IsValid())
+ {
+ SelectNone();
+ SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
void CFX_Edit::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
+ if (m_pVT->IsValid())
+ {
+ SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
- if (m_wpCaret != m_wpOldCaret)
- {
- m_SelState.SetEndPos(m_wpCaret);
+ if (m_wpCaret != m_wpOldCaret)
+ {
+ m_SelState.SetEndPos(m_wpCaret);
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
+ Refresh(RP_OPTIONAL,&wr);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
}
void CFX_Edit::OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- SetCaret(m_pVT->GetUpWordPlace(m_wpCaret,m_ptCaret));
-
- if (bShift)
- {
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
- }
- else
- {
- SelectNone();
-
- ScrollToCaret();
- SetCaretInfo();
- }
- }
+ if (m_pVT->IsValid())
+ {
+ SetCaret(m_pVT->GetUpWordPlace(m_wpCaret,m_ptCaret));
+
+ if (bShift)
+ {
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret,m_wpCaret);
+
+ if (m_wpOldCaret != m_wpCaret)
+ {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ }
+ }
+ else
+ {
+ SelectNone();
+
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ }
}
void CFX_Edit::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- SetCaret(m_pVT->GetDownWordPlace(m_wpCaret,m_ptCaret));
-
- if (bShift)
- {
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
- }
- else
- {
- SelectNone();
-
- ScrollToCaret();
- SetCaretInfo();
- }
- }
+ if (m_pVT->IsValid())
+ {
+ SetCaret(m_pVT->GetDownWordPlace(m_wpCaret,m_ptCaret));
+
+ if (bShift)
+ {
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret,m_wpCaret);
+
+ if (m_wpOldCaret != m_wpCaret)
+ {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ }
+ }
+ else
+ {
+ SelectNone();
+
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ }
}
void CFX_Edit::OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret, m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretInfo();
- }
- }
- else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (bShift)
+ {
+ if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
+
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
+
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
+
+ if (m_wpOldCaret != m_wpCaret)
+ {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
+ Refresh(RP_OPTIONAL,&wr);
+ SetCaretInfo();
+ }
+ }
+ else
+ {
+ if (m_SelState.IsExist())
+ {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
+ SetCaret(m_SelState.BeginPos);
+ else
+ SetCaret(m_SelState.EndPos);
+
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ else
+ {
+ if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
+
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
+
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
+ }
}
void CFX_Edit::OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
-
- if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretInfo();
- }
- }
- else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)>0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
-
- if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
-
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (bShift)
+ {
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+
+ if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret,m_wpCaret);
+
+ if (m_wpOldCaret != m_wpCaret)
+ {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
+ Refresh(RP_OPTIONAL,&wr);
+ SetCaretInfo();
+ }
+ }
+ else
+ {
+ if (m_SelState.IsExist())
+ {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)>0)
+ SetCaret(m_SelState.BeginPos);
+ else
+ SetCaret(m_SelState.EndPos);
+
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ else
+ {
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+
+ if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
+ }
}
void CFX_Edit::OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- if (bCtrl)
- SetCaret(m_pVT->GetBeginWordPlace());
- else
- SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
- else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- if (bCtrl)
- SetCaret(m_pVT->GetBeginWordPlace());
- else
- SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
-
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (bShift)
+ {
+ if (bCtrl)
+ SetCaret(m_pVT->GetBeginWordPlace());
+ else
+ SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
+
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret,m_wpCaret);
+
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ }
+ else
+ {
+ if (m_SelState.IsExist())
+ {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
+ SetCaret(m_SelState.BeginPos);
+ else
+ SetCaret(m_SelState.EndPos);
+
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ else
+ {
+ if (bCtrl)
+ SetCaret(m_pVT->GetBeginWordPlace());
+ else
+ SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
+
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
+ }
}
void CFX_Edit::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl)
{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- if (bCtrl)
- SetCaret(m_pVT->GetEndWordPlace());
- else
- SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret, m_wpCaret);
-
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
- else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)>0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- if (bCtrl)
- SetCaret(m_pVT->GetEndWordPlace());
- else
- SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
-
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (bShift)
+ {
+ if (bCtrl)
+ SetCaret(m_pVT->GetEndWordPlace());
+ else
+ SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
+
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
+
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ }
+ else
+ {
+ if (m_SelState.IsExist())
+ {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)>0)
+ SetCaret(m_SelState.BeginPos);
+ else
+ SetCaret(m_SelState.EndPos);
+
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ }
+ else
+ {
+ if (bCtrl)
+ SetCaret(m_pVT->GetEndWordPlace());
+ else
+ SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
+
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
+ }
}
void CFX_Edit::SetText(const FX_WCHAR* text,int32_t charset,
- const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
+ const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- Empty();
- DoInsertText(CPVT_WordPlace(0,0,-1), text, charset, pSecProps, pWordProps);
- if (bPaint) Paint();
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret);
- //if (bAddUndo)
+ Empty();
+ DoInsertText(CPVT_WordPlace(0,0,-1), text, charset, pSecProps, pWordProps);
+ if (bPaint) Paint();
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret);
+ //if (bAddUndo)
}
FX_BOOL CFX_Edit::InsertWord(FX_WORD word, int32_t charset, const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- if (IsTextOverflow()) return FALSE;
+ if (IsTextOverflow()) return FALSE;
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
+ if (m_pVT->IsValid())
+ {
+ m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(m_pVT->InsertWord(m_wpCaret,word,GetCharSetFromUnicode(word, charset),pWordProps));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ SetCaret(m_pVT->InsertWord(m_wpCaret,word,GetCharSetFromUnicode(word, charset),pWordProps));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_InsertWord(this,m_wpOldCaret,m_wpCaret,word,charset,pWordProps));
- }
+ if (m_wpCaret != m_wpOldCaret)
+ {
+ if (bAddUndo && m_bEnableUndo)
+ {
+ AddEditUndoItem(new CFXEU_InsertWord(this,m_wpOldCaret,m_wpCaret,word,charset,pWordProps));
+ }
- if (bPaint)
- PaintInsertText(m_wpOldCaret, m_wpCaret);
+ if (bPaint)
+ PaintInsertText(m_wpOldCaret, m_wpCaret);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertWord(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertWord(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
- }
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps,
- FX_BOOL bAddUndo, FX_BOOL bPaint)
+ FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- if (IsTextOverflow()) return FALSE;
+ if (IsTextOverflow()) return FALSE;
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(m_pVT->InsertSection(m_wpCaret,pSecProps,pWordProps));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ if (m_pVT->IsValid())
+ {
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetCaret(m_pVT->InsertSection(m_wpCaret,pSecProps,pWordProps));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_InsertReturn(this,m_wpOldCaret,m_wpCaret,pSecProps,pWordProps));
- }
+ if (m_wpCaret != m_wpOldCaret)
+ {
+ if (bAddUndo && m_bEnableUndo)
+ {
+ AddEditUndoItem(new CFXEU_InsertReturn(this,m_wpOldCaret,m_wpCaret,pSecProps,pWordProps));
+ }
- if (bPaint)
- {
- RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret));
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
- Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ if (bPaint)
+ {
+ RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret));
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
+ Refresh(RP_ANALYSE, &wr);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
- }
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- if (m_pVT->IsValid())
- {
- if (m_wpCaret == m_pVT->GetBeginWordPlace()) return FALSE;
-
- CPVT_Section section;
- CPVT_Word word;
-
- if (bAddUndo)
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- pIterator->GetSection(section);
- pIterator->GetWord(word);
- }
- }
-
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(m_pVT->BackSpaceWord(m_wpCaret));
- m_SelState.Set(m_wpCaret,m_wpCaret);
-
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- if (m_wpCaret.SecCmp(m_wpOldCaret) != 0)
- AddEditUndoItem(new CFXEU_Backspace(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,section.WordProps));
- else
- AddEditUndoItem(new CFXEU_Backspace(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,word.WordProps));
- }
-
- if (bPaint)
- {
- RearrangePart(CPVT_WordRange(m_wpCaret,m_wpOldCaret));
- ScrollToCaret();
-
- CPVT_WordRange wr;
- if (m_wpCaret.SecCmp(m_wpOldCaret) !=0)
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),GetVisibleWordRange().EndPos);
- else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0)
- wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
- else
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
-
- Refresh(RP_ANALYSE, &wr);
-
- SetCaretOrigin();
- SetCaretInfo();
- }
-
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret);
-
- return TRUE;
- }
- }
-
- return FALSE;
+ if (m_pVT->IsValid())
+ {
+ if (m_wpCaret == m_pVT->GetBeginWordPlace()) return FALSE;
+
+ CPVT_Section section;
+ CPVT_Word word;
+
+ if (bAddUndo)
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(m_wpCaret);
+ pIterator->GetSection(section);
+ pIterator->GetWord(word);
+ }
+ }
+
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetCaret(m_pVT->BackSpaceWord(m_wpCaret));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
+
+ if (m_wpCaret != m_wpOldCaret)
+ {
+ if (bAddUndo && m_bEnableUndo)
+ {
+ if (m_wpCaret.SecCmp(m_wpOldCaret) != 0)
+ AddEditUndoItem(new CFXEU_Backspace(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
+ section.SecProps,section.WordProps));
+ else
+ AddEditUndoItem(new CFXEU_Backspace(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
+ section.SecProps,word.WordProps));
+ }
+
+ if (bPaint)
+ {
+ RearrangePart(CPVT_WordRange(m_wpCaret,m_wpOldCaret));
+ ScrollToCaret();
+
+ CPVT_WordRange wr;
+ if (m_wpCaret.SecCmp(m_wpOldCaret) !=0)
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),GetVisibleWordRange().EndPos);
+ else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0)
+ wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
+ else
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
+
+ Refresh(RP_ANALYSE, &wr);
+
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- if (m_pVT->IsValid())
- {
- if (m_wpCaret == m_pVT->GetEndWordPlace()) return FALSE;
+ if (m_pVT->IsValid())
+ {
+ if (m_wpCaret == m_pVT->GetEndWordPlace()) return FALSE;
- CPVT_Section section;
- CPVT_Word word;
+ CPVT_Section section;
+ CPVT_Word word;
- if (bAddUndo)
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret));
- pIterator->GetSection(section);
- pIterator->GetWord(word);
- }
- }
+ if (bAddUndo)
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret));
+ pIterator->GetSection(section);
+ pIterator->GetWord(word);
+ }
+ }
- m_pVT->UpdateWordPlace(m_wpCaret);
- FX_BOOL bSecEnd = (m_wpCaret == m_pVT->GetSectionEndPlace(m_wpCaret));
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ FX_BOOL bSecEnd = (m_wpCaret == m_pVT->GetSectionEndPlace(m_wpCaret));
- SetCaret(m_pVT->DeleteWord(m_wpCaret));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ SetCaret(m_pVT->DeleteWord(m_wpCaret));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
- if (bAddUndo && m_bEnableUndo)
- {
- if (bSecEnd)
- AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,section.WordProps,bSecEnd));
- else
- AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,word.WordProps,bSecEnd));
- }
+ if (bAddUndo && m_bEnableUndo)
+ {
+ if (bSecEnd)
+ AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
+ section.SecProps,section.WordProps,bSecEnd));
+ else
+ AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
+ section.SecProps,word.WordProps,bSecEnd));
+ }
- if (bPaint)
- {
- RearrangePart(CPVT_WordRange(m_wpOldCaret,m_wpCaret));
- ScrollToCaret();
+ if (bPaint)
+ {
+ RearrangePart(CPVT_WordRange(m_wpOldCaret,m_wpCaret));
+ ScrollToCaret();
- CPVT_WordRange wr;
- if (bSecEnd)
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),GetVisibleWordRange().EndPos);
- else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0)
- wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
- else
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
+ CPVT_WordRange wr;
+ if (bSecEnd)
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),GetVisibleWordRange().EndPos);
+ else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0)
+ wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
+ else
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
- Refresh(RP_ANALYSE, &wr);
+ Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::Empty()
+FX_BOOL CFX_Edit::Empty()
{
- if (m_pVT->IsValid())
- {
- m_pVT->DeleteWords(GetWholeWordRange());
- SetCaret(m_pVT->GetBeginWordPlace());
+ if (m_pVT->IsValid())
+ {
+ m_pVT->DeleteWords(GetWholeWordRange());
+ SetCaret(m_pVT->GetBeginWordPlace());
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- if (m_pVT->IsValid())
- {
- if (m_SelState.IsExist())
- {
- CPVT_WordRange range = m_SelState.ConvertToWordRange();
-
- if (bAddUndo && m_bEnableUndo)
- {
- if (m_pVT->IsRichText())
- {
- BeginGroupUndo(L"");
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(range.EndPos);
-
- CPVT_Word wordinfo;
- CPVT_Section secinfo;
- do
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(range.BeginPos) <= 0)break;
-
- CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place);
-
- if (oldplace.SecCmp(place) != 0)
- {
- if (pIterator->GetSection(secinfo))
- {
- AddEditUndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word,
- wordinfo.nCharset,secinfo.SecProps,secinfo.WordProps));
- }
- }
- else
- {
- if (pIterator->GetWord(wordinfo))
- {
- oldplace = m_pVT->AjustLineHeader(oldplace,TRUE);
- place = m_pVT->AjustLineHeader(place,TRUE);
-
- AddEditUndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word,
- wordinfo.nCharset,secinfo.SecProps,wordinfo.WordProps));
- }
- }
- }while (pIterator->PrevWord());
- }
- EndGroupUndo();
- }
- else
- {
- AddEditUndoItem(new CFXEU_Clear(this,range,GetSelText()));
- }
- }
-
- SelectNone();
- SetCaret(m_pVT->DeleteWords(range));
- m_SelState.Set(m_wpCaret,m_wpCaret);
-
- if (bPaint)
- {
- RearrangePart(range);
- ScrollToCaret();
-
- CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
- Refresh(RP_ANALYSE, &wr);
-
- SetCaretOrigin();
- SetCaretInfo();
- }
-
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
-
- return TRUE;
- }
- }
-
- return FALSE;
+ if (m_pVT->IsValid())
+ {
+ if (m_SelState.IsExist())
+ {
+ CPVT_WordRange range = m_SelState.ConvertToWordRange();
+
+ if (bAddUndo && m_bEnableUndo)
+ {
+ if (m_pVT->IsRichText())
+ {
+ BeginGroupUndo(L"");
+
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(range.EndPos);
+
+ CPVT_Word wordinfo;
+ CPVT_Section secinfo;
+ do
+ {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(range.BeginPos) <= 0)break;
+
+ CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place);
+
+ if (oldplace.SecCmp(place) != 0)
+ {
+ if (pIterator->GetSection(secinfo))
+ {
+ AddEditUndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word,
+ wordinfo.nCharset,secinfo.SecProps,secinfo.WordProps));
+ }
+ }
+ else
+ {
+ if (pIterator->GetWord(wordinfo))
+ {
+ oldplace = m_pVT->AjustLineHeader(oldplace,TRUE);
+ place = m_pVT->AjustLineHeader(place,TRUE);
+
+ AddEditUndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word,
+ wordinfo.nCharset,secinfo.SecProps,wordinfo.WordProps));
+ }
+ }
+ }while (pIterator->PrevWord());
+ }
+ EndGroupUndo();
+ }
+ else
+ {
+ AddEditUndoItem(new CFXEU_Clear(this,range,GetSelText()));
+ }
+ }
+
+ SelectNone();
+ SetCaret(m_pVT->DeleteWords(range));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
+
+ if (bPaint)
+ {
+ RearrangePart(range);
+ ScrollToCaret();
+
+ CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
+ Refresh(RP_ANALYSE, &wr);
+
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
+ const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
{
- if (IsTextOverflow()) return FALSE;
+ if (IsTextOverflow()) return FALSE;
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps));
+ m_SelState.Set(m_wpCaret,m_wpCaret);
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_InsertText(this,m_wpOldCaret,m_wpCaret,text,charset,pSecProps,pWordProps));
- }
+ if (m_wpCaret != m_wpOldCaret)
+ {
+ if (bAddUndo && m_bEnableUndo)
+ {
+ AddEditUndoItem(new CFXEU_InsertText(this,m_wpOldCaret,m_wpCaret,text,charset,pSecProps,pWordProps));
+ }
- if (bPaint)
- PaintInsertText(m_wpOldCaret, m_wpCaret);
+ if (bPaint)
+ PaintInsertText(m_wpOldCaret, m_wpCaret);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
- return FALSE;
+ return TRUE;
+ }
+ return FALSE;
}
void CFX_Edit::PaintInsertText(const CPVT_WordPlace & wpOld, const CPVT_WordPlace & wpNew)
{
- if (m_pVT->IsValid())
- {
- RearrangePart(CPVT_WordRange(wpOld,wpNew));
- ScrollToCaret();
+ if (m_pVT->IsValid())
+ {
+ RearrangePart(CPVT_WordRange(wpOld,wpNew));
+ ScrollToCaret();
- CPVT_WordRange wr;
- if (m_wpCaret.LineCmp(wpOld) !=0)
- wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld),m_pVT->GetSectionEndPlace(wpNew));
- else
- wr = CPVT_WordRange(wpOld,m_pVT->GetSectionEndPlace(wpNew));
- Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ CPVT_WordRange wr;
+ if (m_wpCaret.LineCmp(wpOld) !=0)
+ wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld),m_pVT->GetSectionEndPlace(wpNew));
+ else
+ wr = CPVT_WordRange(wpOld,m_pVT->GetSectionEndPlace(wpNew));
+ Refresh(RP_ANALYSE, &wr);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
FX_BOOL CFX_Edit::Redo()
{
- if (m_bEnableUndo)
- {
- if (m_Undo.CanRedo())
- {
- m_Undo.Redo();
- return TRUE;
- }
- }
+ if (m_bEnableUndo)
+ {
+ if (m_Undo.CanRedo())
+ {
+ m_Undo.Redo();
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFX_Edit::Undo()
{
- if (m_bEnableUndo)
- {
- if (m_Undo.CanUndo())
- {
- m_Undo.Undo();
- return TRUE;
- }
- }
+ if (m_bEnableUndo)
+ {
+ if (m_Undo.CanUndo())
+ {
+ m_Undo.Undo();
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
void CFX_Edit::SetCaretOrigin()
{
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- m_ptCaret.x = word.ptWord.x + word.fWidth;
- m_ptCaret.y = word.ptWord.y;
- }
- else if (pIterator->GetLine(line))
- {
- m_ptCaret.x = line.ptLine.x;
- m_ptCaret.y = line.ptLine.y;
- }
- }
- }
+ if (m_pVT->IsValid())
+ {
+ if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
+ {
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word))
+ {
+ m_ptCaret.x = word.ptWord.x + word.fWidth;
+ m_ptCaret.y = word.ptWord.y;
+ }
+ else if (pIterator->GetLine(line))
+ {
+ m_ptCaret.x = line.ptLine.x;
+ m_ptCaret.y = line.ptLine.y;
+ }
+ }
+ }
}
int32_t CFX_Edit::WordPlaceToWordIndex(const CPVT_WordPlace & place) const
{
- if (m_pVT->IsValid())
- return m_pVT->WordPlaceToWordIndex(place);
+ if (m_pVT->IsValid())
+ return m_pVT->WordPlaceToWordIndex(place);
- return -1;
+ return -1;
}
CPVT_WordPlace CFX_Edit::WordIndexToWordPlace(int32_t index) const
{
- if (m_pVT->IsValid())
- return m_pVT->WordIndexToWordPlace(index);
+ if (m_pVT->IsValid())
+ return m_pVT->WordIndexToWordPlace(index);
- return CPVT_WordPlace();
+ return CPVT_WordPlace();
}
-FX_BOOL CFX_Edit::IsTextFull() const
+FX_BOOL CFX_Edit::IsTextFull() const
{
- int32_t nTotalWords = m_pVT->GetTotalWords();
- int32_t nLimitChar = m_pVT->GetLimitChar();
- int32_t nCharArray = m_pVT->GetCharArray();
+ int32_t nTotalWords = m_pVT->GetTotalWords();
+ int32_t nLimitChar = m_pVT->GetLimitChar();
+ int32_t nCharArray = m_pVT->GetCharArray();
- return IsTextOverflow() || (nLimitChar>0 && nTotalWords >= nLimitChar)
- || (nCharArray>0 && nTotalWords >= nCharArray);
+ return IsTextOverflow() || (nLimitChar>0 && nTotalWords >= nLimitChar)
+ || (nCharArray>0 && nTotalWords >= nCharArray);
}
-FX_BOOL CFX_Edit::IsTextOverflow() const
+FX_BOOL CFX_Edit::IsTextOverflow() const
{
- if (!m_bEnableScroll && !m_bEnableOverflow)
- {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPDF_Rect rcContent = m_pVT->GetContentRect();
+ if (!m_bEnableScroll && !m_bEnableOverflow)
+ {
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
- if (m_pVT->IsMultiLine() && GetTotalLines() > 1)
- {
- if (FX_EDIT_IsFloatBigger(rcContent.Height(),rcPlate.Height())) return TRUE;
- }
+ if (m_pVT->IsMultiLine() && GetTotalLines() > 1)
+ {
+ if (FX_EDIT_IsFloatBigger(rcContent.Height(),rcPlate.Height())) return TRUE;
+ }
- if (FX_EDIT_IsFloatBigger(rcContent.Width(),rcPlate.Width())) return TRUE;
- }
+ if (FX_EDIT_IsFloatBigger(rcContent.Width(),rcPlate.Width())) return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace & place) const
{
- return m_pVT->GetLineBeginPlace(place);
+ return m_pVT->GetLineBeginPlace(place);
}
CPVT_WordPlace CFX_Edit::GetLineEndPlace(const CPVT_WordPlace & place) const
{
- return m_pVT->GetLineEndPlace(place);
+ return m_pVT->GetLineEndPlace(place);
}
CPVT_WordPlace CFX_Edit::GetSectionBeginPlace(const CPVT_WordPlace & place) const
{
- return m_pVT->GetSectionBeginPlace(place);
+ return m_pVT->GetSectionBeginPlace(place);
}
CPVT_WordPlace CFX_Edit::GetSectionEndPlace(const CPVT_WordPlace & place) const
{
- return m_pVT->GetSectionEndPlace(place);
+ return m_pVT->GetSectionEndPlace(place);
}
-FX_BOOL CFX_Edit::CanUndo() const
+FX_BOOL CFX_Edit::CanUndo() const
{
- if (m_bEnableUndo)
- {
- return m_Undo.CanUndo();
- }
+ if (m_bEnableUndo)
+ {
+ return m_Undo.CanUndo();
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::CanRedo() const
+FX_BOOL CFX_Edit::CanRedo() const
{
- if (m_bEnableUndo)
- {
- return m_Undo.CanRedo();
- }
+ if (m_bEnableUndo)
+ {
+ return m_Undo.CanRedo();
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::IsModified() const
+FX_BOOL CFX_Edit::IsModified() const
{
- if (m_bEnableUndo)
- {
- return m_Undo.IsModified();
- }
+ if (m_bEnableUndo)
+ {
+ return m_Undo.IsModified();
+ }
- return FALSE;
+ return FALSE;
}
void CFX_Edit::EnableRefresh(FX_BOOL bRefresh)
{
- m_bEnableRefresh = bRefresh;
+ m_bEnableRefresh = bRefresh;
}
void CFX_Edit::EnableUndo(FX_BOOL bUndo)
@@ -3466,74 +3439,74 @@ void CFX_Edit::EnableOprNotify(FX_BOOL bNotify)
FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const
{
- if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator())
- {
- CPVT_WordPlace wpOld = pIterator->GetAt();
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(place);
- CPVT_Line line;
- pIterator->GetLine(line);
+ pIterator->SetAt(place);
+ CPVT_Line line;
+ pIterator->GetLine(line);
- pIterator->SetAt(wpOld);
+ pIterator->SetAt(wpOld);
- return line.ptLine.y + line.fLineAscent;
- }
+ return line.ptLine.y + line.fLineAscent;
+ }
- return 0.0f;
+ return 0.0f;
}
FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const
{
- if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator())
- {
- CPVT_WordPlace wpOld = pIterator->GetAt();
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator())
+ {
+ CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(place);
- CPVT_Line line;
- pIterator->GetLine(line);
+ pIterator->SetAt(place);
+ CPVT_Line line;
+ pIterator->GetLine(line);
- pIterator->SetAt(wpOld);
+ pIterator->SetAt(wpOld);
- return line.ptLine.y + line.fLineDescent;
- }
+ return line.ptLine.y + line.fLineDescent;
+ }
- return 0.0f;
+ return 0.0f;
}
CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, const FX_WCHAR* text, int32_t charset,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps)
-{
- CPVT_WordPlace wp = place;
-
- if (m_pVT->IsValid())
- {
- CFX_WideString sText = text;
-
- for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++)
- {
- FX_WORD word = sText[i];
- switch (word)
- {
- case 0x0D:
- wp = m_pVT->InsertSection(wp,pSecProps,pWordProps);
- if (sText[i+1] == 0x0A)
- i++;
- break;
- case 0x0A:
- wp = m_pVT->InsertSection(wp,pSecProps,pWordProps);
- if (sText[i+1] == 0x0D)
- i++;
- break;
- case 0x09:
- word = 0x20;
- default:
- wp = m_pVT->InsertWord(wp,word,GetCharSetFromUnicode(word, charset),pWordProps);
- break;
- }
- }
- }
-
- return wp;
+ const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps)
+{
+ CPVT_WordPlace wp = place;
+
+ if (m_pVT->IsValid())
+ {
+ CFX_WideString sText = text;
+
+ for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++)
+ {
+ FX_WORD word = sText[i];
+ switch (word)
+ {
+ case 0x0D:
+ wp = m_pVT->InsertSection(wp,pSecProps,pWordProps);
+ if (sText[i+1] == 0x0A)
+ i++;
+ break;
+ case 0x0A:
+ wp = m_pVT->InsertSection(wp,pSecProps,pWordProps);
+ if (sText[i+1] == 0x0D)
+ i++;
+ break;
+ case 0x09:
+ word = 0x20;
+ default:
+ wp = m_pVT->InsertWord(wp,word,GetCharSetFromUnicode(word, charset),pWordProps);
+ break;
+ }
+ }
+ }
+
+ return wp;
}
int32_t CFX_Edit::GetCharSetFromUnicode(FX_WORD word, int32_t nOldCharset)
@@ -3545,38 +3518,38 @@ int32_t CFX_Edit::GetCharSetFromUnicode(FX_WORD word, int32_t nOldCharset)
void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle)
{
- ASSERT(m_pGroupUndoItem == NULL);
+ ASSERT(m_pGroupUndoItem == NULL);
- m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle);
+ m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle);
}
void CFX_Edit::EndGroupUndo()
{
- ASSERT(m_pGroupUndoItem != NULL);
+ ASSERT(m_pGroupUndoItem != NULL);
- m_pGroupUndoItem->UpdateItems();
- m_Undo.AddItem(m_pGroupUndoItem);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnAddUndo(m_pGroupUndoItem);
- m_pGroupUndoItem = NULL;
+ m_pGroupUndoItem->UpdateItems();
+ m_Undo.AddItem(m_pGroupUndoItem);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnAddUndo(m_pGroupUndoItem);
+ m_pGroupUndoItem = NULL;
}
void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem)
{
- if (m_pGroupUndoItem)
- m_pGroupUndoItem->AddUndoItem(pEditUndoItem);
- else
- {
- m_Undo.AddItem(pEditUndoItem);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnAddUndo(pEditUndoItem);
- }
+ if (m_pGroupUndoItem)
+ m_pGroupUndoItem->AddUndoItem(pEditUndoItem);
+ else
+ {
+ m_Undo.AddItem(pEditUndoItem);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnAddUndo(pEditUndoItem);
+ }
}
void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem)
{
- m_Undo.AddItem(pUndoItem);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnAddUndo(pUndoItem);
+ m_Undo.AddItem(pUndoItem);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnAddUndo(pUndoItem);
}
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index c35045c76b..fc453b0fc8 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -22,13 +22,13 @@
static v8::Isolate* GetIsolate(IFXJS_Context* cc)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- return pRuntime->GetIsolate();
+ return pRuntime->GetIsolate();
}
BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj)
@@ -45,14 +45,14 @@ IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj)
PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject)
: CJS_EmbedObj(pJSObject)
{
- bUI = TRUE;
- nStart = 0;
- nEnd = 0;
- bSilent = FALSE;
- bShrinkToFit = FALSE;
- bPrintAsImage = FALSE;
- bReverse = FALSE;
- bAnnotations = TRUE;
+ bUI = TRUE;
+ nStart = 0;
+ nEnd = 0;
+ bSilent = FALSE;
+ bShrinkToFit = FALSE;
+ bPrintAsImage = FALSE;
+ bReverse = FALSE;
+ bAnnotations = TRUE;
}
/* ---------------------- Document ---------------------- */
@@ -64,255 +64,255 @@ BEGIN_JS_STATIC_CONST(CJS_Document)
END_JS_STATIC_CONST()
BEGIN_JS_STATIC_PROP(CJS_Document)
- JS_STATIC_PROP_ENTRY(ADBE)
- JS_STATIC_PROP_ENTRY(author)
- JS_STATIC_PROP_ENTRY(baseURL)
- JS_STATIC_PROP_ENTRY(bookmarkRoot)
- JS_STATIC_PROP_ENTRY(calculate)
- JS_STATIC_PROP_ENTRY(Collab)
- JS_STATIC_PROP_ENTRY(creationDate)
- JS_STATIC_PROP_ENTRY(creator)
- JS_STATIC_PROP_ENTRY(delay)
- JS_STATIC_PROP_ENTRY(dirty)
- JS_STATIC_PROP_ENTRY(documentFileName)
- JS_STATIC_PROP_ENTRY(external)
- JS_STATIC_PROP_ENTRY(filesize)
- JS_STATIC_PROP_ENTRY(icons)
- JS_STATIC_PROP_ENTRY(info)
- JS_STATIC_PROP_ENTRY(keywords)
- JS_STATIC_PROP_ENTRY(layout)
- JS_STATIC_PROP_ENTRY(media)
- JS_STATIC_PROP_ENTRY(modDate)
- JS_STATIC_PROP_ENTRY(mouseX)
- JS_STATIC_PROP_ENTRY(mouseY)
- JS_STATIC_PROP_ENTRY(numFields)
- JS_STATIC_PROP_ENTRY(numPages)
- JS_STATIC_PROP_ENTRY(pageNum)
- JS_STATIC_PROP_ENTRY(pageWindowRect)
- JS_STATIC_PROP_ENTRY(path)
- JS_STATIC_PROP_ENTRY(producer)
- JS_STATIC_PROP_ENTRY(subject)
- JS_STATIC_PROP_ENTRY(title)
- JS_STATIC_PROP_ENTRY(zoom)
- JS_STATIC_PROP_ENTRY(zoomType)
+ JS_STATIC_PROP_ENTRY(ADBE)
+ JS_STATIC_PROP_ENTRY(author)
+ JS_STATIC_PROP_ENTRY(baseURL)
+ JS_STATIC_PROP_ENTRY(bookmarkRoot)
+ JS_STATIC_PROP_ENTRY(calculate)
+ JS_STATIC_PROP_ENTRY(Collab)
+ JS_STATIC_PROP_ENTRY(creationDate)
+ JS_STATIC_PROP_ENTRY(creator)
+ JS_STATIC_PROP_ENTRY(delay)
+ JS_STATIC_PROP_ENTRY(dirty)
+ JS_STATIC_PROP_ENTRY(documentFileName)
+ JS_STATIC_PROP_ENTRY(external)
+ JS_STATIC_PROP_ENTRY(filesize)
+ JS_STATIC_PROP_ENTRY(icons)
+ JS_STATIC_PROP_ENTRY(info)
+ JS_STATIC_PROP_ENTRY(keywords)
+ JS_STATIC_PROP_ENTRY(layout)
+ JS_STATIC_PROP_ENTRY(media)
+ JS_STATIC_PROP_ENTRY(modDate)
+ JS_STATIC_PROP_ENTRY(mouseX)
+ JS_STATIC_PROP_ENTRY(mouseY)
+ JS_STATIC_PROP_ENTRY(numFields)
+ JS_STATIC_PROP_ENTRY(numPages)
+ JS_STATIC_PROP_ENTRY(pageNum)
+ JS_STATIC_PROP_ENTRY(pageWindowRect)
+ JS_STATIC_PROP_ENTRY(path)
+ JS_STATIC_PROP_ENTRY(producer)
+ JS_STATIC_PROP_ENTRY(subject)
+ JS_STATIC_PROP_ENTRY(title)
+ JS_STATIC_PROP_ENTRY(zoom)
+ JS_STATIC_PROP_ENTRY(zoomType)
END_JS_STATIC_PROP()
BEGIN_JS_STATIC_METHOD(CJS_Document)
- JS_STATIC_METHOD_ENTRY(addAnnot)
- JS_STATIC_METHOD_ENTRY(addField)
- JS_STATIC_METHOD_ENTRY(addLink)
- JS_STATIC_METHOD_ENTRY(addIcon)
- JS_STATIC_METHOD_ENTRY(calculateNow)
- JS_STATIC_METHOD_ENTRY(closeDoc)
- JS_STATIC_METHOD_ENTRY(createDataObject)
- JS_STATIC_METHOD_ENTRY(deletePages)
- JS_STATIC_METHOD_ENTRY(exportAsText)
- JS_STATIC_METHOD_ENTRY(exportAsFDF)
- JS_STATIC_METHOD_ENTRY(exportAsXFDF)
- JS_STATIC_METHOD_ENTRY(extractPages)
- JS_STATIC_METHOD_ENTRY(getAnnot)
- JS_STATIC_METHOD_ENTRY(getAnnots)
- JS_STATIC_METHOD_ENTRY(getAnnot3D)
- JS_STATIC_METHOD_ENTRY(getAnnots3D)
- JS_STATIC_METHOD_ENTRY(getField)
- JS_STATIC_METHOD_ENTRY(getIcon)
- JS_STATIC_METHOD_ENTRY(getLinks)
- JS_STATIC_METHOD_ENTRY(getNthFieldName)
- JS_STATIC_METHOD_ENTRY(getOCGs)
- JS_STATIC_METHOD_ENTRY(getPageBox)
- JS_STATIC_METHOD_ENTRY(getPageNthWord)
- JS_STATIC_METHOD_ENTRY(getPageNthWordQuads)
- JS_STATIC_METHOD_ENTRY(getPageNumWords)
- JS_STATIC_METHOD_ENTRY(getPrintParams)
- JS_STATIC_METHOD_ENTRY(getURL)
- JS_STATIC_METHOD_ENTRY(importAnFDF)
- JS_STATIC_METHOD_ENTRY(importAnXFDF)
- JS_STATIC_METHOD_ENTRY(importTextData)
- JS_STATIC_METHOD_ENTRY(insertPages)
- JS_STATIC_METHOD_ENTRY(mailForm)
- JS_STATIC_METHOD_ENTRY(print)
- JS_STATIC_METHOD_ENTRY(removeField)
- JS_STATIC_METHOD_ENTRY(replacePages)
- JS_STATIC_METHOD_ENTRY(resetForm)
- JS_STATIC_METHOD_ENTRY(removeIcon)
- JS_STATIC_METHOD_ENTRY(saveAs)
- JS_STATIC_METHOD_ENTRY(submitForm)
- JS_STATIC_METHOD_ENTRY(mailDoc)
+ JS_STATIC_METHOD_ENTRY(addAnnot)
+ JS_STATIC_METHOD_ENTRY(addField)
+ JS_STATIC_METHOD_ENTRY(addLink)
+ JS_STATIC_METHOD_ENTRY(addIcon)
+ JS_STATIC_METHOD_ENTRY(calculateNow)
+ JS_STATIC_METHOD_ENTRY(closeDoc)
+ JS_STATIC_METHOD_ENTRY(createDataObject)
+ JS_STATIC_METHOD_ENTRY(deletePages)
+ JS_STATIC_METHOD_ENTRY(exportAsText)
+ JS_STATIC_METHOD_ENTRY(exportAsFDF)
+ JS_STATIC_METHOD_ENTRY(exportAsXFDF)
+ JS_STATIC_METHOD_ENTRY(extractPages)
+ JS_STATIC_METHOD_ENTRY(getAnnot)
+ JS_STATIC_METHOD_ENTRY(getAnnots)
+ JS_STATIC_METHOD_ENTRY(getAnnot3D)
+ JS_STATIC_METHOD_ENTRY(getAnnots3D)
+ JS_STATIC_METHOD_ENTRY(getField)
+ JS_STATIC_METHOD_ENTRY(getIcon)
+ JS_STATIC_METHOD_ENTRY(getLinks)
+ JS_STATIC_METHOD_ENTRY(getNthFieldName)
+ JS_STATIC_METHOD_ENTRY(getOCGs)
+ JS_STATIC_METHOD_ENTRY(getPageBox)
+ JS_STATIC_METHOD_ENTRY(getPageNthWord)
+ JS_STATIC_METHOD_ENTRY(getPageNthWordQuads)
+ JS_STATIC_METHOD_ENTRY(getPageNumWords)
+ JS_STATIC_METHOD_ENTRY(getPrintParams)
+ JS_STATIC_METHOD_ENTRY(getURL)
+ JS_STATIC_METHOD_ENTRY(importAnFDF)
+ JS_STATIC_METHOD_ENTRY(importAnXFDF)
+ JS_STATIC_METHOD_ENTRY(importTextData)
+ JS_STATIC_METHOD_ENTRY(insertPages)
+ JS_STATIC_METHOD_ENTRY(mailForm)
+ JS_STATIC_METHOD_ENTRY(print)
+ JS_STATIC_METHOD_ENTRY(removeField)
+ JS_STATIC_METHOD_ENTRY(replacePages)
+ JS_STATIC_METHOD_ENTRY(resetForm)
+ JS_STATIC_METHOD_ENTRY(removeIcon)
+ JS_STATIC_METHOD_ENTRY(saveAs)
+ JS_STATIC_METHOD_ENTRY(submitForm)
+ JS_STATIC_METHOD_ENTRY(mailDoc)
END_JS_STATIC_METHOD()
IMPLEMENT_JS_CLASS(CJS_Document, Document)
-FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc)
+FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
- Document* pDoc = (Document*)GetEmbedObject();
- ASSERT(pDoc != NULL);
+ Document* pDoc = (Document*)GetEmbedObject();
+ ASSERT(pDoc != NULL);
- pDoc->AttachDoc(pContext->GetReaderDocument());
- pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate());
- return TRUE;
+ pDoc->AttachDoc(pContext->GetReaderDocument());
+ pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate());
+ return TRUE;
};
/* --------------------------------- Document --------------------------------- */
Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject),
- m_isolate(NULL),
- m_pIconTree(NULL),
- m_pDocument(NULL),
- m_cwBaseURL(L""),
- m_bDelay(FALSE)
+ m_isolate(NULL),
+ m_pIconTree(NULL),
+ m_pDocument(NULL),
+ m_cwBaseURL(L""),
+ m_bDelay(FALSE)
{
}
Document::~Document()
{
- if (m_pIconTree)
- {
- m_pIconTree->DeleteIconTree();
- delete m_pIconTree;
- m_pIconTree = NULL;
- }
- for (int i=0; i<m_DelayData.GetSize(); i++)
- {
- if (CJS_DelayData* pData = m_DelayData.GetAt(i))
- {
- delete pData;
- pData = NULL;
- m_DelayData.SetAt(i, NULL);
+ if (m_pIconTree)
+ {
+ m_pIconTree->DeleteIconTree();
+ delete m_pIconTree;
+ m_pIconTree = NULL;
+ }
+ for (int i=0; i<m_DelayData.GetSize(); i++)
+ {
+ if (CJS_DelayData* pData = m_DelayData.GetAt(i))
+ {
+ delete pData;
+ pData = NULL;
+ m_DelayData.SetAt(i, NULL);
- }
- }
+ }
+ }
- m_DelayData.RemoveAll();
- m_DelayAnnotData.RemoveAll();
+ m_DelayData.RemoveAll();
+ m_DelayAnnotData.RemoveAll();
}
//the total number of fileds in document.
FX_BOOL Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting()) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
- return FALSE;
- }
- CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm();
- CPDF_InterForm *pPDFForm = pInterForm->GetInterForm();
- vp << (int)pPDFForm->CountFields();
- return TRUE;
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+ CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm();
+ CPDF_InterForm *pPDFForm = pInterForm->GetInterForm();
+ vp << (int)pPDFForm->CountFields();
+ return TRUE;
}
FX_BOOL Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsGetting())
- {
- if (m_pDocument->GetChangeMark())
- vp << true;
- else
- vp << false;
- }
- else
- {
- bool bChanged = false;
+ if (vp.IsGetting())
+ {
+ if (m_pDocument->GetChangeMark())
+ vp << true;
+ else
+ vp << false;
+ }
+ else
+ {
+ bool bChanged = false;
- vp >> bChanged;
+ vp >> bChanged;
- if (bChanged)
- m_pDocument->SetChangeMark();
- else
- m_pDocument->ClearChangeMark();
- }
+ if (bChanged)
+ m_pDocument->SetChangeMark();
+ else
+ m_pDocument->ClearChangeMark();
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsGetting())
- {
- vp.SetNull();
- }
- else
- {
- }
+ if (vp.IsGetting())
+ {
+ vp.SetNull();
+ }
+ else
+ {
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsGetting())
- {
- if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView())
- {
- vp << pPageView->GetPageIndex();
- }
- }
- else
- {
- int iPageCount = m_pDocument->GetPageCount();
- int iPageNum = 0;
- vp >> iPageNum;
-
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- if (iPageNum >= 0 && iPageNum < iPageCount)
- {
- pEnv->JS_docgotoPage(iPageNum);
- }
- else if (iPageNum >= iPageCount)
- {
- pEnv->JS_docgotoPage(iPageCount-1);
- }
- else if (iPageNum < 0)
- {
- pEnv->JS_docgotoPage(0);
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsGetting())
+ {
+ if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView())
+ {
+ vp << pPageView->GetPageIndex();
+ }
+ }
+ else
+ {
+ int iPageCount = m_pDocument->GetPageCount();
+ int iPageNum = 0;
+ vp >> iPageNum;
+
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ if (iPageNum >= 0 && iPageNum < iPageCount)
+ {
+ pEnv->JS_docgotoPage(iPageNum);
+ }
+ else if (iPageNum >= iPageCount)
+ {
+ pEnv->JS_docgotoPage(iPageCount-1);
+ }
+ else if (iPageNum < 0)
+ {
+ pEnv->JS_docgotoPage(0);
+ }
+ }
+
+ return TRUE;
}
FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj)
{
- // Not supported.
- return TRUE;
+ // Not supported.
+ return TRUE;
}
FX_BOOL Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Not supported.
- return TRUE;
+ // Not supported.
+ return TRUE;
}
FX_BOOL Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Not supported.
- return TRUE;
+ // Not supported.
+ return TRUE;
}
FX_BOOL Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Unsafe, not supported.
- return TRUE;
+ // Unsafe, not supported.
+ return TRUE;
}
FX_BOOL Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Unsafe, not supported.
- return TRUE;
+ // Unsafe, not supported.
+ return TRUE;
}
FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Unsafe, not supported.
- return TRUE;
+ // Unsafe, not supported.
+ return TRUE;
}
//Maps a field object in PDF document to a JavaScript variable
@@ -321,75 +321,75 @@ FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- if (params.size() < 1) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ CJS_Context* pContext = (CJS_Context*)cc;
+ if (params.size() < 1) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- CFX_WideString wideName = params[0].ToCFXWideString();
+ CFX_WideString wideName = params[0].ToCFXWideString();
- CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
- CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- if (pPDFForm->CountFields(wideName) <= 0)
- {
- vRet.SetNull();
- return TRUE;
- }
+ CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
+ CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
+ if (pPDFForm->CountFields(wideName) <= 0)
+ {
+ vRet.SetNull();
+ return TRUE;
+ }
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Field"));
- v8::Isolate* isolate = GetIsolate(cc);
- CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj);
- Field* pField = (Field *)pJSField->GetEmbedObject();
- pField->AttachField(this, wideName);
+ v8::Isolate* isolate = GetIsolate(cc);
+ CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj);
+ Field* pField = (Field *)pJSField->GetEmbedObject();
+ pField->AttachField(this, wideName);
- vRet = pJSField;
- return TRUE;
+ vRet = pJSField;
+ return TRUE;
}
//Gets the name of the nth field in the document
FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- if (params.size() != 1) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ CJS_Context* pContext = (CJS_Context*)cc;
+ if (params.size() != 1) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- int nIndex = params[0].ToInt();
- if (nIndex < 0) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
- return FALSE;
- }
+ int nIndex = params[0].ToInt();
+ if (nIndex < 0) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
+ return FALSE;
+ }
- CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
- CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- CPDF_FormField* pField = pPDFForm->GetField(nIndex);
- if (!pField)
- return FALSE;
+ CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
+ CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
+ CPDF_FormField* pField = pPDFForm->GetField(nIndex);
+ if (!pField)
+ return FALSE;
- vRet = pField->GetFullName().c_str();
- return TRUE;
+ vRet = pField->GetFullName().c_str();
+ return TRUE;
}
FX_BOOL Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Unsafe, not supported.
- return TRUE;
+ // Unsafe, not supported.
+ return TRUE;
}
FX_BOOL Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Unsafe, not supported.
- return TRUE;
+ // Unsafe, not supported.
+ return TRUE;
}
FX_BOOL Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- // Unsafe, not supported.
- return TRUE;
+ // Unsafe, not supported.
+ return TRUE;
}
//exports the form data and mails the resulting fdf file as an attachment to all recipients.
@@ -399,110 +399,110 @@ FX_BOOL Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params
FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
+ if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
- int iLength = params.size();
+ int iLength = params.size();
- FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
- CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L"";
- CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L"";
- CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L"";
- CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"";
- CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L"";
+ FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
+ CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L"";
+ CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L"";
+ CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L"";
+ CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"";
+ CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L"";
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CFX_ByteTextBuf textBuf;
- if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
- return FALSE;
+ CFX_ByteTextBuf textBuf;
+ if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
+ return FALSE;
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CPDFDoc_Environment* pEnv = pContext->GetReaderApp();
- ASSERT(pEnv != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+ CPDFDoc_Environment* pEnv = pContext->GetReaderApp();
+ ASSERT(pEnv != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- pRuntime->BeginBlock();
- pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
- pRuntime->EndBlock();
- return TRUE;
+ pRuntime->BeginBlock();
+ pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
+ pRuntime->EndBlock();
+ return TRUE;
}
FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
- FX_BOOL bUI = TRUE;
- int nStart = 0;
- int nEnd = 0;
- FX_BOOL bSilent = FALSE;
- FX_BOOL bShrinkToFit = FALSE;
- FX_BOOL bPrintAsImage = FALSE;
- FX_BOOL bReverse = FALSE;
- FX_BOOL bAnnotations = FALSE;
-
- int nlength = params.size();
- if(nlength ==9)
- {
- if (params[8].GetType() == VT_fxobject)
- {
- JSFXObject pObj = params[8].ToV8Object();
- {
- if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"))
- {
- if (CJS_Object* pJSObj = params[8].ToCJSObject())
- {
- if (PrintParamsObj* pprintparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject())
- {
- bUI = pprintparamsObj->bUI;
- nStart = pprintparamsObj->nStart;
- nEnd = pprintparamsObj->nEnd;
- bSilent = pprintparamsObj->bSilent;
- bShrinkToFit = pprintparamsObj->bShrinkToFit;
- bPrintAsImage = pprintparamsObj->bPrintAsImage;
- bReverse = pprintparamsObj->bReverse;
- bAnnotations = pprintparamsObj->bAnnotations;
- }
- }
- }
- }
- }
- }
- else
- {
- if(nlength >= 1)
- bUI = params[0].ToBool();
- if(nlength >= 2)
- nStart = params[1].ToInt();
- if(nlength >= 3)
- nEnd = params[2].ToInt();
- if(nlength >= 4)
- bSilent = params[3].ToBool();
- if(nlength >= 5)
- bShrinkToFit = params[4].ToBool();
- if(nlength >= 6)
- bPrintAsImage = params[5].ToBool();
- if(nlength >= 7)
- bReverse = params[6].ToBool();
- if(nlength >= 8)
- bAnnotations = params[7].ToBool();
- }
-
- ASSERT(m_pDocument != NULL);
-
- if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv())
- {
- pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations);
- return TRUE;
- }
- return FALSE;
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
+
+ FX_BOOL bUI = TRUE;
+ int nStart = 0;
+ int nEnd = 0;
+ FX_BOOL bSilent = FALSE;
+ FX_BOOL bShrinkToFit = FALSE;
+ FX_BOOL bPrintAsImage = FALSE;
+ FX_BOOL bReverse = FALSE;
+ FX_BOOL bAnnotations = FALSE;
+
+ int nlength = params.size();
+ if(nlength ==9)
+ {
+ if (params[8].GetType() == VT_fxobject)
+ {
+ JSFXObject pObj = params[8].ToV8Object();
+ {
+ if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"))
+ {
+ if (CJS_Object* pJSObj = params[8].ToCJSObject())
+ {
+ if (PrintParamsObj* pprintparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject())
+ {
+ bUI = pprintparamsObj->bUI;
+ nStart = pprintparamsObj->nStart;
+ nEnd = pprintparamsObj->nEnd;
+ bSilent = pprintparamsObj->bSilent;
+ bShrinkToFit = pprintparamsObj->bShrinkToFit;
+ bPrintAsImage = pprintparamsObj->bPrintAsImage;
+ bReverse = pprintparamsObj->bReverse;
+ bAnnotations = pprintparamsObj->bAnnotations;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if(nlength >= 1)
+ bUI = params[0].ToBool();
+ if(nlength >= 2)
+ nStart = params[1].ToInt();
+ if(nlength >= 3)
+ nEnd = params[2].ToInt();
+ if(nlength >= 4)
+ bSilent = params[3].ToBool();
+ if(nlength >= 5)
+ bShrinkToFit = params[4].ToBool();
+ if(nlength >= 6)
+ bPrintAsImage = params[5].ToBool();
+ if(nlength >= 7)
+ bReverse = params[6].ToBool();
+ if(nlength >= 8)
+ bAnnotations = params[7].ToBool();
+ }
+
+ ASSERT(m_pDocument != NULL);
+
+ if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv())
+ {
+ pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations);
+ return TRUE;
+ }
+ return FALSE;
}
//removes the specified field from the document.
@@ -511,54 +511,54 @@ FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
- m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE;
+ if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
+ m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE;
- CJS_Context* pContext = (CJS_Context*)cc;
- if (params.size() != 1) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ CJS_Context* pContext = (CJS_Context*)cc;
+ if (params.size() != 1) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- CFX_WideString sFieldName = params[0].ToCFXWideString();
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CFX_WideString sFieldName = params[0].ToCFXWideString();
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CFX_PtrArray widgets;
- pInterForm->GetWidgets(sFieldName, widgets);
+ CFX_PtrArray widgets;
+ pInterForm->GetWidgets(sFieldName, widgets);
- int nSize = widgets.GetSize();
+ int nSize = widgets.GetSize();
- if (nSize > 0)
- {
- for (int i=0; i<nSize; i++)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets[i];
- ASSERT(pWidget != NULL);
+ if (nSize > 0)
+ {
+ for (int i=0; i<nSize; i++)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets[i];
+ ASSERT(pWidget != NULL);
- CPDF_Rect rcAnnot = pWidget->GetRect();
- rcAnnot.left -= 1;
- rcAnnot.bottom -= 1;
- rcAnnot.right += 1;
- rcAnnot.top += 1;
+ CPDF_Rect rcAnnot = pWidget->GetRect();
+ rcAnnot.left -= 1;
+ rcAnnot.bottom -= 1;
+ rcAnnot.right += 1;
+ rcAnnot.top += 1;
- CFX_RectArray aRefresh;
- aRefresh.Add(rcAnnot);
+ CFX_RectArray aRefresh;
+ aRefresh.Add(rcAnnot);
- CPDF_Page* pPage = pWidget->GetPDFPage();
- ASSERT(pPage != NULL);
+ CPDF_Page* pPage = pWidget->GetPDFPage();
+ ASSERT(pPage != NULL);
- CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage);
- pPageView->DeleteAnnot(pWidget);
+ CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage);
+ pPageView->DeleteAnnot(pWidget);
- pPageView->UpdateRects(aRefresh);
- }
- m_pDocument->SetChangeMark();
- }
+ pPageView->UpdateRects(aRefresh);
+ }
+ m_pDocument->SetChangeMark();
+ }
- return TRUE;
+ return TRUE;
}
//reset filed values within a document.
@@ -567,62 +567,62 @@ FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
- m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
- m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE;
+ if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
+ m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE;
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- ASSERT(pPDFForm != NULL);
+ CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
+ ASSERT(pPDFForm != NULL);
- v8::Isolate* isolate = GetIsolate(cc);
- CJS_Array aName(isolate);
+ v8::Isolate* isolate = GetIsolate(cc);
+ CJS_Array aName(isolate);
- if (params.size() > 0)
- {
- switch (params[0].GetType())
- {
- default:
- aName.Attach(params[0].ToV8Array());
- break;
- case VT_string:
- aName.SetElement(0,params[0]);
- break;
- }
+ if (params.size() > 0)
+ {
+ switch (params[0].GetType())
+ {
+ default:
+ aName.Attach(params[0].ToV8Array());
+ break;
+ case VT_string:
+ aName.SetElement(0,params[0]);
+ break;
+ }
- CFX_PtrArray aFields;
+ CFX_PtrArray aFields;
- for (int i=0,isz=aName.GetLength(); i<isz; i++)
- {
- CJS_Value valElement(isolate);
- aName.GetElement(i,valElement);
- CFX_WideString swVal = valElement.ToCFXWideString();
+ for (int i=0,isz=aName.GetLength(); i<isz; i++)
+ {
+ CJS_Value valElement(isolate);
+ aName.GetElement(i,valElement);
+ CFX_WideString swVal = valElement.ToCFXWideString();
- for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++)
- {
- aFields.Add((void*)pPDFForm->GetField(j,swVal));
- }
- }
+ for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++)
+ {
+ aFields.Add((void*)pPDFForm->GetField(j,swVal));
+ }
+ }
- if (aFields.GetSize() > 0)
- {
- pPDFForm->ResetForm(aFields, TRUE, TRUE);
- m_pDocument->SetChangeMark();
+ if (aFields.GetSize() > 0)
+ {
+ pPDFForm->ResetForm(aFields, TRUE, TRUE);
+ m_pDocument->SetChangeMark();
- }
- }
- else
- {
- pPDFForm->ResetForm(TRUE);
- m_pDocument->SetChangeMark();
+ }
+ }
+ else
+ {
+ pPDFForm->ResetForm(TRUE);
+ m_pDocument->SetChangeMark();
- }
+ }
- return TRUE;
+ return TRUE;
}
@@ -635,907 +635,859 @@ FX_BOOL Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
- CJS_Context* pContext = (CJS_Context*)cc;
- int nSize = params.size();
- if (nSize < 1) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- CFX_WideString strURL;
- FX_BOOL bFDF = TRUE;
- FX_BOOL bEmpty = FALSE;
- v8::Isolate* isolate = GetIsolate(cc);
- CJS_Array aFields(isolate);
-
- CJS_Value v = params[0];
- if (v.GetType() == VT_string)
- {
- strURL = params[0].ToCFXWideString();
- if (nSize > 1)
- bFDF = params[1].ToBool();
- if (nSize > 2)
- bEmpty = params[2].ToBool();
- if (nSize > 3)
- aFields.Attach(params[3].ToV8Array());
- }
- else if (v.GetType() == VT_object)
- {
- JSObject pObj = params[0].ToV8Object();
- v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL");
- if (!pValue.IsEmpty())
- strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate, pObj, L"bFDF");
- bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
- pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty");
- bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
- pValue = JS_GetObjectElement(isolate, pObj,L"aFields");
- aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
- }
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
- CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- ASSERT(pPDFInterForm != NULL);
-
- FX_BOOL bAll = (aFields.GetLength() == 0);
-
- if (bAll && bEmpty)
- {
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
-
- if (pPDFInterForm->CheckRequiredFields())
- {
- pRuntime->BeginBlock();
- pInterForm->SubmitForm(strURL, FALSE);
- pRuntime->EndBlock();
- }
-
- return TRUE;
- }
- else
- {
- CFX_PtrArray fieldObjects;
-
- for (int i=0,sz=aFields.GetLength(); i<sz; i++)
- {
- CJS_Value valName(isolate);
- aFields.GetElement(i, valName);
- CFX_WideString sName = valName.ToCFXWideString();
-
- CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- ASSERT(pPDFForm != NULL);
-
- for (int j=0, jsz=pPDFForm->CountFields(sName); j<jsz; j++)
- {
- CPDF_FormField* pField = pPDFForm->GetField(j, sName);
- if (!bEmpty && pField->GetValue().IsEmpty())
- continue;
-
- fieldObjects.Add(pField);
- }
- }
-
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
-
- if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE))
- {
- pRuntime->BeginBlock();
- pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bFDF);
- pRuntime->EndBlock();
- }
-
- return TRUE;
- }
-
+ ASSERT(m_pDocument != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ int nSize = params.size();
+ if (nSize < 1) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ CFX_WideString strURL;
+ FX_BOOL bFDF = TRUE;
+ FX_BOOL bEmpty = FALSE;
+ v8::Isolate* isolate = GetIsolate(cc);
+ CJS_Array aFields(isolate);
+
+ CJS_Value v = params[0];
+ if (v.GetType() == VT_string)
+ {
+ strURL = params[0].ToCFXWideString();
+ if (nSize > 1)
+ bFDF = params[1].ToBool();
+ if (nSize > 2)
+ bEmpty = params[2].ToBool();
+ if (nSize > 3)
+ aFields.Attach(params[3].ToV8Array());
+ }
+ else if (v.GetType() == VT_object)
+ {
+ JSObject pObj = params[0].ToV8Object();
+ v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL");
+ if (!pValue.IsEmpty())
+ strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate, pObj, L"bFDF");
+ bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+ pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty");
+ bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+ pValue = JS_GetObjectElement(isolate, pObj,L"aFields");
+ aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
+ }
+
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
+ FX_BOOL bAll = (aFields.GetLength() == 0);
+ if (bAll && bEmpty)
+ {
+ if (pPDFInterForm->CheckRequiredFields())
+ {
+ pRuntime->BeginBlock();
+ pInterForm->SubmitForm(strURL, FALSE);
+ pRuntime->EndBlock();
+ }
+ return TRUE;
+ }
+
+ CFX_PtrArray fieldObjects;
+ for (int i=0,sz=aFields.GetLength(); i<sz; i++)
+ {
+ CJS_Value valName(isolate);
+ aFields.GetElement(i, valName);
+
+ CFX_WideString sName = valName.ToCFXWideString();
+ CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
+ for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j)
+ {
+ CPDF_FormField* pField = pPDFForm->GetField(j, sName);
+ if (!bEmpty && pField->GetValue().IsEmpty())
+ continue;
+
+ fieldObjects.Add(pField);
+ }
+ }
+
+ if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE))
+ {
+ pRuntime->BeginBlock();
+ pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bFDF);
+ pRuntime->EndBlock();
+ }
+ return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////////////////
void Document::AttachDoc(CPDFSDK_Document *pDoc)
{
- m_pDocument = pDoc;
+ m_pDocument = pDoc;
}
CPDFSDK_Document * Document::GetReaderDoc()
{
- return m_pDocument;
+ return m_pDocument;
}
FX_BOOL Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFileName)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFolderName)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- FX_BOOL bUI = TRUE;
- CFX_WideString cTo = L"";
- CFX_WideString cCc = L"";
- CFX_WideString cBcc = L"";
- CFX_WideString cSubject = L"";
- CFX_WideString cMsg = L"";
+ FX_BOOL bUI = TRUE;
+ CFX_WideString cTo = L"";
+ CFX_WideString cCc = L"";
+ CFX_WideString cBcc = L"";
+ CFX_WideString cSubject = L"";
+ CFX_WideString cMsg = L"";
- if (params.size() >= 1)
- bUI = params[0].ToBool();
- if (params.size() >= 2)
- cTo = params[1].ToCFXWideString();
- if (params.size() >= 3)
- cCc = params[2].ToCFXWideString();
- if (params.size() >= 4)
- cBcc = params[3].ToCFXWideString();
- if (params.size() >= 5)
- cSubject = params[4].ToCFXWideString();
- if (params.size() >= 6)
- cMsg = params[5].ToCFXWideString();
+ if (params.size() >= 1)
+ bUI = params[0].ToBool();
+ if (params.size() >= 2)
+ cTo = params[1].ToCFXWideString();
+ if (params.size() >= 3)
+ cCc = params[2].ToCFXWideString();
+ if (params.size() >= 4)
+ cBcc = params[3].ToCFXWideString();
+ if (params.size() >= 5)
+ cSubject = params[4].ToCFXWideString();
+ if (params.size() >= 6)
+ cMsg = params[5].ToCFXWideString();
- v8::Isolate* isolate = GetIsolate(cc);
+ v8::Isolate* isolate = GetIsolate(cc);
- if(params.size() >= 1 && params[0].GetType() == VT_object)
- {
- JSObject pObj = params[0].ToV8Object();
+ if(params.size() >= 1 && params[0].GetType() == VT_object)
+ {
+ JSObject pObj = params[0].ToV8Object();
- v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI");
- bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt();
+ v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI");
+ bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt();
- pValue = JS_GetObjectElement(isolate,pObj, L"cTo");
- cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate,pObj, L"cTo");
+ cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate,pObj, L"cCc");
- cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate,pObj, L"cCc");
+ cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate,pObj, L"cBcc");
- cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate,pObj, L"cBcc");
+ cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate,pObj, L"cSubject");
- cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate,pObj, L"cSubject");
+ cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate,pObj, L"cMsg");
- cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate,pObj, L"cMsg");
+ cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
- }
+ }
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- pRuntime->BeginBlock();
- CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp();
- pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
- pRuntime->EndBlock();
+ pRuntime->BeginBlock();
+ CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp();
+ pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
+ pRuntime->EndBlock();
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("Author");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("Author");
+ return TRUE;
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
- CFX_WideString csAuthor;
- vp >> csAuthor;
- pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString csAuthor;
+ vp >> csAuthor;
+ pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor));
+ m_pDocument->SetChangeMark();
+ return TRUE;
+ }
}
FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
-
- CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author");
- CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title");
- CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject");
- CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords");
- CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator");
- CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer");
- CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate");
- CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate");
- CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped");
-
- v8::Isolate* isolate = GetIsolate(cc);
- if (vp.IsGetting())
- {
- CJS_Context* pContext = (CJS_Context *)cc;
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1);
-
- JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str());
- JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str());
- JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str());
- JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str());
- JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str());
- JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str());
- JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str());
- JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str());
- JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str());
-
-// It's to be compatible to non-standard info dictionary.
- FX_POSITION pos = pDictionary->GetStartPos();
- while(pos)
- {
- CFX_ByteString bsKey;
- CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey);
- CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength());
- if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==PDFOBJ_NAME) )
- JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetUnicodeText().c_str());
- if(pValueObj->GetType()==PDFOBJ_NUMBER)
- JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj->GetNumber());
- if(pValueObj->GetType()==PDFOBJ_BOOLEAN)
- JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj->GetInteger());
- }
-
- vp << pObj;
- return TRUE;
- }
- else
- {
- return TRUE;
- }
+ ASSERT(m_pDocument != NULL);
+
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
+
+ CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author");
+ CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title");
+ CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject");
+ CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords");
+ CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator");
+ CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer");
+ CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate");
+ CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate");
+ CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped");
+
+ v8::Isolate* isolate = GetIsolate(cc);
+ if (vp.IsGetting())
+ {
+ CJS_Context* pContext = (CJS_Context *)cc;
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1);
+ JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str());
+ JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str());
+ JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str());
+ JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str());
+ JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str());
+ JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str());
+ JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str());
+ JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str());
+ JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str());
+
+ // It's to be compatible to non-standard info dictionary.
+ FX_POSITION pos = pDictionary->GetStartPos();
+ while(pos)
+ {
+ CFX_ByteString bsKey;
+ CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey);
+ CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength());
+ if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==PDFOBJ_NAME) )
+ JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetUnicodeText().c_str());
+ if(pValueObj->GetType()==PDFOBJ_NUMBER)
+ JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj->GetNumber());
+ if(pValueObj->GetType()==PDFOBJ_BOOLEAN)
+ JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj->GetInteger());
+ }
+ vp << pObj;
+ }
+ return TRUE;
}
FX_BOOL Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
-
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("CreationDate");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- CFX_WideString csCreationDate;
- vp >> csCreationDate;
- pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate));
- m_pDocument->SetChangeMark();
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("CreationDate");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- return TRUE;
- }
+ CFX_WideString csCreationDate;
+ vp >> csCreationDate;
+ pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("Creator");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("Creator");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
-
- CFX_WideString csCreator;
- vp >> csCreator;
- pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString csCreator;
+ vp >> csCreator;
+ pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsGetting())
- {
- vp << m_bDelay;
- return TRUE;
- }
- else
- {
- ASSERT(m_pDocument != NULL);
-
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
-
- bool b;
- vp >> b;
-
- m_bDelay = b;
-
- if (m_bDelay)
- {
- for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++)
- delete m_DelayData.GetAt(i);
-
- m_DelayData.RemoveAll();
- }
- else
- {
- CFX_ArrayTemplate<CJS_DelayData*> DelayDataToProcess;
-
- for (int i=0,sz=m_DelayData.GetSize(); i < sz; i++)
- {
- if (CJS_DelayData* pData = m_DelayData.GetAt(i))
- {
- DelayDataToProcess.Add(pData);
- m_DelayData.SetAt(i, NULL);
- }
- }
- m_DelayData.RemoveAll();
-
- for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i++)
- {
- CJS_DelayData* pData = DelayDataToProcess.GetAt(i);
- Field::DoDelay(m_pDocument, pData);
- DelayDataToProcess.SetAt(i,NULL);
- delete pData;
- }
- }
-
- return TRUE;
- }
+ if (vp.IsGetting())
+ {
+ vp << m_bDelay;
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
+
+ bool b;
+ vp >> b;
+ m_bDelay = b;
+ if (m_bDelay)
+ {
+ for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++)
+ delete m_DelayData.GetAt(i);
+
+ m_DelayData.RemoveAll();
+ }
+ else
+ {
+ CFX_ArrayTemplate<CJS_DelayData*> DelayDataToProcess;
+ for (int i=0,sz=m_DelayData.GetSize(); i < sz; i++)
+ {
+ if (CJS_DelayData* pData = m_DelayData.GetAt(i))
+ {
+ DelayDataToProcess.Add(pData);
+ m_DelayData.SetAt(i, NULL);
+ }
+ }
+ m_DelayData.RemoveAll();
+ for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i++)
+ {
+ CJS_DelayData* pData = DelayDataToProcess.GetAt(i);
+ Field::DoDelay(m_pDocument, pData);
+ DelayDataToProcess.SetAt(i,NULL);
+ delete pData;
+ }
+ }
+ }
+ return TRUE;
}
FX_BOOL Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("Keywords");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("Keywords");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- CFX_WideString csKeywords;
- vp >> csKeywords;
- pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString csKeywords;
+ vp >> csKeywords;
+ pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("ModDate");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("ModDate");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
-
- CFX_WideString csmodDate;
- vp >> csmodDate;
- pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString csmodDate;
+ vp >> csmodDate;
+ pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("Producer");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("Producer");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- CFX_WideString csproducer;
- vp >> csproducer;
- pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString csproducer;
+ vp >> csproducer;
+ pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("Subject");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("Subject");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- CFX_WideString cssubject;
- vp >> cssubject;
- pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString cssubject;
+ vp >> cssubject;
+ pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL)
+ return FALSE;
- if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL)
- return FALSE;
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ if (!pDictionary)
+ return FALSE;
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
- if (!pDictionary)return FALSE;
+ if (vp.IsGetting())
+ {
+ vp << pDictionary->GetUnicodeText("Title");
+ }
+ else
+ {
+ if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY))
+ return FALSE;
- if (vp.IsGetting())
- {
- vp << pDictionary->GetUnicodeText("Title");
- return TRUE;
- }
- else
- {
- if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
-
- CFX_WideString cstitle;
- vp >> cstitle;
- pDictionary->SetAtString("Title", PDF_EncodeText(cstitle));
- m_pDocument->SetChangeMark();
- return TRUE;
- }
+ CFX_WideString cstitle;
+ vp >> cstitle;
+ pDictionary->SetAtString("Title", PDF_EncodeText(cstitle));
+ m_pDocument->SetChangeMark();
+ }
+ return TRUE;
}
FX_BOOL Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting()) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
- return FALSE;
- }
- vp << m_pDocument->GetPageCount();
- return TRUE;
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+ vp << m_pDocument->GetPageCount();
+ return TRUE;
}
FX_BOOL Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- //In Chrome case,should always return true.
- if (vp.IsGetting()) {
- vp << TRUE;
- }
- return TRUE;
+ //In Chrome case,should always return true.
+ if (vp.IsGetting()) {
+ vp << TRUE;
+ }
+ return TRUE;
}
FX_BOOL Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting()) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
- return FALSE;
- }
- vp << 0;
- return TRUE;
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+ vp << 0;
+ return TRUE;
}
FX_BOOL Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsGetting())
- {
- vp << m_cwBaseURL;
- }
- else
- {
- vp >> m_cwBaseURL;
- }
- return TRUE;
+ if (vp.IsGetting())
+ {
+ vp << m_cwBaseURL;
+ }
+ else
+ {
+ vp >> m_cwBaseURL;
+ }
+ return TRUE;
}
FX_BOOL Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- if (vp.IsGetting())
- {
- if (pInterForm->IsCalculateEnabled())
- vp << true;
- else
- vp << false;
- }
- else
- {
- bool bCalculate;
- vp >> bCalculate;
+ if (vp.IsGetting())
+ {
+ if (pInterForm->IsCalculateEnabled())
+ vp << true;
+ else
+ vp << false;
+ }
+ else
+ {
+ bool bCalculate;
+ vp >> bCalculate;
- pInterForm->EnableCalculate(bCalculate);
- }
+ pInterForm->EnableCalculate(bCalculate);
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting()) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
- return FALSE;
- }
- CFX_WideString wsFilePath = m_pDocument->GetPath();
- int32_t i = wsFilePath.GetLength() - 1;
- for ( ; i >= 0; i-- )
- {
- if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) == L'/' )
- break;
- }
- if ( i >= 0 && i < wsFilePath.GetLength() - 1 )
- {
- vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 );
- }else{
- vp << L"";
- }
- return TRUE;
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+ CFX_WideString wsFilePath = m_pDocument->GetPath();
+ int32_t i = wsFilePath.GetLength() - 1;
+ for ( ; i >= 0; i-- )
+ {
+ if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) == L'/' )
+ break;
+ }
+ if ( i >= 0 && i < wsFilePath.GetLength() - 1 )
+ {
+ vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 );
+ }else{
+ vp << L"";
+ }
+ return TRUE;
}
CFX_WideString Document::ReversalStr(CFX_WideString cbFrom)
{
- size_t iLength = cbFrom.GetLength();
+ size_t iLength = cbFrom.GetLength();
pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
- iSize *= (iLength + 1);
- wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
- wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
+ iSize *= (iLength + 1);
+ wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
+ wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
- for (size_t i = 0; i < iLength; i++)
- {
- pResult[i] = *(pFrom + iLength - i - 1);
- }
- pResult[iLength] = L'\0';
+ for (size_t i = 0; i < iLength; i++)
+ {
+ pResult[i] = *(pFrom + iLength - i - 1);
+ }
+ pResult[iLength] = L'\0';
- cbFrom.ReleaseBuffer();
- CFX_WideString cbRet = CFX_WideString(pResult);
- free(pResult);
- pResult = NULL;
- return cbRet;
+ cbFrom.ReleaseBuffer();
+ CFX_WideString cbRet = CFX_WideString(pResult);
+ free(pResult);
+ pResult = NULL;
+ return cbRet;
}
CFX_WideString Document::CutString(CFX_WideString cbFrom)
{
- size_t iLength = cbFrom.GetLength();
- pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
- iSize *= (iLength + 1);
- wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
- wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
-
- for (int i = 0; i < iLength; i++)
- {
- if (pFrom[i] == L'\\' || pFrom[i] == L'/')
- {
- pResult[i] = L'\0';
- break;
- }
- pResult[i] = pFrom[i];
- }
- pResult[iLength] = L'\0';
-
- cbFrom.ReleaseBuffer();
- CFX_WideString cbRet = CFX_WideString(pResult);
- free(pResult);
- pResult = NULL;
- return cbRet;
+ size_t iLength = cbFrom.GetLength();
+ pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
+ iSize *= (iLength + 1);
+ wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
+ wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
+
+ for (int i = 0; i < iLength; i++)
+ {
+ if (pFrom[i] == L'\\' || pFrom[i] == L'/')
+ {
+ pResult[i] = L'\0';
+ break;
+ }
+ pResult[i] = pFrom[i];
+ }
+ pResult[iLength] = L'\0';
+
+ cbFrom.ReleaseBuffer();
+ CFX_WideString cbRet = CFX_WideString(pResult);
+ free(pResult);
+ pResult = NULL;
+ return cbRet;
}
FX_BOOL Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting()) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
- return FALSE;
- }
- vp << app::SysPathToPDFPath(m_pDocument->GetPath());
- return TRUE;
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+ vp << app::SysPathToPDFPath(m_pDocument->GetPath());
+ return TRUE;
}
FX_BOOL Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+ return TRUE;
}
FX_BOOL Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- vRet.SetNull();
- return TRUE;
+ vRet.SetNull();
+ return TRUE;
}
FX_BOOL Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- vRet.SetNull();
- return TRUE;
+ vRet.SetNull();
+ return TRUE;
}
FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- vRet = VT_undefined;
- return TRUE;
+ vRet = VT_undefined;
+ return TRUE;
}
FX_BOOL Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect)
{
- if (rect.left <= LinkRect.left
- && rect.top <= LinkRect.top
- && rect.right >= LinkRect.right
- && rect.bottom >= LinkRect.bottom)
- return true;
- else
- return false;
+ return (rect.left <= LinkRect.left &&
+ rect.top <= LinkRect.top &&
+ rect.right >= LinkRect.right &&
+ rect.bottom >= LinkRect.bottom);
}
void IconTree::InsertIconElement(IconElement* pNewIcon)
{
- if (!pNewIcon)return;
+ if (!pNewIcon)return;
- if (m_pHead == NULL && m_pEnd == NULL)
- {
- m_pHead = m_pEnd = pNewIcon;
- m_iLength++;
- }
- else
- {
- m_pEnd->NextIcon = pNewIcon;
- m_pEnd = pNewIcon;
- m_iLength++;
- }
+ if (m_pHead == NULL && m_pEnd == NULL)
+ {
+ m_pHead = m_pEnd = pNewIcon;
+ m_iLength++;
+ }
+ else
+ {
+ m_pEnd->NextIcon = pNewIcon;
+ m_pEnd = pNewIcon;
+ m_iLength++;
+ }
}
void IconTree::DeleteIconTree()
{
- if (!m_pHead || !m_pEnd)return;
+ if (!m_pHead || !m_pEnd)return;
- IconElement* pTemp = NULL;
- while(m_pEnd != m_pHead)
- {
- pTemp = m_pHead;
- m_pHead = m_pHead->NextIcon;
- delete pTemp;
- }
+ IconElement* pTemp = NULL;
+ while(m_pEnd != m_pHead)
+ {
+ pTemp = m_pHead;
+ m_pHead = m_pHead->NextIcon;
+ delete pTemp;
+ }
- delete m_pEnd;
- m_pHead = NULL;
- m_pEnd = NULL;
+ delete m_pEnd;
+ m_pHead = NULL;
+ m_pEnd = NULL;
}
int IconTree::GetLength()
{
- return m_iLength;
+ return m_iLength;
}
IconElement* IconTree::operator [](int iIndex)
{
- if (iIndex >= 0 && iIndex <= m_iLength)
- {
- IconElement* pTemp = m_pHead;
- for (int i = 0; i < iIndex; i++)
- {
- pTemp = pTemp->NextIcon;
- }
- return pTemp;
- }
- else
- return NULL;
+ if (iIndex >= 0 && iIndex <= m_iLength)
+ {
+ IconElement* pTemp = m_pHead;
+ for (int i = 0; i < iIndex; i++)
+ {
+ pTemp = pTemp->NextIcon;
+ }
+ return pTemp;
+ }
+ return NULL;
}
FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- if (params.size() != 2) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ CJS_Context* pContext = (CJS_Context*)cc;
+ if (params.size() != 2) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- CFX_WideString swIconName = params[0].ToCFXWideString();
- JSFXObject pJSIcon = params[1].ToV8Object();
+ CFX_WideString swIconName = params[0].ToCFXWideString();
+ JSFXObject pJSIcon = params[1].ToV8Object();
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
- return FALSE;
- }
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
+ return FALSE;
+ }
- CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject();
- if (!pEmbedObj) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
- return FALSE;
- }
+ CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject();
+ if (!pEmbedObj) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
+ return FALSE;
+ }
- Icon* pIcon = (Icon*)pEmbedObj;
- if (!m_pIconTree)
- m_pIconTree = new IconTree();
+ Icon* pIcon = (Icon*)pEmbedObj;
+ if (!m_pIconTree)
+ m_pIconTree = new IconTree();
- IconElement* pNewIcon = new IconElement();
- pNewIcon->IconName = swIconName;
- pNewIcon->NextIcon = NULL;
- pNewIcon->IconStream = pIcon;
- m_pIconTree->InsertIconElement(pNewIcon);
- return TRUE;
+ IconElement* pNewIcon = new IconElement();
+ pNewIcon->IconName = swIconName;
+ pNewIcon->NextIcon = NULL;
+ pNewIcon->IconStream = pIcon;
+ m_pIconTree->InsertIconElement(pNewIcon);
+ return TRUE;
}
FX_BOOL Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting()) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
- return FALSE;
- }
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
- if (!m_pIconTree)
- {
- vp.SetNull();
- return TRUE;
- }
+ if (!m_pIconTree)
+ {
+ vp.SetNull();
+ return TRUE;
+ }
- CJS_Array Icons(m_isolate);
- IconElement* pIconElement = NULL;
- int iIconTreeLength = m_pIconTree->GetLength();
+ CJS_Array Icons(m_isolate);
+ IconElement* pIconElement = NULL;
+ int iIconTreeLength = m_pIconTree->GetLength();
- CJS_Context* pContext = (CJS_Context *)cc;
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ CJS_Context* pContext = (CJS_Context *)cc;
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- for (int i = 0; i < iIconTreeLength; i++)
- {
- pIconElement = (*m_pIconTree)[i];
+ for (int i = 0; i < iIconTreeLength; i++)
+ {
+ pIconElement = (*m_pIconTree)[i];
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
- if (pObj.IsEmpty()) return FALSE;
+ JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
+ if (pObj.IsEmpty()) return FALSE;
- CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj);
- if (!pJS_Icon) return FALSE;
+ CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj);
+ if (!pJS_Icon) return FALSE;
- Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
- if (!pIcon)return FALSE;
+ Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
+ if (!pIcon)return FALSE;
- pIcon->SetStream(pIconElement->IconStream->GetStream());
- pIcon->SetIconName(pIconElement->IconName);
- Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon));
- }
+ pIcon->SetStream(pIconElement->IconStream->GetStream());
+ pIcon->SetIconName(pIconElement->IconName);
+ Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon));
+ }
- vp << Icons;
- return TRUE;
+ vp << Icons;
+ return TRUE;
}
FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- if (params.size() != 1) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ CJS_Context* pContext = (CJS_Context *)cc;
+ if (params.size() != 1) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- if(!m_pIconTree)
- return FALSE;
- CFX_WideString swIconName = params[0].ToCFXWideString();
- int iIconCounts = m_pIconTree->GetLength();
+ if(!m_pIconTree)
+ return FALSE;
+ CFX_WideString swIconName = params[0].ToCFXWideString();
+ int iIconCounts = m_pIconTree->GetLength();
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- for (int i = 0; i < iIconCounts; i++)
- {
- if ((*m_pIconTree)[i]->IconName == swIconName)
- {
- Icon* pRetIcon = (*m_pIconTree)[i]->IconStream;
+ for (int i = 0; i < iIconCounts; i++)
+ {
+ if ((*m_pIconTree)[i]->IconName == swIconName)
+ {
+ Icon* pRetIcon = (*m_pIconTree)[i]->IconStream;
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
- if (pObj.IsEmpty()) return FALSE;
+ JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
+ if (pObj.IsEmpty()) return FALSE;
- CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj);
- if (!pJS_Icon) return FALSE;
+ CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj);
+ if (!pJS_Icon) return FALSE;
- Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
- if (!pIcon)return FALSE;
+ Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
+ if (!pIcon)return FALSE;
- pIcon->SetIconName(swIconName);
- pIcon->SetStream(pRetIcon->GetStream());
- vRet = pJS_Icon;
- return TRUE;
- }
- }
+ pIcon->SetIconName(swIconName);
+ pIcon->SetStream(pRetIcon->GetStream());
+ vRet = pJS_Icon;
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
@@ -1552,255 +1504,255 @@ FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
- m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
- m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE;
+ if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
+ m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE;
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
- pInterForm->OnCalculate();
- return TRUE;
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+ pInterForm->OnCalculate();
+ return TRUE;
}
FX_BOOL Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
+ if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
- int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
- int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0;
- bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true;
+ int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
+ int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0;
+ bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true;
- CPDF_Document* pDocument = m_pDocument->GetDocument();
- if (!pDocument) return FALSE;
+ CPDF_Document* pDocument = m_pDocument->GetDocument();
+ if (!pDocument) return FALSE;
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
- return FALSE;
- }
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
+ return FALSE;
+ }
- CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
- if (!pPageDict) return FALSE;
+ CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
+ if (!pPageDict) return FALSE;
- CPDF_Page page;
- page.Load(pDocument, pPageDict);
- page.StartParse();
- page.ParseContent();
+ CPDF_Page page;
+ page.Load(pDocument, pPageDict);
+ page.StartParse();
+ page.ParseContent();
- FX_POSITION pos = page.GetFirstObjectPosition();
+ FX_POSITION pos = page.GetFirstObjectPosition();
- int nWords = 0;
+ int nWords = 0;
- CFX_WideString swRet;
+ CFX_WideString swRet;
- while (pos)
- {
- if (CPDF_PageObject* pPageObj = page.GetNextObject(pos))
- {
- if (pPageObj->m_Type == PDFPAGE_TEXT)
- {
- int nObjWords = CountWords((CPDF_TextObject*)pPageObj);
+ while (pos)
+ {
+ if (CPDF_PageObject* pPageObj = page.GetNextObject(pos))
+ {
+ if (pPageObj->m_Type == PDFPAGE_TEXT)
+ {
+ int nObjWords = CountWords((CPDF_TextObject*)pPageObj);
- if (nWords + nObjWords >= nWordNo)
- {
- swRet = GetObjWordStr((CPDF_TextObject*)pPageObj, nWordNo - nWords);
- break;
- }
+ if (nWords + nObjWords >= nWordNo)
+ {
+ swRet = GetObjWordStr((CPDF_TextObject*)pPageObj, nWordNo - nWords);
+ break;
+ }
- nWords += nObjWords;
- }
- }
- }
+ nWords += nObjWords;
+ }
+ }
+ }
- if (bStrip)
- {
- swRet.TrimLeft();
- swRet.TrimRight();
- }
+ if (bStrip)
+ {
+ swRet.TrimLeft();
+ swRet.TrimRight();
+ }
- vRet = swRet.c_str();
- return TRUE;
+ vRet = swRet.c_str();
+ return TRUE;
}
FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
+ if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
- return FALSE;
+ return FALSE;
}
FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
+ if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
- int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
+ int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
- CPDF_Document* pDocument = m_pDocument->GetDocument();
- ASSERT(pDocument != NULL);
+ CPDF_Document* pDocument = m_pDocument->GetDocument();
+ ASSERT(pDocument != NULL);
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
- return FALSE;
- }
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
+ return FALSE;
+ }
- CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
- if (!pPageDict) return FALSE;
+ CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
+ if (!pPageDict) return FALSE;
- CPDF_Page page;
- page.Load(pDocument, pPageDict);
- page.StartParse();
- page.ParseContent();
+ CPDF_Page page;
+ page.Load(pDocument, pPageDict);
+ page.StartParse();
+ page.ParseContent();
- FX_POSITION pos = page.GetFirstObjectPosition();
+ FX_POSITION pos = page.GetFirstObjectPosition();
- int nWords = 0;
+ int nWords = 0;
- while (pos)
- {
- if (CPDF_PageObject* pPageObj = page.GetNextObject(pos))
- {
- if (pPageObj->m_Type == PDFPAGE_TEXT)
- {
- CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj;
- nWords += CountWords(pTextObj);
- }
- }
- }
+ while (pos)
+ {
+ if (CPDF_PageObject* pPageObj = page.GetNextObject(pos))
+ {
+ if (pPageObj->m_Type == PDFPAGE_TEXT)
+ {
+ CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj;
+ nWords += CountWords(pTextObj);
+ }
+ }
+ }
- vRet = nWords;
+ vRet = nWords;
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"));
+ CJS_Context* pContext = (CJS_Context*)cc;
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"));
- // Not implemented yet.
+ // Not implemented yet.
- vRet = pRetObj;
- return TRUE;
+ vRet = pRetObj;
+ return TRUE;
}
-#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
+#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
-int Document::CountWords(CPDF_TextObject* pTextObj)
+int Document::CountWords(CPDF_TextObject* pTextObj)
{
- if (!pTextObj) return 0;
+ if (!pTextObj) return 0;
- int nWords = 0;
+ int nWords = 0;
- CPDF_Font* pFont = pTextObj->GetFont();
- if (!pFont) return 0;
+ CPDF_Font* pFont = pTextObj->GetFont();
+ if (!pFont) return 0;
- FX_BOOL bIsLatin = FALSE;
+ FX_BOOL bIsLatin = FALSE;
- for (int i=0, sz=pTextObj->CountChars(); i<sz; i++)
- {
- FX_DWORD charcode = -1;
- FX_FLOAT kerning;
+ for (int i=0, sz=pTextObj->CountChars(); i<sz; i++)
+ {
+ FX_DWORD charcode = -1;
+ FX_FLOAT kerning;
- pTextObj->GetCharInfo(i, charcode, kerning);
- CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
+ pTextObj->GetCharInfo(i, charcode, kerning);
+ CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
- FX_WORD unicode = 0;
- if (swUnicode.GetLength() > 0)
- unicode = swUnicode[0];
+ FX_WORD unicode = 0;
+ if (swUnicode.GetLength() > 0)
+ unicode = swUnicode[0];
- if (ISLATINWORD(unicode) && bIsLatin)
- continue;
+ if (ISLATINWORD(unicode) && bIsLatin)
+ continue;
- bIsLatin = ISLATINWORD(unicode);
- if (unicode != 0x20)
- nWords++;
- }
+ bIsLatin = ISLATINWORD(unicode);
+ if (unicode != 0x20)
+ nWords++;
+ }
- return nWords;
+ return nWords;
}
CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex)
{
- ASSERT(pTextObj != NULL);
+ ASSERT(pTextObj != NULL);
- CFX_WideString swRet;
+ CFX_WideString swRet;
- CPDF_Font* pFont = pTextObj->GetFont();
- if (!pFont) return L"";
+ CPDF_Font* pFont = pTextObj->GetFont();
+ if (!pFont) return L"";
- int nWords = 0;
- FX_BOOL bIsLatin = FALSE;
+ int nWords = 0;
+ FX_BOOL bIsLatin = FALSE;
- for (int i=0, sz=pTextObj->CountChars(); i<sz; i++)
- {
- FX_DWORD charcode = -1;
- FX_FLOAT kerning;
+ for (int i=0, sz=pTextObj->CountChars(); i<sz; i++)
+ {
+ FX_DWORD charcode = -1;
+ FX_FLOAT kerning;
- pTextObj->GetCharInfo(i, charcode, kerning);
- CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
+ pTextObj->GetCharInfo(i, charcode, kerning);
+ CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
- FX_WORD unicode = 0;
- if (swUnicode.GetLength() > 0)
- unicode = swUnicode[0];
+ FX_WORD unicode = 0;
+ if (swUnicode.GetLength() > 0)
+ unicode = swUnicode[0];
- if (ISLATINWORD(unicode) && bIsLatin)
- {
- }
- else
- {
- bIsLatin = ISLATINWORD(unicode);
- if (unicode != 0x20)
- nWords++;
- }
+ if (ISLATINWORD(unicode) && bIsLatin)
+ {
+ }
+ else
+ {
+ bIsLatin = ISLATINWORD(unicode);
+ if (unicode != 0x20)
+ nWords++;
+ }
- if (nWords-1 == nWordIndex)
- swRet += unicode;
- }
+ if (nWords-1 == nWordIndex)
+ swRet += unicode;
+ }
- return swRet;
+ return swRet;
}
FX_BOOL Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
/**
-(none, NoVary)
-(fitP, FitPage)
-(fitW, FitWidth)
-(fitH, FitHeight)
-(fitV, FitVisibleWidth)
-(pref, Preferred)
-(refW, ReflowWidth)
+(none, NoVary)
+(fitP, FitPage)
+(fitW, FitWidth)
+(fitH, FitHeight)
+(fitV, FitVisibleWidth)
+(pref, Preferred)
+(refW, ReflowWidth)
*/
FX_BOOL Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
@@ -1835,58 +1787,57 @@ FX_BOOL Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
void Document::AddDelayData(CJS_DelayData* pData)
{
- m_DelayData.Add(pData);
+ m_DelayData.Add(pData);
}
void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex)
{
- CFX_DWordArray DelArray;
- CFX_ArrayTemplate<CJS_DelayData*> DelayDataForFieldAndControlIndex;
-
- for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++)
- {
- if (CJS_DelayData* pData = m_DelayData.GetAt(i))
- {
- if (pData->sFieldName == sFieldName && pData->nControlIndex == nControlIndex)
- {
- DelayDataForFieldAndControlIndex.Add(pData);
- m_DelayData.SetAt(i, NULL);
- DelArray.Add(i);
- }
- }
- }
-
- for (int j=DelArray.GetSize()-1; j>=0; j--)
- {
- m_DelayData.RemoveAt(DelArray[j]);
- }
-
- for (int i=0,sz=DelayDataForFieldAndControlIndex.GetSize(); i < sz; i++)
- {
- CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i);
- Field::DoDelay(m_pDocument, pData);
- DelayDataForFieldAndControlIndex.SetAt(i,NULL);
- delete pData;
- }
+ CFX_DWordArray DelArray;
+ CFX_ArrayTemplate<CJS_DelayData*> DelayDataForFieldAndControlIndex;
+
+ for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++)
+ {
+ if (CJS_DelayData* pData = m_DelayData.GetAt(i))
+ {
+ if (pData->sFieldName == sFieldName && pData->nControlIndex == nControlIndex)
+ {
+ DelayDataForFieldAndControlIndex.Add(pData);
+ m_DelayData.SetAt(i, NULL);
+ DelArray.Add(i);
+ }
+ }
+ }
+
+ for (int j=DelArray.GetSize()-1; j>=0; j--)
+ {
+ m_DelayData.RemoveAt(DelArray[j]);
+ }
+
+ for (int i=0,sz=DelayDataForFieldAndControlIndex.GetSize(); i < sz; i++)
+ {
+ CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i);
+ Field::DoDelay(m_pDocument, pData);
+ DelayDataForFieldAndControlIndex.SetAt(i,NULL);
+ delete pData;
+ }
}
void Document::AddDelayAnnotData(CJS_AnnotObj *pData)
{
- m_DelayAnnotData.Add(pData);
+ m_DelayAnnotData.Add(pData);
}
void Document::DoAnnotDelay()
{
- CFX_DWordArray DelArray;
+ CFX_DWordArray DelArray;
- for (int j=DelArray.GetSize()-1; j>=0; j--)
- {
- m_DelayData.RemoveAt(DelArray[j]);
- }
+ for (int j=DelArray.GetSize()-1; j>=0; j--)
+ {
+ m_DelayData.RemoveAt(DelArray[j]);
+ }
}
CJS_Document* Document::GetCJSDoc() const
{
- return static_cast<CJS_Document*>(m_pJSObject);
+ return static_cast<CJS_Document*>(m_pJSObject);
}
-
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 8393d9d5ff..614843426e 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -25,111 +25,111 @@ BEGIN_JS_STATIC_CONST(CJS_Field)
END_JS_STATIC_CONST()
BEGIN_JS_STATIC_PROP(CJS_Field)
- JS_STATIC_PROP_ENTRY(alignment)
- JS_STATIC_PROP_ENTRY(borderStyle)
- JS_STATIC_PROP_ENTRY(buttonAlignX)
- JS_STATIC_PROP_ENTRY(buttonAlignY)
- JS_STATIC_PROP_ENTRY(buttonFitBounds)
- JS_STATIC_PROP_ENTRY(buttonPosition)
- JS_STATIC_PROP_ENTRY(buttonScaleHow)
- JS_STATIC_PROP_ENTRY(buttonScaleWhen)
- JS_STATIC_PROP_ENTRY(calcOrderIndex)
- JS_STATIC_PROP_ENTRY(charLimit)
- JS_STATIC_PROP_ENTRY(comb)
- JS_STATIC_PROP_ENTRY(commitOnSelChange)
- JS_STATIC_PROP_ENTRY(currentValueIndices)
- JS_STATIC_PROP_ENTRY(defaultStyle)
- JS_STATIC_PROP_ENTRY(defaultValue)
- JS_STATIC_PROP_ENTRY(doNotScroll)
- JS_STATIC_PROP_ENTRY(doNotSpellCheck)
- JS_STATIC_PROP_ENTRY(delay)
- JS_STATIC_PROP_ENTRY(display)
- JS_STATIC_PROP_ENTRY(doc)
- JS_STATIC_PROP_ENTRY(editable)
- JS_STATIC_PROP_ENTRY(exportValues)
- JS_STATIC_PROP_ENTRY(hidden)
- JS_STATIC_PROP_ENTRY(fileSelect)
- JS_STATIC_PROP_ENTRY(fillColor)
- JS_STATIC_PROP_ENTRY(lineWidth)
- JS_STATIC_PROP_ENTRY(highlight)
- JS_STATIC_PROP_ENTRY(multiline)
- JS_STATIC_PROP_ENTRY(multipleSelection)
- JS_STATIC_PROP_ENTRY(name)
- JS_STATIC_PROP_ENTRY(numItems)
- JS_STATIC_PROP_ENTRY(page)
- JS_STATIC_PROP_ENTRY(password)
- JS_STATIC_PROP_ENTRY(print)
- JS_STATIC_PROP_ENTRY(radiosInUnison)
- JS_STATIC_PROP_ENTRY(readonly)
- JS_STATIC_PROP_ENTRY(rect)
- JS_STATIC_PROP_ENTRY(required)
- JS_STATIC_PROP_ENTRY(richText)
- JS_STATIC_PROP_ENTRY(richValue)
- JS_STATIC_PROP_ENTRY(rotation)
- JS_STATIC_PROP_ENTRY(strokeColor)
- JS_STATIC_PROP_ENTRY(style)
- JS_STATIC_PROP_ENTRY(submitName)
- JS_STATIC_PROP_ENTRY(textColor)
- JS_STATIC_PROP_ENTRY(textFont)
- JS_STATIC_PROP_ENTRY(textSize)
- JS_STATIC_PROP_ENTRY(type)
- JS_STATIC_PROP_ENTRY(userName)
- JS_STATIC_PROP_ENTRY(value)
- JS_STATIC_PROP_ENTRY(valueAsString)
- JS_STATIC_PROP_ENTRY(source)
+ JS_STATIC_PROP_ENTRY(alignment)
+ JS_STATIC_PROP_ENTRY(borderStyle)
+ JS_STATIC_PROP_ENTRY(buttonAlignX)
+ JS_STATIC_PROP_ENTRY(buttonAlignY)
+ JS_STATIC_PROP_ENTRY(buttonFitBounds)
+ JS_STATIC_PROP_ENTRY(buttonPosition)
+ JS_STATIC_PROP_ENTRY(buttonScaleHow)
+ JS_STATIC_PROP_ENTRY(buttonScaleWhen)
+ JS_STATIC_PROP_ENTRY(calcOrderIndex)
+ JS_STATIC_PROP_ENTRY(charLimit)
+ JS_STATIC_PROP_ENTRY(comb)
+ JS_STATIC_PROP_ENTRY(commitOnSelChange)
+ JS_STATIC_PROP_ENTRY(currentValueIndices)
+ JS_STATIC_PROP_ENTRY(defaultStyle)
+ JS_STATIC_PROP_ENTRY(defaultValue)
+ JS_STATIC_PROP_ENTRY(doNotScroll)
+ JS_STATIC_PROP_ENTRY(doNotSpellCheck)
+ JS_STATIC_PROP_ENTRY(delay)
+ JS_STATIC_PROP_ENTRY(display)
+ JS_STATIC_PROP_ENTRY(doc)
+ JS_STATIC_PROP_ENTRY(editable)
+ JS_STATIC_PROP_ENTRY(exportValues)
+ JS_STATIC_PROP_ENTRY(hidden)
+ JS_STATIC_PROP_ENTRY(fileSelect)
+ JS_STATIC_PROP_ENTRY(fillColor)
+ JS_STATIC_PROP_ENTRY(lineWidth)
+ JS_STATIC_PROP_ENTRY(highlight)
+ JS_STATIC_PROP_ENTRY(multiline)
+ JS_STATIC_PROP_ENTRY(multipleSelection)
+ JS_STATIC_PROP_ENTRY(name)
+ JS_STATIC_PROP_ENTRY(numItems)
+ JS_STATIC_PROP_ENTRY(page)
+ JS_STATIC_PROP_ENTRY(password)
+ JS_STATIC_PROP_ENTRY(print)
+ JS_STATIC_PROP_ENTRY(radiosInUnison)
+ JS_STATIC_PROP_ENTRY(readonly)
+ JS_STATIC_PROP_ENTRY(rect)
+ JS_STATIC_PROP_ENTRY(required)
+ JS_STATIC_PROP_ENTRY(richText)
+ JS_STATIC_PROP_ENTRY(richValue)
+ JS_STATIC_PROP_ENTRY(rotation)
+ JS_STATIC_PROP_ENTRY(strokeColor)
+ JS_STATIC_PROP_ENTRY(style)
+ JS_STATIC_PROP_ENTRY(submitName)
+ JS_STATIC_PROP_ENTRY(textColor)
+ JS_STATIC_PROP_ENTRY(textFont)
+ JS_STATIC_PROP_ENTRY(textSize)
+ JS_STATIC_PROP_ENTRY(type)
+ JS_STATIC_PROP_ENTRY(userName)
+ JS_STATIC_PROP_ENTRY(value)
+ JS_STATIC_PROP_ENTRY(valueAsString)
+ JS_STATIC_PROP_ENTRY(source)
END_JS_STATIC_PROP()
BEGIN_JS_STATIC_METHOD(CJS_Field)
- JS_STATIC_METHOD_ENTRY(browseForFileToSubmit)
- JS_STATIC_METHOD_ENTRY(buttonGetCaption)
- JS_STATIC_METHOD_ENTRY(buttonGetIcon)
- JS_STATIC_METHOD_ENTRY(buttonImportIcon)
- JS_STATIC_METHOD_ENTRY(buttonSetCaption)
- JS_STATIC_METHOD_ENTRY(buttonSetIcon)
- JS_STATIC_METHOD_ENTRY(checkThisBox)
- JS_STATIC_METHOD_ENTRY(clearItems)
- JS_STATIC_METHOD_ENTRY(defaultIsChecked)
- JS_STATIC_METHOD_ENTRY(deleteItemAt)
- JS_STATIC_METHOD_ENTRY(getArray )
- JS_STATIC_METHOD_ENTRY(getItemAt)
- JS_STATIC_METHOD_ENTRY(getLock)
- JS_STATIC_METHOD_ENTRY(insertItemAt)
- JS_STATIC_METHOD_ENTRY(isBoxChecked)
- JS_STATIC_METHOD_ENTRY(isDefaultChecked)
- JS_STATIC_METHOD_ENTRY(setAction)
- JS_STATIC_METHOD_ENTRY(setFocus)
- JS_STATIC_METHOD_ENTRY(setItems)
- JS_STATIC_METHOD_ENTRY(setLock)
- JS_STATIC_METHOD_ENTRY(signatureGetModifications)
- JS_STATIC_METHOD_ENTRY(signatureGetSeedValue)
- JS_STATIC_METHOD_ENTRY(signatureInfo)
- JS_STATIC_METHOD_ENTRY(signatureSetSeedValue)
- JS_STATIC_METHOD_ENTRY(signatureSign)
- JS_STATIC_METHOD_ENTRY(signatureValidate)
+ JS_STATIC_METHOD_ENTRY(browseForFileToSubmit)
+ JS_STATIC_METHOD_ENTRY(buttonGetCaption)
+ JS_STATIC_METHOD_ENTRY(buttonGetIcon)
+ JS_STATIC_METHOD_ENTRY(buttonImportIcon)
+ JS_STATIC_METHOD_ENTRY(buttonSetCaption)
+ JS_STATIC_METHOD_ENTRY(buttonSetIcon)
+ JS_STATIC_METHOD_ENTRY(checkThisBox)
+ JS_STATIC_METHOD_ENTRY(clearItems)
+ JS_STATIC_METHOD_ENTRY(defaultIsChecked)
+ JS_STATIC_METHOD_ENTRY(deleteItemAt)
+ JS_STATIC_METHOD_ENTRY(getArray )
+ JS_STATIC_METHOD_ENTRY(getItemAt)
+ JS_STATIC_METHOD_ENTRY(getLock)
+ JS_STATIC_METHOD_ENTRY(insertItemAt)
+ JS_STATIC_METHOD_ENTRY(isBoxChecked)
+ JS_STATIC_METHOD_ENTRY(isDefaultChecked)
+ JS_STATIC_METHOD_ENTRY(setAction)
+ JS_STATIC_METHOD_ENTRY(setFocus)
+ JS_STATIC_METHOD_ENTRY(setItems)
+ JS_STATIC_METHOD_ENTRY(setLock)
+ JS_STATIC_METHOD_ENTRY(signatureGetModifications)
+ JS_STATIC_METHOD_ENTRY(signatureGetSeedValue)
+ JS_STATIC_METHOD_ENTRY(signatureInfo)
+ JS_STATIC_METHOD_ENTRY(signatureSetSeedValue)
+ JS_STATIC_METHOD_ENTRY(signatureSign)
+ JS_STATIC_METHOD_ENTRY(signatureValidate)
END_JS_STATIC_METHOD()
IMPLEMENT_JS_CLASS(CJS_Field, Field)
-FX_BOOL CJS_Field::InitInstance(IFXJS_Context* cc)
+FX_BOOL CJS_Field::InitInstance(IFXJS_Context* cc)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
- Field* pField = (Field*)GetEmbedObject();
- ASSERT(pField != NULL);
+ Field* pField = (Field*)GetEmbedObject();
+ ASSERT(pField != NULL);
- pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate());
+ pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate());
- return TRUE;
+ return TRUE;
};
Field::Field(CJS_Object* pJSObject): CJS_EmbedObj(pJSObject),
- m_pJSDoc(NULL),
- m_pDocument(NULL),
- m_nFormControlIndex(-1),
- m_bCanSet(FALSE),
- m_bDelay(FALSE),
- m_isolate(NULL)
+ m_pJSDoc(NULL),
+ m_pDocument(NULL),
+ m_nFormControlIndex(-1),
+ m_bCanSet(FALSE),
+ m_bDelay(FALSE),
+ m_isolate(NULL)
{
}
@@ -140,3319 +140,3320 @@ Field::~Field()
//note: iControlNo = -1, means not a widget.
void Field::ParseFieldName(const std::wstring &strFieldNameParsed,std::wstring &strFieldName,int & iControlNo)
{
- int iStart = strFieldNameParsed.find_last_of(L'.');
- if (iStart == -1)
- {
- strFieldName = strFieldNameParsed;
- iControlNo = -1;
- return;
- }
- std::wstring suffixal = strFieldNameParsed.substr(iStart+1);
- iControlNo = FXSYS_wtoi(suffixal.c_str());
- if (iControlNo == 0)
- {
- int iStart;
- while((iStart = suffixal.find_last_of(L" ")) != -1)
- {
- suffixal.erase(iStart,1);
- }
-
- if (suffixal.compare(L"0") != 0)
- {
- strFieldName = strFieldNameParsed;
- iControlNo = -1;
- return;
- }
-
- }
- strFieldName = strFieldNameParsed.substr(0,iStart);
+ int iStart = strFieldNameParsed.find_last_of(L'.');
+ if (iStart == -1)
+ {
+ strFieldName = strFieldNameParsed;
+ iControlNo = -1;
+ return;
+ }
+ std::wstring suffixal = strFieldNameParsed.substr(iStart+1);
+ iControlNo = FXSYS_wtoi(suffixal.c_str());
+ if (iControlNo == 0)
+ {
+ int iStart;
+ while((iStart = suffixal.find_last_of(L" ")) != -1)
+ {
+ suffixal.erase(iStart,1);
+ }
+
+ if (suffixal.compare(L"0") != 0)
+ {
+ strFieldName = strFieldNameParsed;
+ iControlNo = -1;
+ return;
+ }
+
+ }
+ strFieldName = strFieldNameParsed.substr(0,iStart);
}
FX_BOOL Field::AttachField(Document* pDocument, const CFX_WideString& csFieldName)
{
- ASSERT(pDocument != NULL);
- m_pJSDoc = pDocument;
+ ASSERT(pDocument != NULL);
+ m_pJSDoc = pDocument;
- m_pDocument = pDocument->GetReaderDoc();
- ASSERT(m_pDocument != NULL);
+ m_pDocument = pDocument->GetReaderDoc();
+ ASSERT(m_pDocument != NULL);
- m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) ||
- m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
- m_pDocument->GetPermissions(FPDFPERM_MODIFY);
+ m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) ||
+ m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pDocument->GetPermissions(FPDFPERM_MODIFY);
- CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm();
- ASSERT(pRDInterForm != NULL);
+ CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm();
+ ASSERT(pRDInterForm != NULL);
- CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CFX_WideString swFieldNameTemp = csFieldName;
- swFieldNameTemp.Replace(L"..", L".");
+ CFX_WideString swFieldNameTemp = csFieldName;
+ swFieldNameTemp.Replace(L"..", L".");
- if (pInterForm->CountFields(swFieldNameTemp) <= 0)
- {
- std::wstring strFieldName;
- int iControlNo = -1;
- ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo);
- if (iControlNo == -1) return FALSE;
+ if (pInterForm->CountFields(swFieldNameTemp) <= 0)
+ {
+ std::wstring strFieldName;
+ int iControlNo = -1;
+ ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo);
+ if (iControlNo == -1) return FALSE;
- m_FieldName = strFieldName.c_str();
- m_nFormControlIndex = iControlNo;
- return TRUE;
- }
+ m_FieldName = strFieldName.c_str();
+ m_nFormControlIndex = iControlNo;
+ return TRUE;
+ }
- m_FieldName = swFieldNameTemp;
- m_nFormControlIndex = -1;
+ m_FieldName = swFieldNameTemp;
+ m_nFormControlIndex = -1;
- return TRUE;
+ return TRUE;
}
void Field::GetFormFields(CPDFSDK_Document* pDocument, const CFX_WideString& csFieldName, CFX_PtrArray& FieldArray)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm();
- ASSERT(pReaderInterForm != NULL);
+ CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm();
+ ASSERT(pReaderInterForm != NULL);
- CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
+ ASSERT(pInterForm != NULL);
- ASSERT(FieldArray.GetSize() == 0);
+ ASSERT(FieldArray.GetSize() == 0);
- for (int i=0,sz=pInterForm->CountFields(csFieldName); i<sz; i++)
- {
- if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))
- FieldArray.Add((void*)pFormField);
- }
+ for (int i=0,sz=pInterForm->CountFields(csFieldName); i<sz; i++)
+ {
+ if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))
+ FieldArray.Add((void*)pFormField);
+ }
}
void Field::GetFormFields(const CFX_WideString& csFieldName, CFX_PtrArray& FieldArray)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- Field::GetFormFields(m_pDocument, csFieldName, FieldArray);
+ Field::GetFormFields(m_pDocument, csFieldName, FieldArray);
}
void Field::UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField,
- FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh)
-{
- ASSERT(pDocument != NULL);
- ASSERT(pFormField != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CFX_PtrArray widgets;
- pInterForm->GetWidgets(pFormField, widgets);
-
- if (bResetAP)
- {
- int nFieldType = pFormField->GetFieldType();
- if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD)
- {
- for (int i=0,sz=widgets.GetSize(); i<sz; i++)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);
- ASSERT(pWidget != NULL);
-
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = pWidget->OnFormat(bFormated);
- if (bFormated)
- pWidget->ResetAppearance(sValue.c_str(), FALSE);
- else
- pWidget->ResetAppearance(NULL, FALSE);
- }
- }
- else
- {
- for (int i=0,sz=widgets.GetSize(); i<sz; i++)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);
- ASSERT(pWidget != NULL);
-
- pWidget->ResetAppearance(NULL, FALSE);
- }
- }
- }
-
- if (bRefresh)
- {
- for (int i=0,sz=widgets.GetSize(); i<sz; i++)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);
- ASSERT(pWidget != NULL);
-
- CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm();
- CPDFSDK_Document* pDoc = pInterForm->GetDocument();
-// CReader_Page* pPage = pWidget->GetPage();
- ASSERT(pDoc != NULL);
- pDoc->UpdateAllViews(NULL, pWidget);
- }
- }
-
- if (bChangeMark)
- pDocument->SetChangeMark();
+ FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh)
+{
+ ASSERT(pDocument != NULL);
+ ASSERT(pFormField != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CFX_PtrArray widgets;
+ pInterForm->GetWidgets(pFormField, widgets);
+
+ if (bResetAP)
+ {
+ int nFieldType = pFormField->GetFieldType();
+ if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD)
+ {
+ for (int i=0,sz=widgets.GetSize(); i<sz; i++)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);
+ ASSERT(pWidget != NULL);
+
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = pWidget->OnFormat(bFormated);
+ if (bFormated)
+ pWidget->ResetAppearance(sValue.c_str(), FALSE);
+ else
+ pWidget->ResetAppearance(NULL, FALSE);
+ }
+ }
+ else
+ {
+ for (int i=0,sz=widgets.GetSize(); i<sz; i++)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);
+ ASSERT(pWidget != NULL);
+
+ pWidget->ResetAppearance(NULL, FALSE);
+ }
+ }
+ }
+
+ if (bRefresh)
+ {
+ for (int i=0,sz=widgets.GetSize(); i<sz; i++)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);
+ ASSERT(pWidget != NULL);
+
+ CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm();
+ CPDFSDK_Document* pDoc = pInterForm->GetDocument();
+// CReader_Page* pPage = pWidget->GetPage();
+ ASSERT(pDoc != NULL);
+ pDoc->UpdateAllViews(NULL, pWidget);
+ }
+ }
+
+ if (bChangeMark)
+ pDocument->SetChangeMark();
}
void Field::UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl,
- FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh)
-{
- ASSERT(pDocument != NULL);
- ASSERT(pFormControl != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
-
- if (pWidget)
- {
- if (bResetAP)
- {
- int nFieldType = pWidget->GetFieldType();
- if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD)
- {
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = pWidget->OnFormat(bFormated);
- if (bFormated)
- pWidget->ResetAppearance(sValue.c_str(), FALSE);
- else
- pWidget->ResetAppearance(NULL, FALSE);
- }
- else
- {
- pWidget->ResetAppearance(NULL, FALSE);
- }
- }
-
- if (bRefresh)
- {
- CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm();
- CPDFSDK_Document* pDoc = pInterForm->GetDocument();
- ASSERT(pDoc != NULL);
- pDoc->UpdateAllViews(NULL, pWidget);
- }
-
- }
-
- if (bChangeMark)
- pDocument->SetChangeMark();
+ FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh)
+{
+ ASSERT(pDocument != NULL);
+ ASSERT(pFormControl != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
+
+ if (pWidget)
+ {
+ if (bResetAP)
+ {
+ int nFieldType = pWidget->GetFieldType();
+ if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD)
+ {
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = pWidget->OnFormat(bFormated);
+ if (bFormated)
+ pWidget->ResetAppearance(sValue.c_str(), FALSE);
+ else
+ pWidget->ResetAppearance(NULL, FALSE);
+ }
+ else
+ {
+ pWidget->ResetAppearance(NULL, FALSE);
+ }
+ }
+
+ if (bRefresh)
+ {
+ CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm();
+ CPDFSDK_Document* pDoc = pInterForm->GetDocument();
+ ASSERT(pDoc != NULL);
+ pDoc->UpdateAllViews(NULL, pWidget);
+ }
+
+ }
+
+ if (bChangeMark)
+ pDocument->SetChangeMark();
}
CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl)
{
- ASSERT(pDocument != NULL);
- ASSERT(pFormControl != NULL);
+ ASSERT(pDocument != NULL);
+ ASSERT(pFormControl != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- return pInterForm->GetWidget(pFormControl);
+ return pInterForm->GetWidget(pFormControl);
}
FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel)
{
- ASSERT(pFormField != NULL);
+ ASSERT(pFormField != NULL);
- for (int i=0,sz = pFormField->CountOptions(); i < sz; i++)
- {
- if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
- return TRUE;
- }
+ for (int i=0,sz = pFormField->CountOptions(); i < sz; i++)
+ {
+ if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField)
{
- ASSERT(pFormField != NULL);
- if(!pFormField->CountControls() || m_nFormControlIndex>=pFormField->CountControls()) return NULL;
+ if (!pFormField->CountControls() || m_nFormControlIndex >= pFormField->CountControls())
+ return NULL;
- if (m_nFormControlIndex<0)
- return pFormField->GetControl(0);
- else
- return pFormField->GetControl(m_nFormControlIndex);
+ if (m_nFormControlIndex < 0)
+ return pFormField->GetControl(0);
+
+ return pFormField->GetControl(m_nFormControlIndex);
}
/* ---------------------------------------- property ---------------------------------------- */
FX_BOOL Field::alignment(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CFX_ByteString alignStr;
- vp >> alignStr;
-
- if (m_bDelay)
- {
- AddDelay_String(FP_ALIGNMENT, alignStr);
- }
- else
- {
- Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, alignStr);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
-
- switch (pFormControl->GetControlAlignment())
- {
- case 1:
- vp << L"center";
- break;
- case 0:
- vp << L"left";
- break;
- case 2:
- vp << L"right";
- break;
- default:
- vp << L"";
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CFX_ByteString alignStr;
+ vp >> alignStr;
+
+ if (m_bDelay)
+ {
+ AddDelay_String(FP_ALIGNMENT, alignStr);
+ }
+ else
+ {
+ Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, alignStr);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
+
+ switch (pFormControl->GetControlAlignment())
+ {
+ case 1:
+ vp << L"center";
+ break;
+ case 0:
+ vp << L"left";
+ break;
+ case 2:
+ vp << L"right";
+ break;
+ default:
+ vp << L"";
+ }
+ }
+
+ return TRUE;
}
void Field::SetAlignment(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex,
- const CFX_ByteString& string)
+ const CFX_ByteString& string)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::borderStyle(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CFX_ByteString strType = "";
- vp >> strType;
-
- if (m_bDelay)
- {
- AddDelay_String(FP_BORDERSTYLE, strType);
- }
- else
- {
- Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex, strType);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- if (!pFormField) return FALSE;
-
- CPDFSDK_Widget* pWidget = GetWidget(m_pDocument, GetSmartFieldControl(pFormField));
- if (!pWidget) return FALSE;
-
- int nBorderstyle = pWidget->GetBorderStyle();
-
- switch (nBorderstyle)
- {
- case BBS_SOLID:
- vp << L"solid";
- break;
- case BBS_DASH:
- vp << L"dashed";
- break;
- case BBS_BEVELED:
- vp << L"beveled";
- break;
- case BBS_INSET:
- vp << L"inset";
- break;
- case BBS_UNDERLINE:
- vp << L"underline";
- break;
- default:
- vp << L"";
- break;
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CFX_ByteString strType = "";
+ vp >> strType;
+
+ if (m_bDelay)
+ {
+ AddDelay_String(FP_BORDERSTYLE, strType);
+ }
+ else
+ {
+ Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex, strType);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ if (!pFormField) return FALSE;
+
+ CPDFSDK_Widget* pWidget = GetWidget(m_pDocument, GetSmartFieldControl(pFormField));
+ if (!pWidget) return FALSE;
+
+ int nBorderstyle = pWidget->GetBorderStyle();
+
+ switch (nBorderstyle)
+ {
+ case BBS_SOLID:
+ vp << L"solid";
+ break;
+ case BBS_DASH:
+ vp << L"dashed";
+ break;
+ case BBS_BEVELED:
+ vp << L"beveled";
+ break;
+ case BBS_INSET:
+ vp << L"inset";
+ break;
+ case BBS_UNDERLINE:
+ vp << L"underline";
+ break;
+ default:
+ vp << L"";
+ break;
+ }
+ }
+
+ return TRUE;
}
void Field::SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex,
- const CFX_ByteString& string)
-{
- ASSERT(pDocument != NULL);
-
- int nBorderStyle = 0;
-
- if (string == "solid")
- nBorderStyle = BBS_SOLID;
- else if (string == "beveled")
- nBorderStyle = BBS_BEVELED;
- else if (string == "dashed")
- nBorderStyle = BBS_DASH;
- else if (string == "inset")
- nBorderStyle = BBS_INSET;
- else if (string == "underline")
- nBorderStyle = BBS_UNDERLINE;
- else return;
-
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (nControlIndex < 0)
- {
- FX_BOOL bSet = FALSE;
- for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
- {
- if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormField->GetControl(j)))
- {
- if (pWidget->GetBorderStyle() != nBorderStyle)
- {
- pWidget->SetBorderStyle(nBorderStyle);
- bSet = TRUE;
- }
- }
- }
- if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
- }
- else
- {
- if(nControlIndex >= pFormField->CountControls()) return;
- if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
- {
- if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormControl))
- {
- if (pWidget->GetBorderStyle() != nBorderStyle)
- {
- pWidget->SetBorderStyle(nBorderStyle);
- UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
- }
- }
- }
- }
- }
+ const CFX_ByteString& string)
+{
+ ASSERT(pDocument != NULL);
+
+ int nBorderStyle = 0;
+
+ if (string == "solid")
+ nBorderStyle = BBS_SOLID;
+ else if (string == "beveled")
+ nBorderStyle = BBS_BEVELED;
+ else if (string == "dashed")
+ nBorderStyle = BBS_DASH;
+ else if (string == "inset")
+ nBorderStyle = BBS_INSET;
+ else if (string == "underline")
+ nBorderStyle = BBS_UNDERLINE;
+ else return;
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (nControlIndex < 0)
+ {
+ FX_BOOL bSet = FALSE;
+ for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
+ {
+ if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormField->GetControl(j)))
+ {
+ if (pWidget->GetBorderStyle() != nBorderStyle)
+ {
+ pWidget->SetBorderStyle(nBorderStyle);
+ bSet = TRUE;
+ }
+ }
+ }
+ if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
+ }
+ else
+ {
+ if(nControlIndex >= pFormField->CountControls()) return;
+ if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
+ {
+ if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormControl))
+ {
+ if (pWidget->GetBorderStyle() != nBorderStyle)
+ {
+ pWidget->SetBorderStyle(nBorderStyle);
+ UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
+ }
+ }
+ }
+ }
+ }
}
FX_BOOL Field::buttonAlignX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_BUTTONALIGNX, nVP);
- }
- else
- {
- Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_BUTTONALIGNX, nVP);
+ }
+ else
+ {
+ Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- CPDF_IconFit IconFit = pFormControl->GetIconFit();
+ CPDF_IconFit IconFit = pFormControl->GetIconFit();
- FX_FLOAT fLeft,fBottom;
- IconFit.GetIconPosition(fLeft,fBottom);
+ FX_FLOAT fLeft,fBottom;
+ IconFit.GetIconPosition(fLeft,fBottom);
- vp << (int32_t)fLeft;
- }
+ vp << (int32_t)fLeft;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetButtonAlignX(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::buttonAlignY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_BUTTONALIGNY, nVP);
- }
- else
- {
- Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_BUTTONALIGNY, nVP);
+ }
+ else
+ {
+ Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- CPDF_IconFit IconFit = pFormControl->GetIconFit();
+ CPDF_IconFit IconFit = pFormControl->GetIconFit();
- FX_FLOAT fLeft,fBottom;
- IconFit.GetIconPosition(fLeft,fBottom);
+ FX_FLOAT fLeft,fBottom;
+ IconFit.GetIconPosition(fLeft,fBottom);
- vp << (int32_t)fBottom;
- }
+ vp << (int32_t)fBottom;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetButtonAlignY(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::buttonFitBounds(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP);
- }
- else
- {
- Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP);
+ }
+ else
+ {
+ Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- CPDF_IconFit IconFit = pFormControl->GetIconFit();
- vp << IconFit.GetFittingBounds();
- }
+ CPDF_IconFit IconFit = pFormControl->GetIconFit();
+ vp << IconFit.GetFittingBounds();
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetButtonFitBounds(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::buttonPosition(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_BUTTONPOSITION, nVP);
- }
- else
- {
- Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_BUTTONPOSITION, nVP);
+ }
+ else
+ {
+ Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- vp << pFormControl->GetTextPosition();
- }
- return TRUE;
+ vp << pFormControl->GetTextPosition();
+ }
+ return TRUE;
}
void Field::SetButtonPosition(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::buttonScaleHow(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_BUTTONSCALEHOW, nVP);
- }
- else
- {
- Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_BUTTONSCALEHOW, nVP);
+ }
+ else
+ {
+ Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- CPDF_IconFit IconFit = pFormControl->GetIconFit();
- if (IconFit.IsProportionalScale())
- vp << (int32_t)0;
- else
- vp << (int32_t)1;
- }
+ CPDF_IconFit IconFit = pFormControl->GetIconFit();
+ if (IconFit.IsProportionalScale())
+ vp << (int32_t)0;
+ else
+ vp << (int32_t)1;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetButtonScaleHow(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::buttonScaleWhen(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- int nVP;
- vp >> nVP;
-
- if (m_bDelay)
- {
- AddDelay_Int(FP_BUTTONSCALEWHEN, nVP);
- }
- else
- {
- Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*) FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl) return FALSE;
-
- CPDF_IconFit IconFit = pFormControl->GetIconFit();
- int ScaleM = IconFit.GetScaleMethod();
- switch (ScaleM)
- {
- case CPDF_IconFit::Always :
- vp << (int32_t) CPDF_IconFit::Always;
- break;
- case CPDF_IconFit::Bigger :
- vp << (int32_t) CPDF_IconFit::Bigger;
- break;
- case CPDF_IconFit::Never :
- vp << (int32_t) CPDF_IconFit::Never;
- break;
- case CPDF_IconFit::Smaller :
- vp << (int32_t) CPDF_IconFit::Smaller;
- break;
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ int nVP;
+ vp >> nVP;
+
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_BUTTONSCALEWHEN, nVP);
+ }
+ else
+ {
+ Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*) FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl) return FALSE;
+
+ CPDF_IconFit IconFit = pFormControl->GetIconFit();
+ int ScaleM = IconFit.GetScaleMethod();
+ switch (ScaleM)
+ {
+ case CPDF_IconFit::Always :
+ vp << (int32_t) CPDF_IconFit::Always;
+ break;
+ case CPDF_IconFit::Bigger :
+ vp << (int32_t) CPDF_IconFit::Bigger;
+ break;
+ case CPDF_IconFit::Never :
+ vp << (int32_t) CPDF_IconFit::Never;
+ break;
+ case CPDF_IconFit::Smaller :
+ vp << (int32_t) CPDF_IconFit::Smaller;
+ break;
+ }
+ }
+
+ return TRUE;
}
void Field::SetButtonScaleWhen(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::calcOrderIndex(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_CALCORDERINDEX, nVP);
- }
- else
- {
- Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_CALCORDERINDEX, nVP);
+ }
+ else
+ {
+ Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm();
- ASSERT(pRDInterForm != NULL);
+ CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm();
+ ASSERT(pRDInterForm != NULL);
- CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
+ ASSERT(pInterForm != NULL);
- vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField);
- }
+ vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField);
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::charLimit(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_CHARLIMIT, nVP);
- }
- else
- {
- Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_CHARLIMIT, nVP);
+ }
+ else
+ {
+ Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- vp << (int32_t)pFormField->GetMaxLen();
- }
- return TRUE;
+ vp << (int32_t)pFormField->GetMaxLen();
+ }
+ return TRUE;
}
void Field::SetCharLimit(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::comb(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_COMB, bVP);
- }
- else
- {
- Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_COMB, bVP);
+ }
+ else
+ {
+ Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_COMB)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_COMB)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetComb(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::commitOnSelChange(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_COMMITONSELCHANGE, bVP);
- }
- else
- {
- Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_COMMITONSELCHANGE, bVP);
+ }
+ else
+ {
+ Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::currentValueIndices(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CFX_DWordArray array;
-
- if (vp.GetType() == VT_number)
- {
- int iSelecting = 0;
- vp >> iSelecting;
- array.Add(iSelecting);
- }
- else if (vp.IsArrayObject())
- {
- CJS_Array SelArray(m_isolate);
- CJS_Value SelValue(m_isolate);
- int iSelecting;
- vp >> SelArray;
- for (int i=0,sz=SelArray.GetLength(); i<sz; i++)
- {
- SelArray.GetElement(i,SelValue);
- iSelecting = SelValue.ToInt();
- array.Add(iSelecting);
- }
- }
-
- if (m_bDelay)
- {
- AddDelay_WordArray(FP_CURRENTVALUEINDICES, array);
- }
- else
- {
- Field::SetCurrentValueIndices(m_pDocument, m_FieldName, m_nFormControlIndex, array);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
- return FALSE;
-
- if (pFormField->CountSelectedItems() == 1)
- vp << pFormField->GetSelectedIndex(0);
- else if (pFormField->CountSelectedItems() > 1)
- {
- CJS_Array SelArray(m_isolate);
- for (int i=0,sz=pFormField->CountSelectedItems(); i<sz; i++)
- {
- SelArray.SetElement(i, CJS_Value(m_isolate,pFormField->GetSelectedIndex(i)));
- }
- vp << SelArray;
- }
- else
- vp << -1;
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CFX_DWordArray array;
+
+ if (vp.GetType() == VT_number)
+ {
+ int iSelecting = 0;
+ vp >> iSelecting;
+ array.Add(iSelecting);
+ }
+ else if (vp.IsArrayObject())
+ {
+ CJS_Array SelArray(m_isolate);
+ CJS_Value SelValue(m_isolate);
+ int iSelecting;
+ vp >> SelArray;
+ for (int i=0,sz=SelArray.GetLength(); i<sz; i++)
+ {
+ SelArray.GetElement(i,SelValue);
+ iSelecting = SelValue.ToInt();
+ array.Add(iSelecting);
+ }
+ }
+
+ if (m_bDelay)
+ {
+ AddDelay_WordArray(FP_CURRENTVALUEINDICES, array);
+ }
+ else
+ {
+ Field::SetCurrentValueIndices(m_pDocument, m_FieldName, m_nFormControlIndex, array);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+ return FALSE;
+
+ if (pFormField->CountSelectedItems() == 1)
+ vp << pFormField->GetSelectedIndex(0);
+ else if (pFormField->CountSelectedItems() > 1)
+ {
+ CJS_Array SelArray(m_isolate);
+ for (int i=0,sz=pFormField->CountSelectedItems(); i<sz; i++)
+ {
+ SelArray.SetElement(i, CJS_Value(m_isolate,pFormField->GetSelectedIndex(i)));
+ }
+ vp << SelArray;
+ }
+ else
+ vp << -1;
+ }
+
+ return TRUE;
}
void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex,
- const CFX_DWordArray& array)
+ const CFX_DWordArray& array)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
- int nFieldType = pFormField->GetFieldType();
- if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX)
- {
- FX_DWORD dwFieldFlags = pFormField->GetFieldFlags();
- pFormField->ClearSelection(TRUE);
+ int nFieldType = pFormField->GetFieldType();
+ if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX)
+ {
+ FX_DWORD dwFieldFlags = pFormField->GetFieldFlags();
+ pFormField->ClearSelection(TRUE);
- for (int i=0,sz=array.GetSize(); i<sz; i++)
- {
- if (i>0 && !(dwFieldFlags & (1<<21)))
- {
- break;
- }
+ for (int i=0,sz=array.GetSize(); i<sz; i++)
+ {
+ if (i>0 && !(dwFieldFlags & (1<<21)))
+ {
+ break;
+ }
- int iSelecting = (int32_t)array.GetAt(i);
- if (iSelecting < pFormField->CountOptions() && !pFormField->IsItemSelected(iSelecting))
- pFormField->SetItemSelection(iSelecting, TRUE);
+ int iSelecting = (int32_t)array.GetAt(i);
+ if (iSelecting < pFormField->CountOptions() && !pFormField->IsItemSelected(iSelecting))
+ pFormField->SetItemSelection(iSelecting, TRUE);
- }
- UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
- }
- }
+ }
+ UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
+ }
+ }
}
FX_BOOL Field::defaultStyle(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- // MQG sError = JSGetStringFromID(IDS_STRING_NOTSUPPORT);
- return FALSE;
+ // MQG sError = JSGetStringFromID(IDS_STRING_NOTSUPPORT);
+ return FALSE;
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- ;
- }
- else
- {
- ;
- }
- return TRUE;
+ ;
+ }
+ else
+ {
+ ;
+ }
+ return TRUE;
}
void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::defaultValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- CFX_WideString WideStr;
- vp >> WideStr;
+ CFX_WideString WideStr;
+ vp >> WideStr;
- if (m_bDelay)
- {
- AddDelay_WideString(FP_DEFAULTVALUE, WideStr);
- }
- else
- {
- Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex, WideStr);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_WideString(FP_DEFAULTVALUE, WideStr);
+ }
+ else
+ {
+ Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex, WideStr);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON ||
- pFormField->GetFieldType() == FIELDTYPE_SIGNATURE)
- return FALSE;
+ if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON ||
+ pFormField->GetFieldType() == FIELDTYPE_SIGNATURE)
+ return FALSE;
- vp << pFormField->GetDefaultValue();
- }
- return TRUE;
+ vp << pFormField->GetDefaultValue();
+ }
+ return TRUE;
}
void Field::SetDefaultValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex,
- const CFX_WideString& string)
+ const CFX_WideString& string)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::doNotScroll(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_DONOTSCROLL, bVP);
- }
- else
- {
- Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_DONOTSCROLL, bVP);
+ }
+ else
+ {
+ Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetDoNotScroll(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::doNotSpellCheck(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ bool bVP;
+ vp >> bVP;
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD &&
- pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD &&
+ pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetDelay(FX_BOOL bDelay)
{
- m_bDelay = bDelay;
+ m_bDelay = bDelay;
- if (!m_bDelay)
- {
- if (m_pJSDoc)
- m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);
- }
+ if (!m_bDelay)
+ {
+ if (m_pJSDoc)
+ m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);
+ }
}
FX_BOOL Field::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- SetDelay(bVP);
- }
- else
- {
- vp << m_bDelay;
- }
- return TRUE;
+ SetDelay(bVP);
+ }
+ else
+ {
+ vp << m_bDelay;
+ }
+ return TRUE;
}
FX_BOOL Field::display(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- int nVP;
- vp >> nVP;
-
- if (m_bDelay)
- {
- AddDelay_Int(FP_DISPLAY, nVP);
- }
- else
- {
- Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
- if (!pWidget)return FALSE;
-
- FX_DWORD dwFlag = pWidget->GetFlags();
-
- if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag)
- {
- vp << (int32_t)1;
- }
- else
- {
- if (ANNOTFLAG_PRINT & dwFlag)
- {
- if (ANNOTFLAG_NOVIEW & dwFlag)
- {
- vp << (int32_t)3;
- }
- else
- {
- vp << (int32_t)0;
- }
- }
- else
- {
- vp << (int32_t)2;
- }
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ int nVP;
+ vp >> nVP;
+
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_DISPLAY, nVP);
+ }
+ else
+ {
+ Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+ if (!pWidget)return FALSE;
+
+ FX_DWORD dwFlag = pWidget->GetFlags();
+
+ if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag)
+ {
+ vp << (int32_t)1;
+ }
+ else
+ {
+ if (ANNOTFLAG_PRINT & dwFlag)
+ {
+ if (ANNOTFLAG_NOVIEW & dwFlag)
+ {
+ vp << (int32_t)3;
+ }
+ else
+ {
+ vp << (int32_t)0;
+ }
+ }
+ else
+ {
+ vp << (int32_t)2;
+ }
+ }
+ }
+
+ return TRUE;
}
void Field::SetDisplay(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- ASSERT(pDocument != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (nControlIndex < 0)
- {
- FX_BOOL bSet = FALSE;
- for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
- {
- CPDF_FormControl* pFormControl = pFormField->GetControl(j);
- ASSERT(pFormControl != NULL);
-
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- FX_DWORD dwFlag = pWidget->GetFlags();
- switch (number)
- {
- case 0:
- dwFlag &= (~ANNOTFLAG_INVISIBLE);
- dwFlag &= (~ANNOTFLAG_HIDDEN);
- dwFlag &= (~ANNOTFLAG_NOVIEW);
- dwFlag |= ANNOTFLAG_PRINT;
- break;
- case 1:
- dwFlag &= (~ANNOTFLAG_INVISIBLE);
- dwFlag &= (~ANNOTFLAG_NOVIEW);
- dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
- break;
- case 2:
- dwFlag &= (~ANNOTFLAG_INVISIBLE);
- dwFlag &= (~ANNOTFLAG_PRINT);
- dwFlag &= (~ANNOTFLAG_HIDDEN);
- dwFlag &= (~ANNOTFLAG_NOVIEW);
- break;
- case 3:
- dwFlag |= ANNOTFLAG_NOVIEW;
- dwFlag |= ANNOTFLAG_PRINT;
- dwFlag &= (~ANNOTFLAG_HIDDEN);
- break;
- }
-
- if (dwFlag != pWidget->GetFlags())
- {
- pWidget->SetFlags(dwFlag);
- bSet = TRUE;
- }
- }
- }
-
- if (bSet) UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
- }
- else
- {
- if(nControlIndex >= pFormField->CountControls()) return;
- if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
-
- FX_DWORD dwFlag = pWidget->GetFlags();
- switch (number)
- {
- case 0:
- dwFlag &= (~ANNOTFLAG_INVISIBLE);
- dwFlag &= (~ANNOTFLAG_HIDDEN);
- dwFlag &= (~ANNOTFLAG_NOVIEW);
- dwFlag |= ANNOTFLAG_PRINT;
- break;
- case 1:
- dwFlag &= (~ANNOTFLAG_INVISIBLE);
- dwFlag &= (~ANNOTFLAG_NOVIEW);
- dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
- break;
- case 2:
- dwFlag &= (~ANNOTFLAG_INVISIBLE);
- dwFlag &= (~ANNOTFLAG_PRINT);
- dwFlag &= (~ANNOTFLAG_HIDDEN);
- dwFlag &= (~ANNOTFLAG_NOVIEW);
- break;
- case 3:
- dwFlag |= ANNOTFLAG_NOVIEW;
- dwFlag |= ANNOTFLAG_PRINT;
- dwFlag &= (~ANNOTFLAG_HIDDEN);
- break;
- }
- if (dwFlag != pWidget->GetFlags())
- {
- pWidget->SetFlags(dwFlag);
- UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);
- }
- }
- }
- }
- }
+ ASSERT(pDocument != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (nControlIndex < 0)
+ {
+ FX_BOOL bSet = FALSE;
+ for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
+ {
+ CPDF_FormControl* pFormControl = pFormField->GetControl(j);
+ ASSERT(pFormControl != NULL);
+
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ FX_DWORD dwFlag = pWidget->GetFlags();
+ switch (number)
+ {
+ case 0:
+ dwFlag &= (~ANNOTFLAG_INVISIBLE);
+ dwFlag &= (~ANNOTFLAG_HIDDEN);
+ dwFlag &= (~ANNOTFLAG_NOVIEW);
+ dwFlag |= ANNOTFLAG_PRINT;
+ break;
+ case 1:
+ dwFlag &= (~ANNOTFLAG_INVISIBLE);
+ dwFlag &= (~ANNOTFLAG_NOVIEW);
+ dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
+ break;
+ case 2:
+ dwFlag &= (~ANNOTFLAG_INVISIBLE);
+ dwFlag &= (~ANNOTFLAG_PRINT);
+ dwFlag &= (~ANNOTFLAG_HIDDEN);
+ dwFlag &= (~ANNOTFLAG_NOVIEW);
+ break;
+ case 3:
+ dwFlag |= ANNOTFLAG_NOVIEW;
+ dwFlag |= ANNOTFLAG_PRINT;
+ dwFlag &= (~ANNOTFLAG_HIDDEN);
+ break;
+ }
+
+ if (dwFlag != pWidget->GetFlags())
+ {
+ pWidget->SetFlags(dwFlag);
+ bSet = TRUE;
+ }
+ }
+ }
+
+ if (bSet) UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
+ }
+ else
+ {
+ if(nControlIndex >= pFormField->CountControls()) return;
+ if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+
+ FX_DWORD dwFlag = pWidget->GetFlags();
+ switch (number)
+ {
+ case 0:
+ dwFlag &= (~ANNOTFLAG_INVISIBLE);
+ dwFlag &= (~ANNOTFLAG_HIDDEN);
+ dwFlag &= (~ANNOTFLAG_NOVIEW);
+ dwFlag |= ANNOTFLAG_PRINT;
+ break;
+ case 1:
+ dwFlag &= (~ANNOTFLAG_INVISIBLE);
+ dwFlag &= (~ANNOTFLAG_NOVIEW);
+ dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
+ break;
+ case 2:
+ dwFlag &= (~ANNOTFLAG_INVISIBLE);
+ dwFlag &= (~ANNOTFLAG_PRINT);
+ dwFlag &= (~ANNOTFLAG_HIDDEN);
+ dwFlag &= (~ANNOTFLAG_NOVIEW);
+ break;
+ case 3:
+ dwFlag |= ANNOTFLAG_NOVIEW;
+ dwFlag |= ANNOTFLAG_PRINT;
+ dwFlag &= (~ANNOTFLAG_HIDDEN);
+ break;
+ }
+ if (dwFlag != pWidget->GetFlags())
+ {
+ pWidget->SetFlags(dwFlag);
+ UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);
+ }
+ }
+ }
+ }
+ }
}
FX_BOOL Field::doc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (!vp.IsGetting()) {
- return FALSE;
- }
- vp << m_pJSDoc->GetCJSDoc();
- return TRUE;
+ if (!vp.IsGetting()) {
+ return FALSE;
+ }
+ vp << m_pJSDoc->GetCJSDoc();
+ return TRUE;
}
FX_BOOL Field::editable(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ ASSERT(m_pDocument != NULL);
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ bool bVP;
+ vp >> bVP;
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::exportValues(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
- pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
- return FALSE;
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
- if (!vp.IsArrayObject())return FALSE;
- }
- else
- {
- CJS_Array ExportValusArray(m_isolate);
-
- if (m_nFormControlIndex < 0)
- {
- for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
- {
- CPDF_FormControl* pFormControl = pFormField->GetControl(i);
- ASSERT(pFormControl != NULL);
-
- ExportValusArray.SetElement(i, CJS_Value(m_isolate,pFormControl->GetExportValue().c_str()));
- }
- }
- else
- {
- if(m_nFormControlIndex >= pFormField->CountControls()) return FALSE;
- CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex);
- if (!pFormControl) return FALSE;
-
- ExportValusArray.SetElement(0, CJS_Value(m_isolate,pFormControl->GetExportValue().c_str()));
- }
-
- vp << ExportValusArray;
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0)
+ return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
+ pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
+ return FALSE;
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet)
+ return FALSE;
+
+ if (!vp.IsArrayObject())
+ return FALSE;
+ }
+ else
+ {
+ CJS_Array ExportValusArray(m_isolate);
+ if (m_nFormControlIndex < 0)
+ {
+ for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
+ {
+ CPDF_FormControl* pFormControl = pFormField->GetControl(i);
+ ExportValusArray.SetElement(i, CJS_Value(m_isolate,pFormControl->GetExportValue().c_str()));
+ }
+ }
+ else
+ {
+ if (m_nFormControlIndex >= pFormField->CountControls())
+ return FALSE;
+
+ CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex);
+ if (!pFormControl)
+ return FALSE;
+
+ ExportValusArray.SetElement(0, CJS_Value(m_isolate,pFormControl->GetExportValue().c_str()));
+ }
+ vp << ExportValusArray;
+ }
+ return TRUE;
}
FX_BOOL Field::fileSelect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0)
+ return FALSE;
- bool bVP;
- vp >> bVP;
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- }
- else
- {
- if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)
- vp << true;
- else
- vp << false;
- }
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet)
+ return FALSE;
- return TRUE;
+ bool bVP;
+ vp >> bVP;
+ }
+ else
+ {
+ if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)
+ vp << true;
+ else
+ vp << false;
+ }
+ return TRUE;
}
FX_BOOL Field::fillColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CJS_Array crArray(m_isolate);
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
- if (!vp.IsArrayObject()) return FALSE;
-
- vp >> crArray;
-
- CPWL_Color color;
- color::ConvertArrayToPWLColor(crArray, color);
-
- if (m_bDelay)
- {
- AddDelay_Color(FP_FILLCOLOR, color);
- }
- else
- {
- Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
- }
- }
- else
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
-
- int iColorType;
- pFormControl->GetBackgroundColor(iColorType);
-
- CPWL_Color color;
-
- if (iColorType == COLORTYPE_TRANSPARENT)
- {
- color = CPWL_Color(COLORTYPE_TRANSPARENT);
- }
- else if (iColorType == COLORTYPE_GRAY)
- {
- color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBackgroundColor(0));
- }
- else if (iColorType == COLORTYPE_RGB)
- {
- color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),
- pFormControl->GetOriginalBackgroundColor(1),
- pFormControl->GetOriginalBackgroundColor(2));
- }
- else if (iColorType == COLORTYPE_CMYK)
- {
- color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBackgroundColor(0),
- pFormControl->GetOriginalBackgroundColor(1),
- pFormControl->GetOriginalBackgroundColor(2),
- pFormControl->GetOriginalBackgroundColor(3));
- }
- else
- return FALSE;
-
- color::ConvertPWLColorToArray(color, crArray);
+ ASSERT(m_pDocument != NULL);
+
+ CJS_Array crArray(m_isolate);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0)
+ return FALSE;
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet)
+ return FALSE;
+
+ if (!vp.IsArrayObject())
+ return FALSE;
+
+ vp >> crArray;
+
+ CPWL_Color color;
+ color::ConvertArrayToPWLColor(crArray, color);
+ if (m_bDelay)
+ {
+ AddDelay_Color(FP_FILLCOLOR, color);
+ }
+ else
+ {
+ Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
+ }
+ }
+ else
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)
+ return FALSE;
+
+ int iColorType;
+ pFormControl->GetBackgroundColor(iColorType);
+
+ CPWL_Color color;
+ if (iColorType == COLORTYPE_TRANSPARENT)
+ {
+ color = CPWL_Color(COLORTYPE_TRANSPARENT);
+ }
+ else if (iColorType == COLORTYPE_GRAY)
+ {
+ color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBackgroundColor(0));
+ }
+ else if (iColorType == COLORTYPE_RGB)
+ {
+ color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),
+ pFormControl->GetOriginalBackgroundColor(1),
+ pFormControl->GetOriginalBackgroundColor(2));
+ }
+ else if (iColorType == COLORTYPE_CMYK)
+ {
+ color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBackgroundColor(0),
+ pFormControl->GetOriginalBackgroundColor(1),
+ pFormControl->GetOriginalBackgroundColor(2),
+ pFormControl->GetOriginalBackgroundColor(3));
+ }
+ else
+ return FALSE;
+
+ color::ConvertPWLColorToArray(color, crArray);
vp << crArray;
- }
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetFillColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::hidden(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_HIDDEN, bVP);
- }
- else
- {
- Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_HIDDEN, bVP);
+ }
+ else
+ {
+ Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
- if (!pWidget) return FALSE;
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+ if (!pWidget) return FALSE;
- FX_DWORD dwFlags = pWidget->GetFlags();
+ FX_DWORD dwFlags = pWidget->GetFlags();
- if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
- {
- vp << true;
- }
- else
- vp << false;
- }
+ if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
+ {
+ vp << true;
+ }
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetHidden(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- ASSERT(pDocument != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (nControlIndex < 0)
- {
- FX_BOOL bSet = FALSE;
- for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(j)))
- {
- FX_DWORD dwFlags = pWidget->GetFlags();
-
- if (b)
- {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
- }
- else
- {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_HIDDEN);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= ANNOTFLAG_PRINT;
- }
-
- if (dwFlags != pWidget->GetFlags())
- {
- pWidget->SetFlags(dwFlags);
- bSet = TRUE;
- }
- }
- }
-
- if (bSet)
- UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
- }
- else
- {
- if(nControlIndex >= pFormField->CountControls()) return;
- if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- FX_DWORD dwFlags = pWidget->GetFlags();
-
- if (b)
- {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
- }
- else
- {
- dwFlags &= (~ANNOTFLAG_INVISIBLE);
- dwFlags &= (~ANNOTFLAG_HIDDEN);
- dwFlags &= (~ANNOTFLAG_NOVIEW);
- dwFlags |= ANNOTFLAG_PRINT;
- }
-
- if (dwFlags != pWidget->GetFlags())
- {
- pWidget->SetFlags(dwFlags);
- UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);
- }
- }
- }
- }
- }
+ ASSERT(pDocument != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (nControlIndex < 0)
+ {
+ FX_BOOL bSet = FALSE;
+ for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(j)))
+ {
+ FX_DWORD dwFlags = pWidget->GetFlags();
+
+ if (b)
+ {
+ dwFlags &= (~ANNOTFLAG_INVISIBLE);
+ dwFlags &= (~ANNOTFLAG_NOVIEW);
+ dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
+ }
+ else
+ {
+ dwFlags &= (~ANNOTFLAG_INVISIBLE);
+ dwFlags &= (~ANNOTFLAG_HIDDEN);
+ dwFlags &= (~ANNOTFLAG_NOVIEW);
+ dwFlags |= ANNOTFLAG_PRINT;
+ }
+
+ if (dwFlags != pWidget->GetFlags())
+ {
+ pWidget->SetFlags(dwFlags);
+ bSet = TRUE;
+ }
+ }
+ }
+
+ if (bSet)
+ UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
+ }
+ else
+ {
+ if(nControlIndex >= pFormField->CountControls()) return;
+ if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ FX_DWORD dwFlags = pWidget->GetFlags();
+
+ if (b)
+ {
+ dwFlags &= (~ANNOTFLAG_INVISIBLE);
+ dwFlags &= (~ANNOTFLAG_NOVIEW);
+ dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);
+ }
+ else
+ {
+ dwFlags &= (~ANNOTFLAG_INVISIBLE);
+ dwFlags &= (~ANNOTFLAG_HIDDEN);
+ dwFlags &= (~ANNOTFLAG_NOVIEW);
+ dwFlags |= ANNOTFLAG_PRINT;
+ }
+
+ if (dwFlags != pWidget->GetFlags())
+ {
+ pWidget->SetFlags(dwFlags);
+ UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);
+ }
+ }
+ }
+ }
+ }
}
FX_BOOL Field::highlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CFX_ByteString strMode;
- vp >> strMode;
-
- if (m_bDelay)
- {
- AddDelay_String(FP_HIGHLIGHT, strMode);
- }
- else
- {
- Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, strMode);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl) return FALSE;
-
- int eHM = pFormControl->GetHighlightingMode();
- switch (eHM)
- {
- case CPDF_FormControl::None:
- vp << L"none";
- break;
- case CPDF_FormControl::Push:
- vp << L"push";
- break;
- case CPDF_FormControl::Invert:
- vp << L"invert";
- break;
- case CPDF_FormControl::Outline:
- vp << L"outline";
- break;
- case CPDF_FormControl::Toggle:
- vp << L"toggle";
- break;
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CFX_ByteString strMode;
+ vp >> strMode;
+
+ if (m_bDelay)
+ {
+ AddDelay_String(FP_HIGHLIGHT, strMode);
+ }
+ else
+ {
+ Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, strMode);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl) return FALSE;
+
+ int eHM = pFormControl->GetHighlightingMode();
+ switch (eHM)
+ {
+ case CPDF_FormControl::None:
+ vp << L"none";
+ break;
+ case CPDF_FormControl::Push:
+ vp << L"push";
+ break;
+ case CPDF_FormControl::Invert:
+ vp << L"invert";
+ break;
+ case CPDF_FormControl::Outline:
+ vp << L"outline";
+ break;
+ case CPDF_FormControl::Toggle:
+ vp << L"toggle";
+ break;
+ }
+ }
+
+ return TRUE;
}
void Field::SetHighlight(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::lineWidth(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int iWidth;
- vp >> iWidth;
+ int iWidth;
+ vp >> iWidth;
- if (m_bDelay)
- {
- AddDelay_Int(FP_LINEWIDTH, iWidth);
- }
- else
- {
- Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, iWidth);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_LINEWIDTH, iWidth);
+ }
+ else
+ {
+ Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, iWidth);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl) return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl) return FALSE;
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- if(!pFormField->CountControls()) return FALSE;
+ if(!pFormField->CountControls()) return FALSE;
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
- if (!pWidget) return FALSE;
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
+ if (!pWidget) return FALSE;
- vp << (int32_t)pWidget->GetBorderWidth();
- }
+ vp << (int32_t)pWidget->GetBorderWidth();
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetLineWidth(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- ASSERT(pDocument != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (nControlIndex < 0)
- {
- FX_BOOL bSet = FALSE;
- for (int j=0,jsz=pFormField->CountControls(); j<jsz; j++)
- {
- CPDF_FormControl* pFormControl = pFormField->GetControl(j);
- ASSERT(pFormControl != NULL);
-
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- if (number != pWidget->GetBorderWidth())
- {
- pWidget->SetBorderWidth(number);
- bSet = TRUE;
- }
- }
- }
- if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
- }
- else
- {
- if(nControlIndex >= pFormField->CountControls()) return;
- if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- if (number != pWidget->GetBorderWidth())
- {
- pWidget->SetBorderWidth(number);
- UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
- }
- }
- }
- }
- }
+ ASSERT(pDocument != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (nControlIndex < 0)
+ {
+ FX_BOOL bSet = FALSE;
+ for (int j=0,jsz=pFormField->CountControls(); j<jsz; j++)
+ {
+ CPDF_FormControl* pFormControl = pFormField->GetControl(j);
+ ASSERT(pFormControl != NULL);
+
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ if (number != pWidget->GetBorderWidth())
+ {
+ pWidget->SetBorderWidth(number);
+ bSet = TRUE;
+ }
+ }
+ }
+ if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
+ }
+ else
+ {
+ if(nControlIndex >= pFormField->CountControls()) return;
+ if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ if (number != pWidget->GetBorderWidth())
+ {
+ pWidget->SetBorderWidth(number);
+ UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
+ }
+ }
+ }
+ }
+ }
}
FX_BOOL Field::multiline(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_MULTILINE, bVP);
- }
- else
- {
- Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_MULTILINE, bVP);
+ }
+ else
+ {
+ Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetMultiline(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::multipleSelection(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_MULTIPLESELECTION, bVP);
- }
- else
- {
- Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_MULTIPLESELECTION, bVP);
+ }
+ else
+ {
+ Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (!vp.IsGetting()) return FALSE;
+ if (!vp.IsGetting()) return FALSE;
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- vp << m_FieldName;
+ vp << m_FieldName;
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::numItems(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
- pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
+ pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+ return FALSE;
- if (!vp.IsGetting()) return FALSE;
+ if (!vp.IsGetting()) return FALSE;
- vp << (int32_t)pFormField->CountOptions();
+ vp << (int32_t)pFormField->CountOptions();
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::page(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (!vp.IsGetting()) return FALSE;
+ if (!vp.IsGetting()) return FALSE;
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- if (!pFormField) return FALSE;
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ if (!pFormField) return FALSE;
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CFX_PtrArray widgetArray;
- pInterForm->GetWidgets(pFormField, widgetArray);
+ CFX_PtrArray widgetArray;
+ pInterForm->GetWidgets(pFormField, widgetArray);
- if (widgetArray.GetSize() > 0)
- {
- CJS_Array PageArray(m_isolate);
+ if (widgetArray.GetSize() > 0)
+ {
+ CJS_Array PageArray(m_isolate);
- for (int i=0,sz=widgetArray.GetSize(); i<sz; i++)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i);
- ASSERT(pWidget != NULL);
+ for (int i=0,sz=widgetArray.GetSize(); i<sz; i++)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i);
+ ASSERT(pWidget != NULL);
- CPDFSDK_PageView* pPageView = pWidget->GetPageView();
- if(!pPageView)
- return FALSE;
+ CPDFSDK_PageView* pPageView = pWidget->GetPageView();
+ if(!pPageView)
+ return FALSE;
- PageArray.SetElement(i, CJS_Value(m_isolate,(int32_t)pPageView->GetPageIndex()));
- }
+ PageArray.SetElement(i, CJS_Value(m_isolate,(int32_t)pPageView->GetPageIndex()));
+ }
- vp << PageArray;
- }
- else
- {
- vp << (int32_t) -1;
- }
+ vp << PageArray;
+ }
+ else
+ {
+ vp << (int32_t) -1;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::password(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_PASSWORD, bVP);
- }
- else
- {
- Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_PASSWORD, bVP);
+ }
+ else
+ {
+ Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetPassword(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::print(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- bool bVP;
- vp >> bVP;
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (m_nFormControlIndex < 0)
- {
- FX_BOOL bSet = FALSE;
- for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(j)))
- {
- FX_DWORD dwFlags = pWidget->GetFlags();
- if (bVP)
- dwFlags |= ANNOTFLAG_PRINT;
- else
- dwFlags &= ~ANNOTFLAG_PRINT;
-
- if (dwFlags != pWidget->GetFlags())
- {
- pWidget->SetFlags(dwFlags);
- bSet = TRUE;
- }
- }
- }
-
- if (bSet)
- UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE);
- }
- else
- {
- if(m_nFormControlIndex >= pFormField->CountControls()) return FALSE;
- if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex))
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- FX_DWORD dwFlags = pWidget->GetFlags();
- if (bVP)
- dwFlags |= ANNOTFLAG_PRINT;
- else
- dwFlags &= ~ANNOTFLAG_PRINT;
-
- if (dwFlags != pWidget->GetFlags())
- {
- pWidget->SetFlags(dwFlags);
- UpdateFormControl(m_pDocument, pFormField->GetControl(m_nFormControlIndex), TRUE, FALSE, TRUE);
- }
- }
- }
- }
- }
- }
- else
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
- if (!pWidget) return FALSE;
-
- if (pWidget->GetFlags() & ANNOTFLAG_PRINT)
- vp << true;
- else
- vp << false;
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ bool bVP;
+ vp >> bVP;
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (m_nFormControlIndex < 0)
+ {
+ FX_BOOL bSet = FALSE;
+ for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(j)))
+ {
+ FX_DWORD dwFlags = pWidget->GetFlags();
+ if (bVP)
+ dwFlags |= ANNOTFLAG_PRINT;
+ else
+ dwFlags &= ~ANNOTFLAG_PRINT;
+
+ if (dwFlags != pWidget->GetFlags())
+ {
+ pWidget->SetFlags(dwFlags);
+ bSet = TRUE;
+ }
+ }
+ }
+
+ if (bSet)
+ UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE);
+ }
+ else
+ {
+ if(m_nFormControlIndex >= pFormField->CountControls()) return FALSE;
+ if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex))
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ FX_DWORD dwFlags = pWidget->GetFlags();
+ if (bVP)
+ dwFlags |= ANNOTFLAG_PRINT;
+ else
+ dwFlags &= ~ANNOTFLAG_PRINT;
+
+ if (dwFlags != pWidget->GetFlags())
+ {
+ pWidget->SetFlags(dwFlags);
+ UpdateFormControl(m_pDocument, pFormField->GetControl(m_nFormControlIndex), TRUE, FALSE, TRUE);
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+ if (!pWidget) return FALSE;
+
+ if (pWidget->GetFlags() & ANNOTFLAG_PRINT)
+ vp << true;
+ else
+ vp << false;
+ }
+
+ return TRUE;
}
FX_BOOL Field::radiosInUnison(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- }
- else
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ }
+ else
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::readonly(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- }
- else
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ }
+ else
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::rect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
- if (!vp.IsArrayObject())return FALSE;
-
- CJS_Array rcArray(m_isolate);
- vp >> rcArray;
- CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate), Lower_Rightx(m_isolate), Lower_Righty(m_isolate);
- rcArray.GetElement(0, Upper_Leftx);
- rcArray.GetElement(1, Upper_Lefty);
- rcArray.GetElement(2, Lower_Rightx);
- rcArray.GetElement(3, Lower_Righty);
-
- FX_FLOAT pArray[4] = {0.0f,0.0f,0.0f,0.0f};
- pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt();
- pArray[1] = (FX_FLOAT)Lower_Righty.ToInt();
- pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt();
- pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt();
-
- CPDF_Rect crRect(pArray);
-
- if (m_bDelay)
- {
- AddDelay_Rect(FP_RECT, crRect);
- }
- else
- {
- Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
- if (!pWidget) return FALSE;
-
- CFX_FloatRect crRect = pWidget->GetRect();
- CJS_Value Upper_Leftx(m_isolate),Upper_Lefty(m_isolate),Lower_Rightx(m_isolate),Lower_Righty(m_isolate);
- Upper_Leftx = (int32_t)crRect.left;
- Upper_Lefty = (int32_t)crRect.top;
- Lower_Rightx = (int32_t)crRect.right;
- Lower_Righty = (int32_t)crRect.bottom;
-
- CJS_Array rcArray(m_isolate);
- rcArray.SetElement(0,Upper_Leftx);
- rcArray.SetElement(1,Upper_Lefty);
- rcArray.SetElement(2,Lower_Rightx);
- rcArray.SetElement(3,Lower_Righty);
-
- vp << rcArray;
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+ if (!vp.IsArrayObject())return FALSE;
+
+ CJS_Array rcArray(m_isolate);
+ vp >> rcArray;
+ CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate), Lower_Rightx(m_isolate), Lower_Righty(m_isolate);
+ rcArray.GetElement(0, Upper_Leftx);
+ rcArray.GetElement(1, Upper_Lefty);
+ rcArray.GetElement(2, Lower_Rightx);
+ rcArray.GetElement(3, Lower_Righty);
+
+ FX_FLOAT pArray[4] = {0.0f,0.0f,0.0f,0.0f};
+ pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt();
+ pArray[1] = (FX_FLOAT)Lower_Righty.ToInt();
+ pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt();
+ pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt();
+
+ CPDF_Rect crRect(pArray);
+
+ if (m_bDelay)
+ {
+ AddDelay_Rect(FP_RECT, crRect);
+ }
+ else
+ {
+ Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+ if (!pWidget) return FALSE;
+
+ CFX_FloatRect crRect = pWidget->GetRect();
+ CJS_Value Upper_Leftx(m_isolate),Upper_Lefty(m_isolate),Lower_Rightx(m_isolate),Lower_Righty(m_isolate);
+ Upper_Leftx = (int32_t)crRect.left;
+ Upper_Lefty = (int32_t)crRect.top;
+ Lower_Rightx = (int32_t)crRect.right;
+ Lower_Righty = (int32_t)crRect.bottom;
+
+ CJS_Array rcArray(m_isolate);
+ rcArray.SetElement(0,Upper_Leftx);
+ rcArray.SetElement(1,Upper_Lefty);
+ rcArray.SetElement(2,Lower_Rightx);
+ rcArray.SetElement(3,Lower_Righty);
+
+ vp << rcArray;
+ }
+
+ return TRUE;
}
void Field::SetRect(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPDF_Rect& rect)
{
- ASSERT(pDocument != NULL);
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (nControlIndex < 0)
- {
- FX_BOOL bSet = FALSE;
- for (int i=0, sz=pFormField->CountControls(); i<sz; i++)
- {
- CPDF_FormControl* pFormControl = pFormField->GetControl(i);
- ASSERT(pFormControl != NULL);
-
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- CPDF_Rect crRect = rect;
-
- CPDF_Page* pPDFPage = pWidget->GetPDFPage();
- ASSERT(pPDFPage != NULL);
-
-// CPDF_Page* pPDFPage = pPage->GetPage();
-// ASSERT(pPDFPage != NULL);
-
- crRect.Intersect(pPDFPage->GetPageBBox());
-
- if (!crRect.IsEmpty())
- {
- CPDF_Rect rcOld = pWidget->GetRect();
- if (crRect.left != rcOld.left ||
- crRect.right != rcOld.right ||
- crRect.top != rcOld.top ||
- crRect.bottom != rcOld.bottom)
- {
- pWidget->SetRect(crRect);
- bSet = TRUE;
- }
- }
- }
- }
-
- if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
- }
- else
- {
- if(nControlIndex >= pFormField->CountControls()) return;
- if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
- {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
- {
- CPDF_Rect crRect = rect;
-
- CPDF_Page* pPDFPage = pWidget->GetPDFPage();
- ASSERT(pPDFPage != NULL);
-
-// CPDF_Page* pPDFPage = pPage->GetPage();
-// ASSERT(pPDFPage != NULL);
-
- crRect.Intersect(pPDFPage->GetPageBBox());
-
- if (!crRect.IsEmpty())
- {
- CPDF_Rect rcOld = pWidget->GetRect();
- if (crRect.left != rcOld.left ||
- crRect.right != rcOld.right ||
- crRect.top != rcOld.top ||
- crRect.bottom != rcOld.bottom)
- {
- pWidget->SetRect(crRect);
- UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
- }
- }
- }
- }
- }
- }
+ ASSERT(pDocument != NULL);
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (nControlIndex < 0)
+ {
+ FX_BOOL bSet = FALSE;
+ for (int i=0, sz=pFormField->CountControls(); i<sz; i++)
+ {
+ CPDF_FormControl* pFormControl = pFormField->GetControl(i);
+ ASSERT(pFormControl != NULL);
+
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ CPDF_Rect crRect = rect;
+
+ CPDF_Page* pPDFPage = pWidget->GetPDFPage();
+ ASSERT(pPDFPage != NULL);
+
+// CPDF_Page* pPDFPage = pPage->GetPage();
+// ASSERT(pPDFPage != NULL);
+
+ crRect.Intersect(pPDFPage->GetPageBBox());
+
+ if (!crRect.IsEmpty())
+ {
+ CPDF_Rect rcOld = pWidget->GetRect();
+ if (crRect.left != rcOld.left ||
+ crRect.right != rcOld.right ||
+ crRect.top != rcOld.top ||
+ crRect.bottom != rcOld.bottom)
+ {
+ pWidget->SetRect(crRect);
+ bSet = TRUE;
+ }
+ }
+ }
+ }
+
+ if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);
+ }
+ else
+ {
+ if(nControlIndex >= pFormField->CountControls()) return;
+ if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))
+ {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))
+ {
+ CPDF_Rect crRect = rect;
+
+ CPDF_Page* pPDFPage = pWidget->GetPDFPage();
+ ASSERT(pPDFPage != NULL);
+
+// CPDF_Page* pPDFPage = pPage->GetPage();
+// ASSERT(pPDFPage != NULL);
+
+ crRect.Intersect(pPDFPage->GetPageBBox());
+
+ if (!crRect.IsEmpty())
+ {
+ CPDF_Rect rcOld = pWidget->GetRect();
+ if (crRect.left != rcOld.left ||
+ crRect.right != rcOld.right ||
+ crRect.top != rcOld.top ||
+ crRect.bottom != rcOld.bottom)
+ {
+ pWidget->SetRect(crRect);
+ UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);
+ }
+ }
+ }
+ }
+ }
+ }
}
FX_BOOL Field::required(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- }
- else
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ }
+ else
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::richText(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- bool bVP;
- vp >> bVP;
+ bool bVP;
+ vp >> bVP;
- if (m_bDelay)
- {
- AddDelay_Bool(FP_RICHTEXT, bVP);
- }
- else
- {
- Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Bool(FP_RICHTEXT, bVP);
+ }
+ else
+ {
+ Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+ return FALSE;
- if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)
- vp << true;
- else
- vp << false;
- }
+ if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)
+ vp << true;
+ else
+ vp << false;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetRichText(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::richValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
- ;
- }
- else
- {
- ;
- }
- return TRUE;
+ return TRUE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+ ;
+ }
+ else
+ {
+ ;
+ }
+ return TRUE;
}
void Field::SetRichValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::rotation(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_ROTATION, nVP);
- }
- else
- {
- Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_ROTATION, nVP);
+ }
+ else
+ {
+ Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- vp << (int32_t)pFormControl->GetRotation();
- }
+ vp << (int32_t)pFormControl->GetRotation();
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetRotation(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::strokeColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- if (!vp.IsArrayObject())return FALSE;
-
- CJS_Array crArray(m_isolate);
- vp >> crArray;
-
- CPWL_Color color;
- color::ConvertArrayToPWLColor(crArray, color);
-
- if (m_bDelay)
- {
- AddDelay_Color(FP_STROKECOLOR, color);
- }
- else
- {
- Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
-
- int iColorType;
- pFormControl->GetBorderColor(iColorType);
-
- CPWL_Color color;
-
- if (iColorType == COLORTYPE_TRANSPARENT)
- {
- color = CPWL_Color(COLORTYPE_TRANSPARENT);
- }
- else if (iColorType == COLORTYPE_GRAY)
- {
- color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
- }
- else if (iColorType == COLORTYPE_RGB)
- {
- color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
- pFormControl->GetOriginalBorderColor(1),
- pFormControl->GetOriginalBorderColor(2));
- }
- else if (iColorType == COLORTYPE_CMYK)
- {
- color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
- pFormControl->GetOriginalBorderColor(1),
- pFormControl->GetOriginalBorderColor(2),
- pFormControl->GetOriginalBorderColor(3));
- }
- else
- return FALSE;
-
- CJS_Array crArray(m_isolate);
- color::ConvertPWLColorToArray(color, crArray);
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ if (!vp.IsArrayObject())return FALSE;
+
+ CJS_Array crArray(m_isolate);
+ vp >> crArray;
+
+ CPWL_Color color;
+ color::ConvertArrayToPWLColor(crArray, color);
+
+ if (m_bDelay)
+ {
+ AddDelay_Color(FP_STROKECOLOR, color);
+ }
+ else
+ {
+ Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
+
+ int iColorType;
+ pFormControl->GetBorderColor(iColorType);
+
+ CPWL_Color color;
+
+ if (iColorType == COLORTYPE_TRANSPARENT)
+ {
+ color = CPWL_Color(COLORTYPE_TRANSPARENT);
+ }
+ else if (iColorType == COLORTYPE_GRAY)
+ {
+ color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
+ }
+ else if (iColorType == COLORTYPE_RGB)
+ {
+ color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
+ pFormControl->GetOriginalBorderColor(1),
+ pFormControl->GetOriginalBorderColor(2));
+ }
+ else if (iColorType == COLORTYPE_CMYK)
+ {
+ color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
+ pFormControl->GetOriginalBorderColor(1),
+ pFormControl->GetOriginalBorderColor(2),
+ pFormControl->GetOriginalBorderColor(3));
+ }
+ else
+ return FALSE;
+
+ CJS_Array crArray(m_isolate);
+ color::ConvertPWLColorToArray(color, crArray);
vp << crArray;
- }
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetStrokeColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::style(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CFX_ByteString csBCaption;
- vp >> csBCaption;
-
- if (m_bDelay)
- {
- AddDelay_String(FP_STYLE, csBCaption);
- }
- else
- {
- Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, csBCaption);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
- pFormField->GetFieldType() != FIELDTYPE_CHECKBOX)
- return FALSE;
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl) return FALSE;
-
- CFX_WideString csWCaption = pFormControl->GetNormalCaption();
- CFX_ByteString csBCaption;
-
- switch (csWCaption[0])
- {
- case L'l':
- csBCaption = "circle";
- break;
- case L'8':
- csBCaption = "cross";
- break;
- case L'u':
- csBCaption = "diamond";
- break;
- case L'n':
- csBCaption = "square";
- break;
- case L'H':
- csBCaption = "star";
- break;
- default: //L'4'
- csBCaption = "check";
- break;
- }
- vp << csBCaption;
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CFX_ByteString csBCaption;
+ vp >> csBCaption;
+
+ if (m_bDelay)
+ {
+ AddDelay_String(FP_STYLE, csBCaption);
+ }
+ else
+ {
+ Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, csBCaption);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
+ pFormField->GetFieldType() != FIELDTYPE_CHECKBOX)
+ return FALSE;
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl) return FALSE;
+
+ CFX_WideString csWCaption = pFormControl->GetNormalCaption();
+ CFX_ByteString csBCaption;
+
+ switch (csWCaption[0])
+ {
+ case L'l':
+ csBCaption = "circle";
+ break;
+ case L'8':
+ csBCaption = "cross";
+ break;
+ case L'u':
+ csBCaption = "diamond";
+ break;
+ case L'n':
+ csBCaption = "square";
+ break;
+ case L'H':
+ csBCaption = "star";
+ break;
+ default: //L'4'
+ csBCaption = "check";
+ break;
+ }
+ vp << csBCaption;
+ }
+
+ return TRUE;
}
void Field::SetStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex,
- const CFX_ByteString& string)
+ const CFX_ByteString& string)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::submitName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::textColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CJS_Array crArray(m_isolate);
- if (!vp.IsArrayObject())return FALSE;
- vp >> crArray;
-
- CPWL_Color color;
- color::ConvertArrayToPWLColor(crArray, color);
-
- if (m_bDelay)
- {
- AddDelay_Color(FP_TEXTCOLOR, color);
- }
- else
- {
- Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
-
- int iColorType;
- FX_ARGB color;
- CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
- FieldAppearance.GetColor(color, iColorType);
- int32_t a,r,g,b;
- ArgbDecode(color, a, r, g, b);
-
- CPWL_Color crRet = CPWL_Color(COLORTYPE_RGB, r / 255.0f,
- g / 255.0f,
- b / 255.0f);
-
- if (iColorType == COLORTYPE_TRANSPARENT)
- crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
-
- CJS_Array crArray(m_isolate);
- color::ConvertPWLColorToArray(crRet, crArray);
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CJS_Array crArray(m_isolate);
+ if (!vp.IsArrayObject())return FALSE;
+ vp >> crArray;
+
+ CPWL_Color color;
+ color::ConvertArrayToPWLColor(crArray, color);
+
+ if (m_bDelay)
+ {
+ AddDelay_Color(FP_TEXTCOLOR, color);
+ }
+ else
+ {
+ Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
+
+ int iColorType;
+ FX_ARGB color;
+ CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
+ FieldAppearance.GetColor(color, iColorType);
+ int32_t a,r,g,b;
+ ArgbDecode(color, a, r, g, b);
+
+ CPWL_Color crRet = CPWL_Color(COLORTYPE_RGB, r / 255.0f,
+ g / 255.0f,
+ b / 255.0f);
+
+ if (iColorType == COLORTYPE_TRANSPARENT)
+ crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
+
+ CJS_Array crArray(m_isolate);
+ color::ConvertPWLColorToArray(crRet, crArray);
vp << crArray;
- }
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetTextColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::textFont(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- CFX_ByteString csFontName;
- vp >> csFontName;
- if (csFontName.IsEmpty()) return FALSE;
+ CFX_ByteString csFontName;
+ vp >> csFontName;
+ if (csFontName.IsEmpty()) return FALSE;
- if (m_bDelay)
- {
- AddDelay_String(FP_TEXTFONT, csFontName);
- }
- else
- {
- Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, csFontName);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_String(FP_TEXTFONT, csFontName);
+ }
+ else
+ {
+ Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, csFontName);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- int nFieldType = pFormField->GetFieldType();
+ int nFieldType = pFormField->GetFieldType();
- if (nFieldType == FIELDTYPE_PUSHBUTTON ||
- nFieldType == FIELDTYPE_COMBOBOX ||
- nFieldType == FIELDTYPE_LISTBOX ||
- nFieldType == FIELDTYPE_TEXTFIELD)
- {
- CPDF_Font * pFont = pFormControl->GetDefaultControlFont();
- if (!pFont) return FALSE;
+ if (nFieldType == FIELDTYPE_PUSHBUTTON ||
+ nFieldType == FIELDTYPE_COMBOBOX ||
+ nFieldType == FIELDTYPE_LISTBOX ||
+ nFieldType == FIELDTYPE_TEXTFIELD)
+ {
+ CPDF_Font * pFont = pFormControl->GetDefaultControlFont();
+ if (!pFont) return FALSE;
- vp << pFont->GetBaseFont();
- }
- else
- return FALSE;
- }
+ vp << pFont->GetBaseFont();
+ }
+ else
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetTextFont(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::textSize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- int nVP;
- vp >> nVP;
+ int nVP;
+ vp >> nVP;
- if (m_bDelay)
- {
- AddDelay_Int(FP_TEXTSIZE, nVP);
- }
- else
- {
- Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_Int(FP_TEXTSIZE, nVP);
+ }
+ else
+ {
+ Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
+ CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
- CFX_ByteString csFontNameTag;
- FX_FLOAT fFontSize;
- FieldAppearance.GetFont(csFontNameTag,fFontSize);
+ CFX_ByteString csFontNameTag;
+ FX_FLOAT fFontSize;
+ FieldAppearance.GetFont(csFontNameTag,fFontSize);
- vp << (int)fFontSize;
- }
+ vp << (int)fFontSize;
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetTextSize(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (!vp.IsGetting()) return FALSE;
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- switch (pFormField->GetFieldType())
- {
- case FIELDTYPE_UNKNOWN:
- vp << L"unknown";
- break;
- case FIELDTYPE_PUSHBUTTON:
- vp << L"button";
- break;
- case FIELDTYPE_CHECKBOX:
- vp << L"checkbox";
- break;
- case FIELDTYPE_RADIOBUTTON:
- vp << L"radiobutton";
- break;
- case FIELDTYPE_COMBOBOX:
- vp << L"combobox";
- break;
- case FIELDTYPE_LISTBOX:
- vp << L"listbox";
- break;
- case FIELDTYPE_TEXTFIELD:
- vp << L"text";
- break;
- case FIELDTYPE_SIGNATURE:
- vp << L"signature";
- break;
- default :
- vp << L"unknown";
- break;
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (!vp.IsGetting()) return FALSE;
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ switch (pFormField->GetFieldType())
+ {
+ case FIELDTYPE_UNKNOWN:
+ vp << L"unknown";
+ break;
+ case FIELDTYPE_PUSHBUTTON:
+ vp << L"button";
+ break;
+ case FIELDTYPE_CHECKBOX:
+ vp << L"checkbox";
+ break;
+ case FIELDTYPE_RADIOBUTTON:
+ vp << L"radiobutton";
+ break;
+ case FIELDTYPE_COMBOBOX:
+ vp << L"combobox";
+ break;
+ case FIELDTYPE_LISTBOX:
+ vp << L"listbox";
+ break;
+ case FIELDTYPE_TEXTFIELD:
+ vp << L"text";
+ break;
+ case FIELDTYPE_SIGNATURE:
+ vp << L"signature";
+ break;
+ default :
+ vp << L"unknown";
+ break;
+ }
+
+ return TRUE;
}
FX_BOOL Field::userName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
- CFX_WideString swName;
- vp >> swName;
+ CFX_WideString swName;
+ vp >> swName;
- if (m_bDelay)
- {
- AddDelay_WideString(FP_USERNAME, swName);
- }
- else
- {
- Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, swName);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ if (m_bDelay)
+ {
+ AddDelay_WideString(FP_USERNAME, swName);
+ }
+ else
+ {
+ Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, swName);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- vp << (CFX_WideString)pFormField->GetAlternateName();
- }
+ vp << (CFX_WideString)pFormField->GetAlternateName();
+ }
- return TRUE;
+ return TRUE;
}
void Field::SetUserName(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_WideString& string)
{
- //Not supported.
+ //Not supported.
}
FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (vp.IsSetting())
- {
- if (!m_bCanSet) return FALSE;
-
- CJS_WideStringArray strArray;
-
- if (vp.IsArrayObject())
- {
- CJS_Array ValueArray(m_isolate);
- vp.ConvertToArray(ValueArray);
- for (int i = 0,sz = ValueArray.GetLength(); i < sz; i++)
- {
- CJS_Value ElementValue(m_isolate);
- ValueArray.GetElement(i, ElementValue);
- strArray.Add(ElementValue.ToCFXWideString());
- }
- }
- else
- {
- CFX_WideString swValue;
- vp >> swValue;
-
- strArray.Add(swValue);
- }
-
- if (m_bDelay)
- {
- AddDelay_WideStringArray(FP_VALUE, strArray);
- }
- else
- {
- Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray);
- }
- }
- else
- {
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
-
-
- switch (pFormField->GetFieldType())
- {
- case FIELDTYPE_PUSHBUTTON:
- return FALSE;
- case FIELDTYPE_COMBOBOX:
- case FIELDTYPE_TEXTFIELD:
- {
- CFX_WideString swValue = pFormField->GetValue();
-
- double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot))
- {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
- }
- else
- vp << swValue;
- }
- break;
- case FIELDTYPE_LISTBOX:
- {
- if (pFormField->CountSelectedItems() > 1)
- {
- CJS_Array ValueArray(m_isolate);
- CJS_Value ElementValue(m_isolate);
- int iIndex;
- for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++)
- {
- iIndex = pFormField->GetSelectedIndex(i);
- ElementValue = pFormField->GetOptionValue(iIndex).c_str();
- if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0)
- ElementValue = pFormField->GetOptionLabel(iIndex).c_str();
- ValueArray.SetElement(i, ElementValue);
- }
- vp << ValueArray;
- }
- else
- {
- CFX_WideString swValue = pFormField->GetValue();
-
- double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot))
- {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
- }
- else
- vp << swValue;
- }
- }
- break;
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- {
- FX_BOOL bFind = FALSE;
- for (int i = 0 , sz = pFormField->CountControls(); i < sz; i++)
- {
- if (pFormField->GetControl(i)->IsChecked())
- {
- CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue();
- double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot))
- {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
- }
- else
- vp << swValue;
-
- bFind = TRUE;
- break;
- }
- else
- continue;
- }
- if (!bFind)
- vp << L"Off";
- }
- break;
- default:
- vp << pFormField->GetValue();
- break;
- }
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (vp.IsSetting())
+ {
+ if (!m_bCanSet) return FALSE;
+
+ CJS_WideStringArray strArray;
+
+ if (vp.IsArrayObject())
+ {
+ CJS_Array ValueArray(m_isolate);
+ vp.ConvertToArray(ValueArray);
+ for (int i = 0,sz = ValueArray.GetLength(); i < sz; i++)
+ {
+ CJS_Value ElementValue(m_isolate);
+ ValueArray.GetElement(i, ElementValue);
+ strArray.Add(ElementValue.ToCFXWideString());
+ }
+ }
+ else
+ {
+ CFX_WideString swValue;
+ vp >> swValue;
+
+ strArray.Add(swValue);
+ }
+
+ if (m_bDelay)
+ {
+ AddDelay_WideStringArray(FP_VALUE, strArray);
+ }
+ else
+ {
+ Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray);
+ }
+ }
+ else
+ {
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+
+
+ switch (pFormField->GetFieldType())
+ {
+ case FIELDTYPE_PUSHBUTTON:
+ return FALSE;
+ case FIELDTYPE_COMBOBOX:
+ case FIELDTYPE_TEXTFIELD:
+ {
+ CFX_WideString swValue = pFormField->GetValue();
+
+ double dRet;
+ FX_BOOL bDot;
+ if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot))
+ {
+ if (bDot)
+ vp << dRet;
+ else
+ vp << dRet;
+ }
+ else
+ vp << swValue;
+ }
+ break;
+ case FIELDTYPE_LISTBOX:
+ {
+ if (pFormField->CountSelectedItems() > 1)
+ {
+ CJS_Array ValueArray(m_isolate);
+ CJS_Value ElementValue(m_isolate);
+ int iIndex;
+ for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++)
+ {
+ iIndex = pFormField->GetSelectedIndex(i);
+ ElementValue = pFormField->GetOptionValue(iIndex).c_str();
+ if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0)
+ ElementValue = pFormField->GetOptionLabel(iIndex).c_str();
+ ValueArray.SetElement(i, ElementValue);
+ }
+ vp << ValueArray;
+ }
+ else
+ {
+ CFX_WideString swValue = pFormField->GetValue();
+
+ double dRet;
+ FX_BOOL bDot;
+ if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot))
+ {
+ if (bDot)
+ vp << dRet;
+ else
+ vp << dRet;
+ }
+ else
+ vp << swValue;
+ }
+ }
+ break;
+ case FIELDTYPE_CHECKBOX:
+ case FIELDTYPE_RADIOBUTTON:
+ {
+ FX_BOOL bFind = FALSE;
+ for (int i = 0 , sz = pFormField->CountControls(); i < sz; i++)
+ {
+ if (pFormField->GetControl(i)->IsChecked())
+ {
+ CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue();
+ double dRet;
+ FX_BOOL bDot;
+ if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot))
+ {
+ if (bDot)
+ vp << dRet;
+ else
+ vp << dRet;
+ }
+ else
+ vp << swValue;
+
+ bFind = TRUE;
+ break;
+ }
+ else
+ continue;
+ }
+ if (!bFind)
+ vp << L"Off";
+ }
+ break;
+ default:
+ vp << pFormField->GetValue();
+ break;
+ }
+ }
+
+ return TRUE;
}
void Field::SetValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName,
- int nControlIndex, const CJS_WideStringArray& strArray)
-{
- ASSERT(pDocument != NULL);
-
- if (strArray.GetSize() < 1) return;
-
- CFX_PtrArray FieldArray;
- GetFormFields(pDocument, swFieldName, FieldArray);
-
- for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFullName().Compare(swFieldName) != 0)
- continue;
-
- switch (pFormField->GetFieldType())
- {
- case FIELDTYPE_TEXTFIELD:
- case FIELDTYPE_COMBOBOX:
- if (pFormField->GetValue() != strArray.GetAt(0))
- {
- CFX_WideString WideString = strArray.GetAt(0);
- pFormField->SetValue(strArray.GetAt(0), TRUE);
- UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
- }
- break;
- case FIELDTYPE_CHECKBOX: //mantis: 0004493
- case FIELDTYPE_RADIOBUTTON:
- {
- if (pFormField->GetValue() != strArray.GetAt(0))
- {
- pFormField->SetValue(strArray.GetAt(0), TRUE);
- UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
- }
- }
- break;
- case FIELDTYPE_LISTBOX:
- {
- FX_BOOL bModified = FALSE;
-
- for (int i=0,sz=strArray.GetSize(); i<sz; i++)
- {
- int iIndex = pFormField->FindOption(strArray.GetAt(i));
-
- if (!pFormField->IsItemSelected(iIndex))
- {
- bModified = TRUE;
- break;
- }
- }
-
- if (bModified)
- {
- pFormField->ClearSelection(TRUE);
- for (int i=0,sz=strArray.GetSize(); i<sz; i++)
- {
- int iIndex = pFormField->FindOption(strArray.GetAt(i));
- pFormField->SetItemSelection(iIndex, TRUE, TRUE);
- }
-
- UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
- }
- }
- break;
- default:
- break;
- }
- }
+ int nControlIndex, const CJS_WideStringArray& strArray)
+{
+ ASSERT(pDocument != NULL);
+
+ if (strArray.GetSize() < 1) return;
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(pDocument, swFieldName, FieldArray);
+
+ for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFullName().Compare(swFieldName) != 0)
+ continue;
+
+ switch (pFormField->GetFieldType())
+ {
+ case FIELDTYPE_TEXTFIELD:
+ case FIELDTYPE_COMBOBOX:
+ if (pFormField->GetValue() != strArray.GetAt(0))
+ {
+ CFX_WideString WideString = strArray.GetAt(0);
+ pFormField->SetValue(strArray.GetAt(0), TRUE);
+ UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
+ }
+ break;
+ case FIELDTYPE_CHECKBOX: //mantis: 0004493
+ case FIELDTYPE_RADIOBUTTON:
+ {
+ if (pFormField->GetValue() != strArray.GetAt(0))
+ {
+ pFormField->SetValue(strArray.GetAt(0), TRUE);
+ UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
+ }
+ }
+ break;
+ case FIELDTYPE_LISTBOX:
+ {
+ FX_BOOL bModified = FALSE;
+
+ for (int i=0,sz=strArray.GetSize(); i<sz; i++)
+ {
+ int iIndex = pFormField->FindOption(strArray.GetAt(i));
+
+ if (!pFormField->IsItemSelected(iIndex))
+ {
+ bModified = TRUE;
+ break;
+ }
+ }
+
+ if (bModified)
+ {
+ pFormField->ClearSelection(TRUE);
+ for (int i=0,sz=strArray.GetSize(); i<sz; i++)
+ {
+ int iIndex = pFormField->FindOption(strArray.GetAt(i));
+ pFormField->SetItemSelection(iIndex, TRUE, TRUE);
+ }
+
+ UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
FX_BOOL Field::valueAsString(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- if (!vp.IsGetting()) return FALSE;
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return FALSE;
-
- if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
- {
- if(!pFormField->CountControls()) return FALSE;
-
- if (pFormField->GetControl(0)->IsChecked())
- vp << L"Yes";
- else
- vp << L"Off";
- }
- else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON))
- {
- for (int i=0, sz=pFormField->CountControls(); i<sz; i++)
- {
- if (pFormField->GetControl(i)->IsChecked())
- {
- vp << pFormField->GetControl(i)->GetExportValue().c_str();
- break;
- }
- else
- vp << L"Off";
- }
- }
- else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && (pFormField->CountSelectedItems() > 1))
- {
- vp << L"";
- }
- else
- vp << pFormField->GetValue().c_str();
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ if (!vp.IsGetting()) return FALSE;
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+ return FALSE;
+
+ if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
+ {
+ if(!pFormField->CountControls()) return FALSE;
+
+ if (pFormField->GetControl(0)->IsChecked())
+ vp << L"Yes";
+ else
+ vp << L"Off";
+ }
+ else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON))
+ {
+ for (int i=0, sz=pFormField->CountControls(); i<sz; i++)
+ {
+ if (pFormField->GetControl(i)->IsChecked())
+ {
+ vp << pFormField->GetControl(i)->GetExportValue().c_str();
+ break;
+ }
+ else
+ vp << L"Off";
+ }
+ }
+ else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && (pFormField->CountSelectedItems() > 1))
+ {
+ vp << L"";
+ }
+ else
+ vp << pFormField->GetValue().c_str();
+
+ return TRUE;
}
/* --------------------------------- methods --------------------------------- */
FX_BOOL Field::browseForFileToSubmit(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName, FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName, FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- CPDFDoc_Environment* pApp = m_pDocument->GetEnv();
- ASSERT(pApp != NULL);
+ CPDFDoc_Environment* pApp = m_pDocument->GetEnv();
+ ASSERT(pApp != NULL);
- if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
- (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD))
- {
- CFX_WideString wsFileName = pApp->JS_fieldBrowse();
- if(!wsFileName.IsEmpty())
- {
- pFormField->SetValue(wsFileName);
- UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE);
+ if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
+ (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD))
+ {
+ CFX_WideString wsFileName = pApp->JS_fieldBrowse();
+ if(!wsFileName.IsEmpty())
+ {
+ pFormField->SetValue(wsFileName);
+ UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE);
}
- }
- else
- return FALSE;
+ }
+ else
+ return FALSE;
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::buttonGetCaption(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- int nface = 0;
- int iSize = params.size();
- if (iSize >= 1)
- nface = params[0].ToInt();
+ int nface = 0;
+ int iSize = params.size();
+ if (iSize >= 1)
+ nface = params[0].ToInt();
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- if (nface == 0)
- vRet = pFormControl->GetNormalCaption().c_str();
- else if (nface == 1)
- vRet = pFormControl->GetDownCaption().c_str();
- else if (nface == 2)
- vRet = pFormControl->GetRolloverCaption().c_str();
- else
- return FALSE;
+ if (nface == 0)
+ vRet = pFormControl->GetNormalCaption().c_str();
+ else if (nface == 1)
+ vRet = pFormControl->GetDownCaption().c_str();
+ else if (nface == 2)
+ vRet = pFormControl->GetRolloverCaption().c_str();
+ else
+ return FALSE;
- return TRUE;
+ return TRUE;
}
//#pragma warning(disable: 4800)
FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- int nface = 0;
- int iSize = params.size();
- if (iSize >= 1)
- nface = params[0].ToInt();
+ int nface = 0;
+ int iSize = params.size();
+ if (iSize >= 1)
+ nface = params[0].ToInt();
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return FALSE;
+ if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+ return FALSE;
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
- ASSERT(pObj.IsEmpty() == FALSE);
+ JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
+ ASSERT(pObj.IsEmpty() == FALSE);
- CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj);
- ASSERT(pJS_Icon != NULL);
+ CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj);
+ ASSERT(pJS_Icon != NULL);
- Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
- ASSERT(pIcon != NULL);
+ Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
+ ASSERT(pIcon != NULL);
- CPDF_Stream* pIconStream = NULL;
- if (nface == 0)
- pIconStream = pFormControl->GetNormalIcon();
- else if (nface == 1)
- pIconStream = pFormControl->GetDownIcon();
- else if (nface == 2)
- pIconStream = pFormControl->GetRolloverIcon();
- else
- return FALSE;
+ CPDF_Stream* pIconStream = NULL;
+ if (nface == 0)
+ pIconStream = pFormControl->GetNormalIcon();
+ else if (nface == 1)
+ pIconStream = pFormControl->GetDownIcon();
+ else if (nface == 2)
+ pIconStream = pFormControl->GetRolloverIcon();
+ else
+ return FALSE;
- pIcon->SetStream(pIconStream);
- vRet = pJS_Icon;
+ pIcon->SetStream(pIconStream);
+ vRet = pJS_Icon;
- return TRUE;
+ return TRUE;
}
//#pragma warning(default: 4800)
@@ -3460,656 +3461,656 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
FX_BOOL Field::buttonImportIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
#if 0
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- if (!pFormField)return FALSE;
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ if (!pFormField)return FALSE;
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv);
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv);
- CFX_WideString sIconFileName = pEnv->JS_fieldBrowse();
- if (sIconFileName.IsEmpty())
- {
- vRet = 1;
- return TRUE;
- }
+ CFX_WideString sIconFileName = pEnv->JS_fieldBrowse();
+ if (sIconFileName.IsEmpty())
+ {
+ vRet = 1;
+ return TRUE;
+ }
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CPDF_Stream* pStream = pInterForm->LoadImageFromFile(sIconFileName);
- if (!pStream)
- {
- vRet = -1;
- return TRUE;
- }
+ CPDF_Stream* pStream = pInterForm->LoadImageFromFile(sIconFileName);
+ if (!pStream)
+ {
+ vRet = -1;
+ return TRUE;
+ }
- CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
- if (!pFormControl)return FALSE;
+ CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+ if (!pFormControl)return FALSE;
- pFormControl->SetNormalIcon(pStream);
- UpdateFormControl(m_pDocument, pFormControl, TRUE, TRUE, TRUE);
+ pFormControl->SetNormalIcon(pStream);
+ UpdateFormControl(m_pDocument, pFormControl, TRUE, TRUE, TRUE);
- vRet = 0;
+ vRet = 0;
#endif // 0
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::buttonSetCaption(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::buttonSetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::checkThisBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!m_bCanSet) return FALSE;
+ if (!m_bCanSet) return FALSE;
- int iSize = params.size();
- if (iSize < 1)
- return FALSE;
+ int iSize = params.size();
+ if (iSize < 1)
+ return FALSE;
- int nWidget = params[0].ToInt();
+ int nWidget = params[0].ToInt();
- FX_BOOL bCheckit = TRUE;
- if (iSize >= 2)
- bCheckit = params[1].ToBool();
+ FX_BOOL bCheckit = TRUE;
+ if (iSize >= 2)
+ bCheckit = params[1].ToBool();
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
- return FALSE;
- if(nWidget <0 || nWidget >= pFormField->CountControls())
- return FALSE;
- if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)
- pFormField->CheckControl(nWidget, bCheckit, TRUE);
- else
- pFormField->CheckControl(nWidget, bCheckit, TRUE);
+ if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
+ return FALSE;
+ if(nWidget <0 || nWidget >= pFormField->CountControls())
+ return FALSE;
+ if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)
+ pFormField->CheckControl(nWidget, bCheckit, TRUE);
+ else
+ pFormField->CheckControl(nWidget, bCheckit, TRUE);
- UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE);
- return TRUE;
+ UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE);
+ return TRUE;
}
FX_BOOL Field::clearItems(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::defaultIsChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- if (!m_bCanSet) return FALSE;
+ if (!m_bCanSet) return FALSE;
- int iSize = params.size();
- if (iSize < 1)
- return FALSE;
+ int iSize = params.size();
+ if (iSize < 1)
+ return FALSE;
- int nWidget = params[0].ToInt();
+ int nWidget = params[0].ToInt();
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if(nWidget <0 || nWidget >= pFormField->CountControls())
- {
- vRet = FALSE;
- return FALSE;
- }
- if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
- || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON))
- {
+ if(nWidget <0 || nWidget >= pFormField->CountControls())
+ {
+ vRet = FALSE;
+ return FALSE;
+ }
+ if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
+ || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON))
+ {
- vRet = TRUE;
- }
- else
- vRet = FALSE;
+ vRet = TRUE;
+ }
+ else
+ vRet = FALSE;
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::deleteItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
int JS_COMPARESTRING(CFX_WideString* ps1, CFX_WideString* ps2)
{
- ASSERT(ps1 != NULL);
- ASSERT(ps2 != NULL);
+ ASSERT(ps1 != NULL);
+ ASSERT(ps2 != NULL);
- return ps1->Compare(*ps2);
+ return ps1->Compare(*ps2);
}
FX_BOOL Field::getArray(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CGW_ArrayTemplate<CFX_WideString*> swSort;
+ CGW_ArrayTemplate<CFX_WideString*> swSort;
- for (int i=0,sz=FieldArray.GetSize(); i<sz; i++)
- {
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
- ASSERT(pFormField != NULL);
+ for (int i=0,sz=FieldArray.GetSize(); i<sz; i++)
+ {
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);
+ ASSERT(pFormField != NULL);
- swSort.Add(new CFX_WideString(pFormField->GetFullName()));
+ swSort.Add(new CFX_WideString(pFormField->GetFullName()));
- }
- swSort.Sort(JS_COMPARESTRING);
+ }
+ swSort.Sort(JS_COMPARESTRING);
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- CJS_Array FormFieldArray(m_isolate);
- for (int j=0,jsz = swSort.GetSize(); j<jsz; j++)
- {
- CFX_WideString* pStr = swSort.GetAt(j);
+ CJS_Array FormFieldArray(m_isolate);
+ for (int j=0,jsz = swSort.GetSize(); j<jsz; j++)
+ {
+ CFX_WideString* pStr = swSort.GetAt(j);
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Field"));
- ASSERT(pObj.IsEmpty() == FALSE);
+ JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+ ASSERT(pObj.IsEmpty() == FALSE);
- CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pObj);
- ASSERT(pJSField != NULL);
+ CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pObj);
+ ASSERT(pJSField != NULL);
- Field* pField = (Field*)pJSField->GetEmbedObject();
- ASSERT(pField != NULL);
+ Field* pField = (Field*)pJSField->GetEmbedObject();
+ ASSERT(pField != NULL);
- pField->AttachField(m_pJSDoc, *pStr);
+ pField->AttachField(m_pJSDoc, *pStr);
- CJS_Value FormFieldValue(m_isolate);
- FormFieldValue = pJSField;
- FormFieldArray.SetElement(j, FormFieldValue);
+ CJS_Value FormFieldValue(m_isolate);
+ FormFieldValue = pJSField;
+ FormFieldArray.SetElement(j, FormFieldValue);
- delete pStr;
- }
+ delete pStr;
+ }
- vRet = FormFieldArray;
- swSort.RemoveAll();
- return TRUE;
+ vRet = FormFieldArray;
+ swSort.RemoveAll();
+ return TRUE;
}
FX_BOOL Field::getItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
- int iSize = params.size();
-
- int nIdx = -1;
- if (iSize >= 1)
- nIdx = params[0].ToInt();
-
- FX_BOOL bExport = TRUE;
- if (iSize >= 2)
- bExport = params[1].ToBool();
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX)
- || (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX))
- {
- if (nIdx == -1 || nIdx > pFormField->CountOptions())
- nIdx = pFormField->CountOptions() -1;
- if (bExport)
- {
- CFX_WideString strval = pFormField->GetOptionValue(nIdx);
- if (strval.IsEmpty())
- vRet = pFormField->GetOptionLabel(nIdx).c_str();
- else
- vRet = strval.c_str();
- }
- else
- vRet = pFormField->GetOptionLabel(nIdx).c_str();
- }
- else
- return FALSE;
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+ int iSize = params.size();
+
+ int nIdx = -1;
+ if (iSize >= 1)
+ nIdx = params[0].ToInt();
+
+ FX_BOOL bExport = TRUE;
+ if (iSize >= 2)
+ bExport = params[1].ToBool();
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX)
+ || (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX))
+ {
+ if (nIdx == -1 || nIdx > pFormField->CountOptions())
+ nIdx = pFormField->CountOptions() -1;
+ if (bExport)
+ {
+ CFX_WideString strval = pFormField->GetOptionValue(nIdx);
+ if (strval.IsEmpty())
+ vRet = pFormField->GetOptionLabel(nIdx).c_str();
+ else
+ vRet = strval.c_str();
+ }
+ else
+ vRet = pFormField->GetOptionLabel(nIdx).c_str();
+ }
+ else
+ return FALSE;
+
+ return TRUE;
}
FX_BOOL Field::getLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::insertItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::isBoxChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- int nIndex = -1;
- if (params.size() >= 1)
- nIndex = params[0].ToInt();
+ int nIndex = -1;
+ if (params.size() >= 1)
+ nIndex = params[0].ToInt();
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if(nIndex <0 || nIndex >= pFormField->CountControls())
- {
- vRet = FALSE;
- return FALSE;
- }
+ if(nIndex <0 || nIndex >= pFormField->CountControls())
+ {
+ vRet = FALSE;
+ return FALSE;
+ }
- if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
- || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON))
- {
- if (pFormField->GetControl(nIndex)->IsChecked() !=0 )
- vRet = TRUE;
- else
- vRet = FALSE;
- }
- else
- vRet = FALSE;
+ if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
+ || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON))
+ {
+ if (pFormField->GetControl(nIndex)->IsChecked() !=0 )
+ vRet = TRUE;
+ else
+ vRet = FALSE;
+ }
+ else
+ vRet = FALSE;
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::isDefaultChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
+ ASSERT(m_pDocument != NULL);
- int nIndex = -1;
- if (params.size() >= 1)
- nIndex = params[0].ToInt();
+ int nIndex = -1;
+ if (params.size() >= 1)
+ nIndex = params[0].ToInt();
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
- if(nIndex <0 || nIndex >= pFormField->CountControls())
- {
- vRet = FALSE;
- return FALSE;
- }
- if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
- || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON))
- {
- if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)
- vRet = TRUE;
- else
- vRet = FALSE;
- }
- else
- vRet = FALSE;
+ if(nIndex <0 || nIndex >= pFormField->CountControls())
+ {
+ vRet = FALSE;
+ return FALSE;
+ }
+ if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX)
+ || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON))
+ {
+ if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)
+ vRet = TRUE;
+ else
+ vRet = FALSE;
+ }
+ else
+ vRet = FALSE;
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::setAction(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::setFocus(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- ASSERT(m_pDocument != NULL);
-
- CFX_PtrArray FieldArray;
- GetFormFields(m_FieldName,FieldArray);
- if (FieldArray.GetSize() <= 0) return FALSE;
-
- CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
- int32_t nCount = pFormField->CountControls();
-
- if (nCount < 1) return FALSE;
-
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
-
- CPDFSDK_Widget* pWidget = NULL;
- if (nCount == 1)
- {
- pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
- }
- else
- {
- CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
- ASSERT(pEnv);
- CPDF_Page* pPage = (CPDF_Page*)pEnv->FFI_GetCurrentPage(m_pDocument->GetDocument());
- if(!pPage)
- return FALSE;
- if (CPDFSDK_PageView* pCurPageView = m_pDocument->GetPageView(pPage))
- {
- for (int32_t i=0; i<nCount; i++)
- {
- if (CPDFSDK_Widget* pTempWidget = pInterForm->GetWidget(pFormField->GetControl(i)))
- {
- if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage())
- {
- pWidget = pTempWidget;
- break;
- }
- }
- }
- }
- }
-
- if (pWidget)
- {
- m_pDocument->SetFocusAnnot(pWidget);
- }
-
- return TRUE;
+ ASSERT(m_pDocument != NULL);
+
+ CFX_PtrArray FieldArray;
+ GetFormFields(m_FieldName,FieldArray);
+ if (FieldArray.GetSize() <= 0) return FALSE;
+
+ CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
+ ASSERT(pFormField != NULL);
+
+ int32_t nCount = pFormField->CountControls();
+
+ if (nCount < 1) return FALSE;
+
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CPDFSDK_Widget* pWidget = NULL;
+ if (nCount == 1)
+ {
+ pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
+ }
+ else
+ {
+ CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
+ ASSERT(pEnv);
+ CPDF_Page* pPage = (CPDF_Page*)pEnv->FFI_GetCurrentPage(m_pDocument->GetDocument());
+ if(!pPage)
+ return FALSE;
+ if (CPDFSDK_PageView* pCurPageView = m_pDocument->GetPageView(pPage))
+ {
+ for (int32_t i=0; i<nCount; i++)
+ {
+ if (CPDFSDK_Widget* pTempWidget = pInterForm->GetWidget(pFormField->GetControl(i)))
+ {
+ if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage())
+ {
+ pWidget = pTempWidget;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (pWidget)
+ {
+ m_pDocument->SetFocusAnnot(pWidget);
+ }
+
+ return TRUE;
}
FX_BOOL Field::setItems(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return TRUE;
+ return TRUE;
}
FX_BOOL Field::setLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::signatureGetModifications(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::signatureGetSeedValue(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::signatureInfo(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::signatureSetSeedValue(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::signatureSign(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::signatureValidate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL Field::source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsGetting())
- {
- vp << (CJS_Object*)NULL;
- }
+ if (vp.IsGetting())
+ {
+ vp << (CJS_Object*)NULL;
+ }
- return TRUE;
+ return TRUE;
}
/////////////////////////////////////////// delay /////////////////////////////////////////////
void Field::AddDelay_Int(enum FIELD_PROP prop, int32_t n)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- pNewData->num = n;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ pNewData->num = n;
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_Bool(enum FIELD_PROP prop,bool b)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- pNewData->b = b;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ pNewData->b = b;
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- pNewData->string = string;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ pNewData->string = string;
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- pNewData->widestring = string;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ pNewData->widestring = string;
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- pNewData->rect = rect;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ pNewData->rect = rect;
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- pNewData->color = color;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ pNewData->color = color;
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
- for (int i=0,sz=array.GetSize(); i<sz; i++)
- pNewData->wordarray.Add(array.GetAt(i));
+ for (int i=0,sz=array.GetSize(); i<sz; i++)
+ pNewData->wordarray.Add(array.GetAt(i));
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::AddDelay_WideStringArray(enum FIELD_PROP prop, const CJS_WideStringArray& array)
{
- ASSERT(m_pJSDoc != NULL);
+ ASSERT(m_pJSDoc != NULL);
- CJS_DelayData* pNewData = new CJS_DelayData;
- pNewData->sFieldName = m_FieldName;
- pNewData->nControlIndex = m_nFormControlIndex;
- pNewData->eProp = prop;
- for (int i=0,sz=array.GetSize(); i<sz; i++)
- pNewData->widestringarray.Add(array.GetAt(i));
+ CJS_DelayData* pNewData = new CJS_DelayData;
+ pNewData->sFieldName = m_FieldName;
+ pNewData->nControlIndex = m_nFormControlIndex;
+ pNewData->eProp = prop;
+ for (int i=0,sz=array.GetSize(); i<sz; i++)
+ pNewData->widestringarray.Add(array.GetAt(i));
- m_pJSDoc->AddDelayData(pNewData);
+ m_pJSDoc->AddDelayData(pNewData);
}
void Field::DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData)
{
- ASSERT(pDocument != NULL);
- ASSERT(pData != NULL);
-
- switch (pData->eProp)
- {
- case FP_ALIGNMENT:
- Field::SetAlignment(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
- break;
- case FP_BORDERSTYLE:
- Field::SetBorderStyle(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
- break;
- case FP_BUTTONALIGNX:
- Field::SetButtonAlignX(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_BUTTONALIGNY:
- Field::SetButtonAlignY(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_BUTTONFITBOUNDS:
- Field::SetButtonFitBounds(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_BUTTONPOSITION:
- Field::SetButtonPosition(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_BUTTONSCALEHOW:
- Field::SetButtonScaleHow(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_BUTTONSCALEWHEN:
- Field::SetButtonScaleWhen(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_CALCORDERINDEX:
- Field::SetCalcOrderIndex(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_CHARLIMIT:
- Field::SetCharLimit(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_COMB:
- Field::SetComb(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_COMMITONSELCHANGE:
- Field::SetCommitOnSelChange(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_CURRENTVALUEINDICES:
- Field::SetCurrentValueIndices(pDocument, pData->sFieldName, pData->nControlIndex, pData->wordarray);
- break;
- case FP_DEFAULTVALUE:
- Field::SetDefaultValue(pDocument, pData->sFieldName, pData->nControlIndex, pData->widestring);
- break;
- case FP_DONOTSCROLL:
- Field::SetDoNotScroll(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_DISPLAY:
- Field::SetDisplay(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_FILLCOLOR:
- Field::SetFillColor(pDocument, pData->sFieldName, pData->nControlIndex, pData->color);
- break;
- case FP_HIDDEN:
- Field::SetHidden(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_HIGHLIGHT:
- Field::SetHighlight(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
- break;
- case FP_LINEWIDTH:
- Field::SetLineWidth(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_MULTILINE:
- Field::SetMultiline(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_MULTIPLESELECTION:
- Field::SetMultipleSelection(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_PASSWORD:
- Field::SetPassword(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_RECT:
- Field::SetRect(pDocument, pData->sFieldName, pData->nControlIndex, pData->rect);
- break;
- case FP_RICHTEXT:
- Field::SetRichText(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
- break;
- case FP_RICHVALUE:
- break;
- case FP_ROTATION:
- Field::SetRotation(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_STROKECOLOR:
- Field::SetStrokeColor(pDocument, pData->sFieldName, pData->nControlIndex, pData->color);
- break;
- case FP_STYLE:
- Field::SetStyle(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
- break;
- case FP_TEXTCOLOR:
- Field::SetTextColor(pDocument, pData->sFieldName, pData->nControlIndex, pData->color);
- break;
- case FP_TEXTFONT:
- Field::SetTextFont(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
- break;
- case FP_TEXTSIZE:
- Field::SetTextSize(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
- break;
- case FP_USERNAME:
- Field::SetUserName(pDocument, pData->sFieldName, pData->nControlIndex, pData->widestring);
- break;
- case FP_VALUE:
- Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, pData->widestringarray);
- break;
- }
-}
-
-#define JS_FIELD_MINWIDTH 1
-#define JS_FIELD_MINHEIGHT 1
+ ASSERT(pDocument != NULL);
+ ASSERT(pData != NULL);
+
+ switch (pData->eProp)
+ {
+ case FP_ALIGNMENT:
+ Field::SetAlignment(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
+ break;
+ case FP_BORDERSTYLE:
+ Field::SetBorderStyle(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
+ break;
+ case FP_BUTTONALIGNX:
+ Field::SetButtonAlignX(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_BUTTONALIGNY:
+ Field::SetButtonAlignY(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_BUTTONFITBOUNDS:
+ Field::SetButtonFitBounds(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_BUTTONPOSITION:
+ Field::SetButtonPosition(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_BUTTONSCALEHOW:
+ Field::SetButtonScaleHow(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_BUTTONSCALEWHEN:
+ Field::SetButtonScaleWhen(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_CALCORDERINDEX:
+ Field::SetCalcOrderIndex(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_CHARLIMIT:
+ Field::SetCharLimit(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_COMB:
+ Field::SetComb(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_COMMITONSELCHANGE:
+ Field::SetCommitOnSelChange(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_CURRENTVALUEINDICES:
+ Field::SetCurrentValueIndices(pDocument, pData->sFieldName, pData->nControlIndex, pData->wordarray);
+ break;
+ case FP_DEFAULTVALUE:
+ Field::SetDefaultValue(pDocument, pData->sFieldName, pData->nControlIndex, pData->widestring);
+ break;
+ case FP_DONOTSCROLL:
+ Field::SetDoNotScroll(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_DISPLAY:
+ Field::SetDisplay(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_FILLCOLOR:
+ Field::SetFillColor(pDocument, pData->sFieldName, pData->nControlIndex, pData->color);
+ break;
+ case FP_HIDDEN:
+ Field::SetHidden(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_HIGHLIGHT:
+ Field::SetHighlight(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
+ break;
+ case FP_LINEWIDTH:
+ Field::SetLineWidth(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_MULTILINE:
+ Field::SetMultiline(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_MULTIPLESELECTION:
+ Field::SetMultipleSelection(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_PASSWORD:
+ Field::SetPassword(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_RECT:
+ Field::SetRect(pDocument, pData->sFieldName, pData->nControlIndex, pData->rect);
+ break;
+ case FP_RICHTEXT:
+ Field::SetRichText(pDocument, pData->sFieldName, pData->nControlIndex, pData->b);
+ break;
+ case FP_RICHVALUE:
+ break;
+ case FP_ROTATION:
+ Field::SetRotation(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_STROKECOLOR:
+ Field::SetStrokeColor(pDocument, pData->sFieldName, pData->nControlIndex, pData->color);
+ break;
+ case FP_STYLE:
+ Field::SetStyle(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
+ break;
+ case FP_TEXTCOLOR:
+ Field::SetTextColor(pDocument, pData->sFieldName, pData->nControlIndex, pData->color);
+ break;
+ case FP_TEXTFONT:
+ Field::SetTextFont(pDocument, pData->sFieldName, pData->nControlIndex, pData->string);
+ break;
+ case FP_TEXTSIZE:
+ Field::SetTextSize(pDocument, pData->sFieldName, pData->nControlIndex, pData->num);
+ break;
+ case FP_USERNAME:
+ Field::SetUserName(pDocument, pData->sFieldName, pData->nControlIndex, pData->widestring);
+ break;
+ case FP_VALUE:
+ Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, pData->widestringarray);
+ break;
+ }
+}
+
+#define JS_FIELD_MINWIDTH 1
+#define JS_FIELD_MINHEIGHT 1
void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType,
- const CFX_WideString& sName, const CPDF_Rect& rcCoords)
+ const CFX_WideString& sName, const CPDF_Rect& rcCoords)
{
- //Not supported.
+ //Not supported.
}
diff --git a/fpdfsdk/src/javascript/JS_EventHandler.cpp b/fpdfsdk/src/javascript/JS_EventHandler.cpp
index 7d27c66f6b..1769e3053f 100644
--- a/fpdfsdk/src/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/src/javascript/JS_EventHandler.cpp
@@ -7,7 +7,6 @@
#include "../../include/javascript/JavaScript.h"
#include "../../include/javascript/IJavaScript.h"
#include "../../include/javascript/JS_EventHandler.h"
-//#include "../../include/javascript/JS_ResMgr.h"
#include "../../include/javascript/JS_Context.h"
#include "../../include/javascript/JS_Runtime.h"
#include "../../include/javascript/JS_Define.h"
@@ -18,28 +17,28 @@
/* ---------------------------- CJS_EventHandler ---------------------------- */
-CJS_EventHandler::CJS_EventHandler(CJS_Context * pContext) :
- m_pJSContext(pContext),
- m_eEventType(JET_UNKNOWN),
- m_bValid(FALSE),
- m_pWideStrChange(NULL),
- m_nCommitKey(-1),
- m_bKeyDown(FALSE),
- m_bModifier(FALSE),
- m_bShift(FALSE),
- m_pISelEnd(NULL),
- m_nSelEndDu(0),
- m_pISelStart(NULL),
- m_nSelStartDu(0),
- m_bWillCommit(FALSE),
- m_pValue(NULL),
- m_bFieldFull(FALSE),
- m_pbRc(NULL),
- m_bRcDu(FALSE),
- m_pSourceDoc(NULL),
- m_pTargetBookMark(NULL),
- m_pTargetDoc(NULL),
- m_pTargetAnnot(NULL)
+CJS_EventHandler::CJS_EventHandler(CJS_Context * pContext) :
+ m_pJSContext(pContext),
+ m_eEventType(JET_UNKNOWN),
+ m_bValid(FALSE),
+ m_pWideStrChange(NULL),
+ m_nCommitKey(-1),
+ m_bKeyDown(FALSE),
+ m_bModifier(FALSE),
+ m_bShift(FALSE),
+ m_pISelEnd(NULL),
+ m_nSelEndDu(0),
+ m_pISelStart(NULL),
+ m_nSelStartDu(0),
+ m_bWillCommit(FALSE),
+ m_pValue(NULL),
+ m_bFieldFull(FALSE),
+ m_pbRc(NULL),
+ m_bRcDu(FALSE),
+ m_pSourceDoc(NULL),
+ m_pTargetBookMark(NULL),
+ m_pTargetDoc(NULL),
+ m_pTargetAnnot(NULL)
{
}
@@ -49,629 +48,617 @@ CJS_EventHandler::~CJS_EventHandler()
void CJS_EventHandler::OnApp_Init()
{
- Initial(JET_APP_INIT);
+ Initial(JET_APP_INIT);
}
void CJS_EventHandler::OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName)
{
- Initial(JET_DOC_OPEN);
+ Initial(JET_DOC_OPEN);
- m_pTargetDoc = pDoc;
- m_strTargetName = strTargetName;
+ m_pTargetDoc = pDoc;
+ m_strTargetName = strTargetName;
}
void CJS_EventHandler::OnDoc_WillPrint(CPDFSDK_Document* pDoc)
{
- Initial(JET_DOC_WILLPRINT);
+ Initial(JET_DOC_WILLPRINT);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnDoc_DidPrint(CPDFSDK_Document* pDoc)
{
- Initial(JET_DOC_DIDPRINT);
+ Initial(JET_DOC_DIDPRINT);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnDoc_WillSave(CPDFSDK_Document* pDoc)
{
- Initial(JET_DOC_WILLSAVE);
- m_pTargetDoc = pDoc;
+ Initial(JET_DOC_WILLSAVE);
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnDoc_DidSave(CPDFSDK_Document* pDoc)
{
- Initial(JET_DOC_DIDSAVE);
+ Initial(JET_DOC_DIDSAVE);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnDoc_WillClose(CPDFSDK_Document* pDoc)
{
- Initial(JET_DOC_WILLCLOSE);
+ Initial(JET_DOC_WILLCLOSE);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnPage_Open(CPDFSDK_Document* pDoc)
{
- Initial(JET_PAGE_OPEN);
+ Initial(JET_PAGE_OPEN);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnPage_Close(CPDFSDK_Document* pDoc)
{
- Initial(JET_PAGE_CLOSE);
+ Initial(JET_PAGE_CLOSE);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnPage_InView(CPDFSDK_Document* pDoc)
{
- Initial(JET_PAGE_INVIEW);
+ Initial(JET_PAGE_INVIEW);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnPage_OutView(CPDFSDK_Document* pDoc)
{
- Initial(JET_PAGE_OUTVIEW);
+ Initial(JET_PAGE_OUTVIEW);
- m_pTargetDoc = pDoc;
+ m_pTargetDoc = pDoc;
}
void CJS_EventHandler::OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)
{
- Initial(JET_FIELD_MOUSEENTER);
+ Initial(JET_FIELD_MOUSEENTER);
- m_bModifier = bModifier;
- m_bShift = bShift;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
}
void CJS_EventHandler::OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)
{
- Initial(JET_FIELD_MOUSEEXIT);
+ Initial(JET_FIELD_MOUSEEXIT);
- m_bModifier = bModifier;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
}
void CJS_EventHandler::OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)
{
- Initial(JET_FIELD_MOUSEDOWN);
- m_eEventType = JET_FIELD_MOUSEDOWN;
+ Initial(JET_FIELD_MOUSEDOWN);
+ m_eEventType = JET_FIELD_MOUSEDOWN;
- m_bModifier = bModifier;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
}
void CJS_EventHandler::OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)
{
- Initial(JET_FIELD_MOUSEUP);
+ Initial(JET_FIELD_MOUSEUP);
- m_bModifier = bModifier;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
}
void CJS_EventHandler::OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget,
- const CFX_WideString& Value)
+ const CFX_WideString& Value)
{
- Initial(JET_FIELD_FOCUS);
+ Initial(JET_FIELD_FOCUS);
- m_bModifier = bModifier;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
- m_pValue = (CFX_WideString*)&Value;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
+ m_pValue = (CFX_WideString*)&Value;
}
void CJS_EventHandler::OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget,
- const CFX_WideString& Value)
+ const CFX_WideString& Value)
{
- Initial(JET_FIELD_BLUR);
+ Initial(JET_FIELD_BLUR);
- m_bModifier = bModifier;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
- m_pValue = (CFX_WideString*)&Value;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
+ m_pValue = (CFX_WideString*)&Value;
}
void CJS_EventHandler::OnField_Keystroke(CFX_WideString &strChange,
- const CFX_WideString& strChangeEx, FX_BOOL KeyDown,
- FX_BOOL bModifier, int& nSelEnd, int& nSelStart,
- FX_BOOL bShift, CPDF_FormField* pTarget,
- CFX_WideString& Value, FX_BOOL bWillCommit,
- FX_BOOL bFieldFull, FX_BOOL& bRc)
-{
- Initial(JET_FIELD_KEYSTROKE);
-
- m_nCommitKey = 0;
- m_pWideStrChange = &strChange;
- m_WideStrChangeEx = strChangeEx;
- m_bKeyDown = KeyDown;
- m_bModifier = bModifier;
- m_pISelEnd = &nSelEnd;
- m_pISelStart = &nSelStart;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
- m_bWillCommit = bWillCommit;
- m_pbRc = &bRc;
- m_bFieldFull = bFieldFull;
+ const CFX_WideString& strChangeEx, FX_BOOL KeyDown,
+ FX_BOOL bModifier, int& nSelEnd, int& nSelStart,
+ FX_BOOL bShift, CPDF_FormField* pTarget,
+ CFX_WideString& Value, FX_BOOL bWillCommit,
+ FX_BOOL bFieldFull, FX_BOOL& bRc)
+{
+ Initial(JET_FIELD_KEYSTROKE);
+
+ m_nCommitKey = 0;
+ m_pWideStrChange = &strChange;
+ m_WideStrChangeEx = strChangeEx;
+ m_bKeyDown = KeyDown;
+ m_bModifier = bModifier;
+ m_pISelEnd = &nSelEnd;
+ m_pISelStart = &nSelStart;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
+ m_pValue = &Value;
+ m_bWillCommit = bWillCommit;
+ m_pbRc = &bRc;
+ m_bFieldFull = bFieldFull;
}
void CJS_EventHandler::OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx,
- FX_BOOL bKeyDown, FX_BOOL bModifier, FX_BOOL bShift,
- CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc)
-{
- Initial(JET_FIELD_VALIDATE);
-
- m_pWideStrChange = &strChange;
- m_WideStrChangeEx = strChangeEx;
- m_bKeyDown = bKeyDown;
- m_bModifier = bModifier;
- m_bShift = bShift;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
- m_pbRc = &bRc;
+ FX_BOOL bKeyDown, FX_BOOL bModifier, FX_BOOL bShift,
+ CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc)
+{
+ Initial(JET_FIELD_VALIDATE);
+
+ m_pWideStrChange = &strChange;
+ m_WideStrChangeEx = strChangeEx;
+ m_bKeyDown = bKeyDown;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
+ m_pValue = &Value;
+ m_pbRc = &bRc;
}
void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget,
- CFX_WideString& Value, FX_BOOL& bRc)
+ CFX_WideString& Value, FX_BOOL& bRc)
{
- Initial(JET_FIELD_CALCULATE);
+ Initial(JET_FIELD_CALCULATE);
- if (pSource)
- m_strSourceName = pSource->GetFullName();
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
+ if (pSource)
+ m_strSourceName = pSource->GetFullName();
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
m_pValue = &Value;
- m_pbRc = &bRc;
+ m_pbRc = &bRc;
}
void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget,
CFX_WideString& Value,
FX_BOOL bWillCommit)
{
- Initial(JET_FIELD_FORMAT);
+ Initial(JET_FIELD_FORMAT);
- m_nCommitKey = 0;
- ASSERT(pTarget != NULL);
- m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
- m_bWillCommit = bWillCommit;
+ m_nCommitKey = 0;
+ ASSERT(pTarget != NULL);
+ m_strTargetName = pTarget->GetFullName();
+ m_pValue = &Value;
+ m_bWillCommit = bWillCommit;
}
void CJS_EventHandler::OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_FOCUS);
+ Initial(JET_SCREEN_FOCUS);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_BLUR);
+ Initial(JET_SCREEN_BLUR);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_OPEN);
+ Initial(JET_SCREEN_OPEN);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_CLOSE);
+ Initial(JET_SCREEN_CLOSE);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_MOUSEDOWN);
+ Initial(JET_SCREEN_MOUSEDOWN);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_MOUSEUP);
+ Initial(JET_SCREEN_MOUSEUP);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_MOUSEENTER);
+ Initial(JET_SCREEN_MOUSEENTER);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_MOUSEEXIT);
+ Initial(JET_SCREEN_MOUSEEXIT);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_INVIEW);
+ Initial(JET_SCREEN_INVIEW);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)
{
- Initial(JET_SCREEN_OUTVIEW);
+ Initial(JET_SCREEN_OUTVIEW);
- m_bModifier = bModifier;
- m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_bModifier = bModifier;
+ m_bShift = bShift;
+ m_pTargetAnnot = pScreen;
}
void CJS_EventHandler::OnLink_MouseUp(CPDFSDK_Document* pTarget)
{
- Initial(JET_LINK_MOUSEUP);
+ Initial(JET_LINK_MOUSEUP);
- m_pTargetDoc = pTarget;
+ m_pTargetDoc = pTarget;
}
void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark)
{
- Initial(JET_BOOKMARK_MOUSEUP);
+ Initial(JET_BOOKMARK_MOUSEUP);
- m_pTargetBookMark = pBookMark;
+ m_pTargetBookMark = pBookMark;
}
void CJS_EventHandler::OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName)
{
- Initial(JET_MENU_EXEC);
+ Initial(JET_MENU_EXEC);
- m_pTargetDoc = pTarget;
- m_strTargetName = strTargetName;
+ m_pTargetDoc = pTarget;
+ m_strTargetName = strTargetName;
}
void CJS_EventHandler::OnExternal_Exec()
{
- Initial(JET_EXTERNAL_EXEC);
+ Initial(JET_EXTERNAL_EXEC);
}
void CJS_EventHandler::OnBatchExec(CPDFSDK_Document* pTarget)
{
- Initial(JET_BATCH_EXEC);
+ Initial(JET_BATCH_EXEC);
- m_pTargetDoc = pTarget;
+ m_pTargetDoc = pTarget;
}
void CJS_EventHandler::OnConsole_Exec()
{
- Initial(JET_CONSOLE_EXEC);
+ Initial(JET_CONSOLE_EXEC);
}
void CJS_EventHandler::Initial(JS_EVENT_T type)
{
- m_eEventType = type;
-
- m_strTargetName = L"";
- m_strSourceName = L"";
- m_pWideStrChange = NULL;
- m_WideStrChangeDu = L"";
- m_WideStrChangeEx = L"";
- m_nCommitKey = -1;
- m_bKeyDown = FALSE;
- m_bModifier = FALSE;
- m_bShift = FALSE;
- m_pISelEnd = NULL;
- m_nSelEndDu = 0;
- m_pISelStart = NULL;
- m_nSelStartDu = 0;
- m_bWillCommit = FALSE;
- m_pValue = NULL;
- m_bFieldFull = FALSE;
- m_pbRc = NULL;
- m_bRcDu = FALSE;
-
- m_pSourceDoc = NULL;
- m_pTargetBookMark = NULL;
- m_pTargetDoc = NULL;
- m_pTargetAnnot = NULL;
-
- m_bValid = TRUE;
+ m_eEventType = type;
+
+ m_strTargetName = L"";
+ m_strSourceName = L"";
+ m_pWideStrChange = NULL;
+ m_WideStrChangeDu = L"";
+ m_WideStrChangeEx = L"";
+ m_nCommitKey = -1;
+ m_bKeyDown = FALSE;
+ m_bModifier = FALSE;
+ m_bShift = FALSE;
+ m_pISelEnd = NULL;
+ m_nSelEndDu = 0;
+ m_pISelStart = NULL;
+ m_nSelStartDu = 0;
+ m_bWillCommit = FALSE;
+ m_pValue = NULL;
+ m_bFieldFull = FALSE;
+ m_pbRc = NULL;
+ m_bRcDu = FALSE;
+
+ m_pSourceDoc = NULL;
+ m_pTargetBookMark = NULL;
+ m_pTargetDoc = NULL;
+ m_pTargetAnnot = NULL;
+
+ m_bValid = TRUE;
}
void CJS_EventHandler::Destroy()
{
- m_bValid = FALSE;
+ m_bValid = FALSE;
}
FX_BOOL CJS_EventHandler::IsValid()
{
- return m_bValid;
+ return m_bValid;
}
CFX_WideString & CJS_EventHandler::Change()
{
- if (m_pWideStrChange != NULL)
- return *m_pWideStrChange;
- else
- {
- return m_WideStrChangeDu;
- }
+ if (m_pWideStrChange) {
+ return *m_pWideStrChange;
+ }
+ return m_WideStrChangeDu;
}
CFX_WideString CJS_EventHandler::ChangeEx()
{
- return m_WideStrChangeEx;
+ return m_WideStrChangeEx;
}
int CJS_EventHandler::CommitKey()
{
- return m_nCommitKey;
+ return m_nCommitKey;
}
FX_BOOL CJS_EventHandler::FieldFull()
{
- return m_bFieldFull;
+ return m_bFieldFull;
}
FX_BOOL CJS_EventHandler::KeyDown()
{
- return m_bKeyDown;
+ return m_bKeyDown;
}
FX_BOOL CJS_EventHandler::Modifier()
{
- return m_bModifier;
+ return m_bModifier;
}
const FX_WCHAR* CJS_EventHandler::Name()
{
- switch (m_eEventType)
- {
- case JET_APP_INIT: return L"Init";
- case JET_BATCH_EXEC: return L"Exec";
- case JET_BOOKMARK_MOUSEUP: return L"Mouse Up";
- case JET_CONSOLE_EXEC: return L"Exec";
- case JET_DOC_DIDPRINT: return L"DidPrint";
- case JET_DOC_DIDSAVE: return L"DidSave";
- case JET_DOC_OPEN: return L"Open";
- case JET_DOC_WILLCLOSE: return L"WillClose";
- case JET_DOC_WILLPRINT: return L"WillPrint";
- case JET_DOC_WILLSAVE: return L"WillSave";
- case JET_EXTERNAL_EXEC: return L"Exec";
- case JET_FIELD_FOCUS:
- case JET_SCREEN_FOCUS: return L"Focus";
- case JET_FIELD_BLUR:
- case JET_SCREEN_BLUR: return L"Blur";
- case JET_FIELD_MOUSEDOWN:
- case JET_SCREEN_MOUSEDOWN: return L"Mouse Down";
- case JET_FIELD_MOUSEUP:
- case JET_SCREEN_MOUSEUP: return L"Mouse Up";
- case JET_FIELD_MOUSEENTER:
- case JET_SCREEN_MOUSEENTER: return L"Mouse Enter";
- case JET_FIELD_MOUSEEXIT:
- case JET_SCREEN_MOUSEEXIT: return L"Mouse Exit";
- case JET_FIELD_CALCULATE: return L"Calculate";
- case JET_FIELD_FORMAT: return L"Format";
- case JET_FIELD_KEYSTROKE: return L"Keystroke";
- case JET_FIELD_VALIDATE: return L"Validate";
- case JET_LINK_MOUSEUP: return L"Mouse Up";
- case JET_MENU_EXEC: return L"Exec";
- case JET_PAGE_OPEN:
- case JET_SCREEN_OPEN: return L"Open";
- case JET_PAGE_CLOSE:
- case JET_SCREEN_CLOSE: return L"Close";
- case JET_SCREEN_INVIEW:
- case JET_PAGE_INVIEW: return L"InView";
- case JET_PAGE_OUTVIEW:
- case JET_SCREEN_OUTVIEW: return L"OutView";
- default:
- return L"";
- }
-
- return L"";
+ switch (m_eEventType)
+ {
+ case JET_APP_INIT: return L"Init";
+ case JET_BATCH_EXEC: return L"Exec";
+ case JET_BOOKMARK_MOUSEUP: return L"Mouse Up";
+ case JET_CONSOLE_EXEC: return L"Exec";
+ case JET_DOC_DIDPRINT: return L"DidPrint";
+ case JET_DOC_DIDSAVE: return L"DidSave";
+ case JET_DOC_OPEN: return L"Open";
+ case JET_DOC_WILLCLOSE: return L"WillClose";
+ case JET_DOC_WILLPRINT: return L"WillPrint";
+ case JET_DOC_WILLSAVE: return L"WillSave";
+ case JET_EXTERNAL_EXEC: return L"Exec";
+ case JET_FIELD_FOCUS:
+ case JET_SCREEN_FOCUS: return L"Focus";
+ case JET_FIELD_BLUR:
+ case JET_SCREEN_BLUR: return L"Blur";
+ case JET_FIELD_MOUSEDOWN:
+ case JET_SCREEN_MOUSEDOWN: return L"Mouse Down";
+ case JET_FIELD_MOUSEUP:
+ case JET_SCREEN_MOUSEUP: return L"Mouse Up";
+ case JET_FIELD_MOUSEENTER:
+ case JET_SCREEN_MOUSEENTER: return L"Mouse Enter";
+ case JET_FIELD_MOUSEEXIT:
+ case JET_SCREEN_MOUSEEXIT: return L"Mouse Exit";
+ case JET_FIELD_CALCULATE: return L"Calculate";
+ case JET_FIELD_FORMAT: return L"Format";
+ case JET_FIELD_KEYSTROKE: return L"Keystroke";
+ case JET_FIELD_VALIDATE: return L"Validate";
+ case JET_LINK_MOUSEUP: return L"Mouse Up";
+ case JET_MENU_EXEC: return L"Exec";
+ case JET_PAGE_OPEN:
+ case JET_SCREEN_OPEN: return L"Open";
+ case JET_PAGE_CLOSE:
+ case JET_SCREEN_CLOSE: return L"Close";
+ case JET_SCREEN_INVIEW:
+ case JET_PAGE_INVIEW: return L"InView";
+ case JET_PAGE_OUTVIEW:
+ case JET_SCREEN_OUTVIEW: return L"OutView";
+ default:
+ return L"";
+ }
+
+ return L"";
}
const FX_WCHAR* CJS_EventHandler::Type()
{
- switch (m_eEventType)
- {
- case JET_APP_INIT: return L"App";
- case JET_BATCH_EXEC: return L"Batch";
- case JET_BOOKMARK_MOUSEUP: return L"BookMark";
- case JET_CONSOLE_EXEC: return L"Console";
- case JET_DOC_DIDPRINT:
- case JET_DOC_DIDSAVE:
- case JET_DOC_OPEN:
- case JET_DOC_WILLCLOSE:
- case JET_DOC_WILLPRINT:
- case JET_DOC_WILLSAVE: return L"Doc";
- case JET_EXTERNAL_EXEC: return L"External";
- case JET_FIELD_BLUR:
- case JET_FIELD_FOCUS:
- case JET_FIELD_MOUSEDOWN:
- case JET_FIELD_MOUSEENTER:
- case JET_FIELD_MOUSEEXIT:
- case JET_FIELD_MOUSEUP:
- case JET_FIELD_CALCULATE:
- case JET_FIELD_FORMAT:
- case JET_FIELD_KEYSTROKE:
- case JET_FIELD_VALIDATE: return L"Field";
- case JET_SCREEN_FOCUS:
- case JET_SCREEN_BLUR:
- case JET_SCREEN_OPEN:
- case JET_SCREEN_CLOSE:
- case JET_SCREEN_MOUSEDOWN:
- case JET_SCREEN_MOUSEUP:
- case JET_SCREEN_MOUSEENTER:
- case JET_SCREEN_MOUSEEXIT:
- case JET_SCREEN_INVIEW:
- case JET_SCREEN_OUTVIEW: return L"Screen";
- case JET_LINK_MOUSEUP: return L"Link";
- case JET_MENU_EXEC: return L"Menu";
- case JET_PAGE_OPEN:
- case JET_PAGE_CLOSE:
- case JET_PAGE_INVIEW:
- case JET_PAGE_OUTVIEW:return L"Page";
- default:
- return L"";
- }
-
- return L"";
+ switch (m_eEventType)
+ {
+ case JET_APP_INIT: return L"App";
+ case JET_BATCH_EXEC: return L"Batch";
+ case JET_BOOKMARK_MOUSEUP: return L"BookMark";
+ case JET_CONSOLE_EXEC: return L"Console";
+ case JET_DOC_DIDPRINT:
+ case JET_DOC_DIDSAVE:
+ case JET_DOC_OPEN:
+ case JET_DOC_WILLCLOSE:
+ case JET_DOC_WILLPRINT:
+ case JET_DOC_WILLSAVE: return L"Doc";
+ case JET_EXTERNAL_EXEC: return L"External";
+ case JET_FIELD_BLUR:
+ case JET_FIELD_FOCUS:
+ case JET_FIELD_MOUSEDOWN:
+ case JET_FIELD_MOUSEENTER:
+ case JET_FIELD_MOUSEEXIT:
+ case JET_FIELD_MOUSEUP:
+ case JET_FIELD_CALCULATE:
+ case JET_FIELD_FORMAT:
+ case JET_FIELD_KEYSTROKE:
+ case JET_FIELD_VALIDATE: return L"Field";
+ case JET_SCREEN_FOCUS:
+ case JET_SCREEN_BLUR:
+ case JET_SCREEN_OPEN:
+ case JET_SCREEN_CLOSE:
+ case JET_SCREEN_MOUSEDOWN:
+ case JET_SCREEN_MOUSEUP:
+ case JET_SCREEN_MOUSEENTER:
+ case JET_SCREEN_MOUSEEXIT:
+ case JET_SCREEN_INVIEW:
+ case JET_SCREEN_OUTVIEW: return L"Screen";
+ case JET_LINK_MOUSEUP: return L"Link";
+ case JET_MENU_EXEC: return L"Menu";
+ case JET_PAGE_OPEN:
+ case JET_PAGE_CLOSE:
+ case JET_PAGE_INVIEW:
+ case JET_PAGE_OUTVIEW:return L"Page";
+ default:
+ return L"";
+ }
+
+ return L"";
}
FX_BOOL& CJS_EventHandler::Rc()
{
- if (m_pbRc != NULL)
- return *m_pbRc;
- else
- {
- return m_bRcDu;
- }
+ if (m_pbRc) {
+ return *m_pbRc;
+ }
+ return m_bRcDu;
}
int & CJS_EventHandler::SelEnd()
{
- if (m_pISelEnd != NULL)
- {
- return *m_pISelEnd;
- }
- else
- {
- return m_nSelEndDu;
- }
+ if (m_pISelEnd) {
+ return *m_pISelEnd;
+ }
+ return m_nSelEndDu;
}
int & CJS_EventHandler::SelStart()
{
- if (m_pISelStart != NULL)
- return * m_pISelStart;
- else
- {
- return m_nSelStartDu;
- }
+ if (m_pISelStart) {
+ return *m_pISelStart;
+ }
+ return m_nSelStartDu;
}
FX_BOOL CJS_EventHandler::Shift()
{
- return m_bShift;
+ return m_bShift;
}
Field* CJS_EventHandler::Source()
{
- ASSERT(m_pJSContext != NULL);
-
- CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
-
- JSFXObject pDocObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));
- ASSERT(pDocObj.IsEmpty() == FALSE);
- JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));
- ASSERT(pFieldObj.IsEmpty() == FALSE);
-
- CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);
- ASSERT(pJSDocument != NULL);
- Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
- ASSERT(pDocument != NULL);
- if (m_pTargetDoc != NULL)
- pDocument->AttachDoc(m_pTargetDoc);
- else
- pDocument->AttachDoc(m_pJSContext->GetReaderDocument());
-
- //if (m_pSourceField == NULL)
- // return NULL;
- //CRAO_Widget *pWidget = IBCL_Widget::GetWidget(m_pSourceField);
- //CPDF_FormField* pFormField = pWidget->GetFormField();
- //ASSERT(pFormField);
- //CFX_WideString csFieldName = pFormField->GetFullName();
- CJS_Field * pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj);
- ASSERT(pJSField != NULL);
- Field * pField = (Field *)pJSField->GetEmbedObject();
- ASSERT(pField != NULL);
- pField->AttachField(pDocument, m_strSourceName);
- return pField;
+ ASSERT(m_pJSContext != NULL);
+
+ CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
+
+ JSFXObject pDocObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));
+ ASSERT(pDocObj.IsEmpty() == FALSE);
+ JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+ ASSERT(pFieldObj.IsEmpty() == FALSE);
+
+ CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);
+ ASSERT(pJSDocument != NULL);
+ Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
+ ASSERT(pDocument != NULL);
+ if (m_pTargetDoc != NULL)
+ pDocument->AttachDoc(m_pTargetDoc);
+ else
+ pDocument->AttachDoc(m_pJSContext->GetReaderDocument());
+
+ //if (m_pSourceField == NULL)
+ // return NULL;
+ //CRAO_Widget *pWidget = IBCL_Widget::GetWidget(m_pSourceField);
+ //CPDF_FormField* pFormField = pWidget->GetFormField();
+ //ASSERT(pFormField);
+ //CFX_WideString csFieldName = pFormField->GetFullName();
+ CJS_Field * pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj);
+ ASSERT(pJSField != NULL);
+ Field * pField = (Field *)pJSField->GetEmbedObject();
+ ASSERT(pField != NULL);
+ pField->AttachField(pDocument, m_strSourceName);
+ return pField;
}
Field* CJS_EventHandler::Target_Field()
{
- ASSERT(m_pJSContext != NULL);
+ ASSERT(m_pJSContext != NULL);
- CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
+ CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
- JSFXObject pDocObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));
- ASSERT(pDocObj.IsEmpty() == FALSE);
- JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));
- ASSERT(pFieldObj.IsEmpty() == FALSE);
+ JSFXObject pDocObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));
+ ASSERT(pDocObj.IsEmpty() == FALSE);
+ JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+ ASSERT(pFieldObj.IsEmpty() == FALSE);
- CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);
- ASSERT(pJSDocument != NULL);
- Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
- ASSERT(pDocument != NULL);
- if (m_pTargetDoc != NULL)
- pDocument->AttachDoc(m_pTargetDoc);
- else
- pDocument->AttachDoc(m_pJSContext->GetReaderDocument());
+ CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);
+ ASSERT(pJSDocument != NULL);
+ Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
+ ASSERT(pDocument != NULL);
+ if (m_pTargetDoc != NULL)
+ pDocument->AttachDoc(m_pTargetDoc);
+ else
+ pDocument->AttachDoc(m_pJSContext->GetReaderDocument());
- CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj);
- ASSERT(pJSField != NULL);
+ CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj);
+ ASSERT(pJSField != NULL);
- Field* pField = (Field *)pJSField->GetEmbedObject();
- ASSERT(pField != NULL);
+ Field* pField = (Field *)pJSField->GetEmbedObject();
+ ASSERT(pField != NULL);
- pField->AttachField(pDocument, m_strTargetName);
- return pField;
+ pField->AttachField(pDocument, m_strTargetName);
+ return pField;
}
CFX_WideString& CJS_EventHandler::Value()
{
- return *m_pValue;
+ return *m_pValue;
}
FX_BOOL CJS_EventHandler::WillCommit()
{
- return m_bWillCommit;
+ return m_bWillCommit;
}
CFX_WideString CJS_EventHandler::TargetName()
{
- return m_strTargetName;
+ return m_strTargetName;
}
-
-
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp
index 2ba5c3bca5..8c7bd7150e 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.cpp
+++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp
@@ -9,7 +9,7 @@
#include "../../include/javascript/IJavaScript.h"
#include "../../include/javascript/JS_GlobalData.h"
-#define JS_MAXGLOBALDATA (1024 * 4 - 8)
+#define JS_MAXGLOBALDATA (1024 * 4 - 8)
/* --------------------- CJS_GlobalVariableArray --------------------- */
@@ -19,497 +19,495 @@ CJS_GlobalVariableArray::CJS_GlobalVariableArray()
CJS_GlobalVariableArray::~CJS_GlobalVariableArray()
{
- Empty();
+ Empty();
}
void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array)
{
- Empty();
- for (int i=0,sz=array.Count(); i<sz; i++)
- {
- CJS_KeyValue* pOldObjData = array.GetAt(i);
- ASSERT(pOldObjData != NULL);
-
- switch (pOldObjData->nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- {
- CJS_KeyValue* pNewObjData = new CJS_KeyValue;
- pNewObjData->sKey = pOldObjData->sKey;
- pNewObjData->nType = pOldObjData->nType;
- pNewObjData->dData = pOldObjData->dData;
- Add(pNewObjData);
- }
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- {
- CJS_KeyValue* pNewObjData = new CJS_KeyValue;
- pNewObjData->sKey = pOldObjData->sKey;
- pNewObjData->nType = pOldObjData->nType;
- pNewObjData->bData = pOldObjData->bData;
- Add(pNewObjData);
- }
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- {
- CJS_KeyValue* pNewObjData = new CJS_KeyValue;
- pNewObjData->sKey = pOldObjData->sKey;
- pNewObjData->nType = pOldObjData->nType;
- pNewObjData->sData = pOldObjData->sData;
- Add(pNewObjData);
- }
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- {
- CJS_KeyValue* pNewObjData = new CJS_KeyValue;
- pNewObjData->sKey = pOldObjData->sKey;
- pNewObjData->nType = pOldObjData->nType;
- pNewObjData->objData.Copy(pOldObjData->objData);
- Add(pNewObjData);
- }
- case JS_GLOBALDATA_TYPE_NULL:
- {
- CJS_KeyValue* pNewObjData = new CJS_KeyValue;
- pNewObjData->sKey = pOldObjData->sKey;
- pNewObjData->nType = pOldObjData->nType;
- Add(pNewObjData);
- }
- }
- }
+ Empty();
+ for (int i=0,sz=array.Count(); i<sz; i++)
+ {
+ CJS_KeyValue* pOldObjData = array.GetAt(i);
+ ASSERT(pOldObjData != NULL);
+
+ switch (pOldObjData->nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->dData = pOldObjData->dData;
+ Add(pNewObjData);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->bData = pOldObjData->bData;
+ Add(pNewObjData);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->sData = pOldObjData->sData;
+ Add(pNewObjData);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->objData.Copy(pOldObjData->objData);
+ Add(pNewObjData);
+ }
+ case JS_GLOBALDATA_TYPE_NULL:
+ {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ Add(pNewObjData);
+ }
+ }
+ }
}
void CJS_GlobalVariableArray::Add(CJS_KeyValue* p)
{
- array.Add(p);
+ array.Add(p);
}
int CJS_GlobalVariableArray::Count() const
{
- return array.GetSize();
+ return array.GetSize();
}
CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const
{
- return array.GetAt(index);
+ return array.GetAt(index);
}
void CJS_GlobalVariableArray::Empty()
{
- for (int i=0,sz=array.GetSize(); i<sz; i++)
- delete array.GetAt(i);
- array.RemoveAll();
+ for (int i=0,sz=array.GetSize(); i<sz; i++)
+ delete array.GetAt(i);
+ array.RemoveAll();
}
/* -------------------------- CJS_GlobalData -------------------------- */
-#define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data"
-#define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data"
-#define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data"
+#define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data"
+#define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data"
+#define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data"
static const uint8_t JS_RC4KEY[] = {0x19,0xa8,0xe8,0x01,0xf6,0xa8,0xb6,0x4d,0x82,0x04,
- 0x45,0x6d,0xb4,0xcf,0xd7,0x77,0x67,0xf9,0x75,0x9f,
- 0xf0,0xe0,0x1e,0x51,0xee,0x46,0xfd,0x0b,0xc9,0x93,
- 0x25,0x55,0x4a,0xee,0xe0,0x16,0xd0,0xdf,0x8c,0xfa,
- 0x2a,0xa9,0x49,0xfd,0x97,0x1c,0x0e,0x22,0x13,0x28,
- 0x7c,0xaf,0xc4,0xfc,0x9c,0x12,0x65,0x8c,0x4e,0x5b,
- 0x04,0x75,0x89,0xc9,0xb1,0xed,0x50,0xca,0x96,0x6f,
- 0x1a,0x7a,0xfe,0x58,0x5d,0xec,0x19,0x4a,0xf6,0x35,
- 0x6a,0x97,0x14,0x00,0x0e,0xd0,0x6b,0xbb,0xd5,0x75,
- 0x55,0x8b,0x6e,0x6b,0x19,0xa0,0xf8,0x77,0xd5,0xa3
- };
+ 0x45,0x6d,0xb4,0xcf,0xd7,0x77,0x67,0xf9,0x75,0x9f,
+ 0xf0,0xe0,0x1e,0x51,0xee,0x46,0xfd,0x0b,0xc9,0x93,
+ 0x25,0x55,0x4a,0xee,0xe0,0x16,0xd0,0xdf,0x8c,0xfa,
+ 0x2a,0xa9,0x49,0xfd,0x97,0x1c,0x0e,0x22,0x13,0x28,
+ 0x7c,0xaf,0xc4,0xfc,0x9c,0x12,0x65,0x8c,0x4e,0x5b,
+ 0x04,0x75,0x89,0xc9,0xb1,0xed,0x50,0xca,0x96,0x6f,
+ 0x1a,0x7a,0xfe,0x58,0x5d,0xec,0x19,0x4a,0xf6,0x35,
+ 0x6a,0x97,0x14,0x00,0x0e,0xd0,0x6b,0xbb,0xd5,0x75,
+ 0x55,0x8b,0x6e,0x6b,0x19,0xa0,0xf8,0x77,0xd5,0xa3
+ };
CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp)
{
-// IBaseAnnot* pBaseAnnot = IBaseAnnot::GetBaseAnnot(m_pApp);
-// ASSERT(pBaseAnnot != NULL);
+// IBaseAnnot* pBaseAnnot = IBaseAnnot::GetBaseAnnot(m_pApp);
+// ASSERT(pBaseAnnot != NULL);
//
-// m_sFilePath = pBaseAnnot->GetUserPath();
- m_sFilePath += SDK_JS_GLOBALDATA_FILENAME;
+// m_sFilePath = pBaseAnnot->GetUserPath();
+ m_sFilePath += SDK_JS_GLOBALDATA_FILENAME;
- LoadGlobalPersistentVariables();
+ LoadGlobalPersistentVariables();
}
CJS_GlobalData::~CJS_GlobalData()
{
- SaveGlobalPersisitentVariables();
+ SaveGlobalPersisitentVariables();
- for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
- delete m_arrayGlobalData.GetAt(i);
+ for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
+ delete m_arrayGlobalData.GetAt(i);
- m_arrayGlobalData.RemoveAll();
+ m_arrayGlobalData.RemoveAll();
}
-int CJS_GlobalData::FindGlobalVariable(const FX_CHAR* propname)
+int CJS_GlobalData::FindGlobalVariable(const FX_CHAR* propname)
{
- ASSERT(propname != NULL);
+ ASSERT(propname != NULL);
- int nRet = -1;
+ int nRet = -1;
- for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
- {
- CJS_GlobalData_Element* pTemp = m_arrayGlobalData.GetAt(i);
- if (pTemp->data.sKey[0] == *propname && pTemp->data.sKey == propname)
- {
- nRet = i;
- break;
- }
- }
+ for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
+ {
+ CJS_GlobalData_Element* pTemp = m_arrayGlobalData.GetAt(i);
+ if (pTemp->data.sKey[0] == *propname && pTemp->data.sKey == propname)
+ {
+ nRet = i;
+ break;
+ }
+ }
- return nRet;
+ return nRet;
}
CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(const FX_CHAR* propname)
{
- ASSERT(propname != NULL);
+ ASSERT(propname != NULL);
- int nFind = FindGlobalVariable(propname);
+ int nFind = FindGlobalVariable(propname);
+ if (nFind >= 0)
+ return m_arrayGlobalData.GetAt(nFind);
- if (nFind >= 0)
- return m_arrayGlobalData.GetAt(nFind);
- else
- return NULL;
+ return NULL;
}
void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname, double dData)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
-
- sPropName.TrimLeft();
- sPropName.TrimRight();
-
- if (sPropName.GetLength() == 0) return;
-
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
- {
- pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER;
- pData->data.dData = dData;
- }
- else
- {
- CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
- pNewData->data.sKey = sPropName;
- pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER;
- pNewData->data.dData = dData;
-
- m_arrayGlobalData.Add(pNewData);
- }
+ ASSERT(propname != NULL);
+
+ CFX_ByteString sPropName = propname;
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
+ if (sPropName.GetLength() == 0)
+ return;
+
+ if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
+ {
+ pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER;
+ pData->data.dData = dData;
+ }
+ else
+ {
+ CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
+ pNewData->data.sKey = sPropName;
+ pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER;
+ pNewData->data.dData = dData;
+ m_arrayGlobalData.Add(pNewData);
+ }
}
void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
-
- sPropName.TrimLeft();
- sPropName.TrimRight();
-
- if (sPropName.GetLength() == 0) return;
-
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
- {
- pData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN;
- pData->data.bData = bData;
- }
- else
- {
- CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
- pNewData->data.sKey = sPropName;
- pNewData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN;
- pNewData->data.bData = bData;
-
- m_arrayGlobalData.Add(pNewData);
- }
+ ASSERT(propname != NULL);
+ CFX_ByteString sPropName = propname;
+
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
+
+ if (sPropName.GetLength() == 0) return;
+
+ if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
+ {
+ pData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN;
+ pData->data.bData = bData;
+ }
+ else
+ {
+ CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
+ pNewData->data.sKey = sPropName;
+ pNewData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN;
+ pNewData->data.bData = bData;
+
+ m_arrayGlobalData.Add(pNewData);
+ }
}
void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname, const CFX_ByteString& sData)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
-
- sPropName.TrimLeft();
- sPropName.TrimRight();
-
- if (sPropName.GetLength() == 0) return;
-
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
- {
- pData->data.nType = JS_GLOBALDATA_TYPE_STRING;
- pData->data.sData = sData;
- }
- else
- {
- CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
- pNewData->data.sKey = sPropName;
- pNewData->data.nType = JS_GLOBALDATA_TYPE_STRING;
- pNewData->data.sData = sData;
-
- m_arrayGlobalData.Add(pNewData);
- }
+ ASSERT(propname != NULL);
+ CFX_ByteString sPropName = propname;
+
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
+
+ if (sPropName.GetLength() == 0) return;
+
+ if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
+ {
+ pData->data.nType = JS_GLOBALDATA_TYPE_STRING;
+ pData->data.sData = sData;
+ }
+ else
+ {
+ CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
+ pNewData->data.sKey = sPropName;
+ pNewData->data.nType = JS_GLOBALDATA_TYPE_STRING;
+ pNewData->data.sData = sData;
+
+ m_arrayGlobalData.Add(pNewData);
+ }
}
void CJS_GlobalData::SetGlobalVariableObject(const FX_CHAR* propname, const CJS_GlobalVariableArray& array)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
-
- sPropName.TrimLeft();
- sPropName.TrimRight();
-
- if (sPropName.GetLength() == 0) return;
-
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
- {
- pData->data.nType = JS_GLOBALDATA_TYPE_OBJECT;
- pData->data.objData.Copy(array);
- }
- else
- {
- CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
- pNewData->data.sKey = sPropName;
- pNewData->data.nType = JS_GLOBALDATA_TYPE_OBJECT;
- pNewData->data.objData.Copy(array);
-
- m_arrayGlobalData.Add(pNewData);
- }
+ ASSERT(propname != NULL);
+ CFX_ByteString sPropName = propname;
+
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
+
+ if (sPropName.GetLength() == 0) return;
+
+ if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
+ {
+ pData->data.nType = JS_GLOBALDATA_TYPE_OBJECT;
+ pData->data.objData.Copy(array);
+ }
+ else
+ {
+ CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
+ pNewData->data.sKey = sPropName;
+ pNewData->data.nType = JS_GLOBALDATA_TYPE_OBJECT;
+ pNewData->data.objData.Copy(array);
+
+ m_arrayGlobalData.Add(pNewData);
+ }
}
void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
-
- sPropName.TrimLeft();
- sPropName.TrimRight();
-
- if (sPropName.GetLength() == 0) return;
-
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
- {
- pData->data.nType = JS_GLOBALDATA_TYPE_NULL;
- }
- else
- {
- CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
- pNewData->data.sKey = sPropName;
- pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL;
-
- m_arrayGlobalData.Add(pNewData);
- }
+ ASSERT(propname != NULL);
+ CFX_ByteString sPropName = propname;
+
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
+
+ if (sPropName.GetLength() == 0) return;
+
+ if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
+ {
+ pData->data.nType = JS_GLOBALDATA_TYPE_NULL;
+ }
+ else
+ {
+ CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
+ pNewData->data.sKey = sPropName;
+ pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL;
+
+ m_arrayGlobalData.Add(pNewData);
+ }
}
FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, FX_BOOL bPersistent)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
+ ASSERT(propname != NULL);
+ CFX_ByteString sPropName = propname;
- sPropName.TrimLeft();
- sPropName.TrimRight();
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
- if (sPropName.GetLength() == 0) return FALSE;
+ if (sPropName.GetLength() == 0) return FALSE;
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
- {
- pData->bPersistent = bPersistent;
- return TRUE;
- }
+ if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
+ {
+ pData->bPersistent = bPersistent;
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const FX_CHAR* propname)
{
- ASSERT(propname != NULL);
- CFX_ByteString sPropName = propname;
+ ASSERT(propname != NULL);
+ CFX_ByteString sPropName = propname;
- sPropName.TrimLeft();
- sPropName.TrimRight();
+ sPropName.TrimLeft();
+ sPropName.TrimRight();
- if (sPropName.GetLength() == 0) return FALSE;
+ if (sPropName.GetLength() == 0) return FALSE;
- int nFind = FindGlobalVariable(sPropName);
+ int nFind = FindGlobalVariable(sPropName);
- if (nFind >= 0)
- {
- delete m_arrayGlobalData.GetAt(nFind);
- m_arrayGlobalData.RemoveAt(nFind);
- return TRUE;
- }
+ if (nFind >= 0)
+ {
+ delete m_arrayGlobalData.GetAt(nFind);
+ m_arrayGlobalData.RemoveAt(nFind);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
int32_t CJS_GlobalData::GetSize() const
{
- return m_arrayGlobalData.GetSize();
+ return m_arrayGlobalData.GetSize();
}
CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const
{
- return m_arrayGlobalData.GetAt(index);
+ return m_arrayGlobalData.GetAt(index);
}
void CJS_GlobalData::LoadGlobalPersistentVariables()
{
- uint8_t* pBuffer = NULL;
- int32_t nLength = 0;
-
- LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength);
- CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY));
-
- if (pBuffer)
- {
- uint8_t* p = pBuffer;
- FX_WORD wType = *((FX_WORD*)p);
- p += sizeof(FX_WORD);
-
- //FX_WORD wTemp = (FX_WORD)(('X' << 8) | 'F');
-
- if (wType == (FX_WORD)(('X' << 8) | 'F'))
- {
- FX_WORD wVersion = *((FX_WORD*)p);
- p += sizeof(FX_WORD);
-
- ASSERT(wVersion <= 2);
-
- FX_DWORD dwCount = *((FX_DWORD*)p);
- p += sizeof(FX_DWORD);
-
- FX_DWORD dwSize = *((FX_DWORD*)p);
- p += sizeof(FX_DWORD);
-
- if (dwSize == nLength - sizeof(FX_WORD) * 2 - sizeof(FX_DWORD)* 2)
- {
- for (int32_t i=0,sz=dwCount; i<sz; i++)
- {
- if (p > pBuffer + nLength)
- break;
-
- FX_DWORD dwNameLen = *((FX_DWORD*)p);
- p += sizeof(FX_DWORD);
-
- if (p + dwNameLen > pBuffer + nLength)
- break;
-
- CFX_ByteString sEntry = CFX_ByteString(p, dwNameLen);
- p += sizeof(char) * dwNameLen;
-
- FX_WORD wDataType = *((FX_WORD*)p);
- p += sizeof(FX_WORD);
-
- switch (wDataType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- {
- double dData = 0;
- switch (wVersion)
- {
- case 1:
- {
- FX_DWORD dwData = *((FX_DWORD*)p);
- p += sizeof(FX_DWORD);
- dData = dwData;
- }
- break;
- case 2:
- {
- dData = *((double*)p);
- p += sizeof(double);
- }
- break;
- }
- SetGlobalVariableNumber(sEntry, dData);
- SetGlobalVariablePersistent(sEntry, TRUE);
- }
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- {
- FX_WORD wData = *((FX_WORD*)p);
- p += sizeof(FX_WORD);
- SetGlobalVariableBoolean(sEntry, (bool)(wData == 1));
- SetGlobalVariablePersistent(sEntry, TRUE);
- }
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- {
- FX_DWORD dwLength = *((FX_DWORD*)p);
- p += sizeof(FX_DWORD);
-
- if (p + dwLength > pBuffer + nLength)
- break;
-
- SetGlobalVariableString(sEntry, CFX_ByteString(p, dwLength));
- SetGlobalVariablePersistent(sEntry, TRUE);
- p += sizeof(char) * dwLength;
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- {
- SetGlobalVariableNull(sEntry);
- SetGlobalVariablePersistent(sEntry, TRUE);
- }
- }
- }
- }
- }
- FX_Free(pBuffer);
- }
+ uint8_t* pBuffer = NULL;
+ int32_t nLength = 0;
+
+ LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength);
+ CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY));
+
+ if (pBuffer)
+ {
+ uint8_t* p = pBuffer;
+ FX_WORD wType = *((FX_WORD*)p);
+ p += sizeof(FX_WORD);
+
+ //FX_WORD wTemp = (FX_WORD)(('X' << 8) | 'F');
+
+ if (wType == (FX_WORD)(('X' << 8) | 'F'))
+ {
+ FX_WORD wVersion = *((FX_WORD*)p);
+ p += sizeof(FX_WORD);
+
+ ASSERT(wVersion <= 2);
+
+ FX_DWORD dwCount = *((FX_DWORD*)p);
+ p += sizeof(FX_DWORD);
+
+ FX_DWORD dwSize = *((FX_DWORD*)p);
+ p += sizeof(FX_DWORD);
+
+ if (dwSize == nLength - sizeof(FX_WORD) * 2 - sizeof(FX_DWORD)* 2)
+ {
+ for (int32_t i=0,sz=dwCount; i<sz; i++)
+ {
+ if (p > pBuffer + nLength)
+ break;
+
+ FX_DWORD dwNameLen = *((FX_DWORD*)p);
+ p += sizeof(FX_DWORD);
+
+ if (p + dwNameLen > pBuffer + nLength)
+ break;
+
+ CFX_ByteString sEntry = CFX_ByteString(p, dwNameLen);
+ p += sizeof(char) * dwNameLen;
+
+ FX_WORD wDataType = *((FX_WORD*)p);
+ p += sizeof(FX_WORD);
+
+ switch (wDataType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ {
+ double dData = 0;
+ switch (wVersion)
+ {
+ case 1:
+ {
+ FX_DWORD dwData = *((FX_DWORD*)p);
+ p += sizeof(FX_DWORD);
+ dData = dwData;
+ }
+ break;
+ case 2:
+ {
+ dData = *((double*)p);
+ p += sizeof(double);
+ }
+ break;
+ }
+ SetGlobalVariableNumber(sEntry, dData);
+ SetGlobalVariablePersistent(sEntry, TRUE);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ {
+ FX_WORD wData = *((FX_WORD*)p);
+ p += sizeof(FX_WORD);
+ SetGlobalVariableBoolean(sEntry, (bool)(wData == 1));
+ SetGlobalVariablePersistent(sEntry, TRUE);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ {
+ FX_DWORD dwLength = *((FX_DWORD*)p);
+ p += sizeof(FX_DWORD);
+
+ if (p + dwLength > pBuffer + nLength)
+ break;
+
+ SetGlobalVariableString(sEntry, CFX_ByteString(p, dwLength));
+ SetGlobalVariablePersistent(sEntry, TRUE);
+ p += sizeof(char) * dwLength;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ {
+ SetGlobalVariableNull(sEntry);
+ SetGlobalVariablePersistent(sEntry, TRUE);
+ }
+ }
+ }
+ }
+ }
+ FX_Free(pBuffer);
+ }
}
/*
struct js_global_datafile_header
{
- FX_WORD type; //FX ('X' << 8) | 'F'
- FX_WORD version; //1.0
- FX_DWORD datacount;
+ FX_WORD type; //FX ('X' << 8) | 'F'
+ FX_WORD version; //1.0
+ FX_DWORD datacount;
};
struct js_global_datafile_data
{
- FX_WORD type;
- FX_DWORD nData;
- FX_WORD bData;
- FX_DWORD nStrLen;
- char* pStr;
+ FX_WORD type;
+ FX_DWORD nData;
+ FX_WORD bData;
+ FX_DWORD nStrLen;
+ char* pStr;
};
*/
void CJS_GlobalData::SaveGlobalPersisitentVariables()
{
- FX_DWORD nCount = 0;
- CFX_BinaryBuf sData;
+ FX_DWORD nCount = 0;
+ CFX_BinaryBuf sData;
- for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
- {
- CJS_GlobalData_Element* pElement = m_arrayGlobalData.GetAt(i);
- ASSERT(pElement != NULL);
+ for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
+ {
+ CJS_GlobalData_Element* pElement = m_arrayGlobalData.GetAt(i);
+ ASSERT(pElement != NULL);
- if (pElement->bPersistent)
- {
- CFX_BinaryBuf sElement;
- MakeByteString(pElement->data.sKey, &pElement->data, sElement);
+ if (pElement->bPersistent)
+ {
+ CFX_BinaryBuf sElement;
+ MakeByteString(pElement->data.sKey, &pElement->data, sElement);
- if (sData.GetSize() + sElement.GetSize() > JS_MAXGLOBALDATA)
- break;
+ if (sData.GetSize() + sElement.GetSize() > JS_MAXGLOBALDATA)
+ break;
- sData.AppendBlock(sElement.GetBuffer(), sElement.GetSize());
- nCount++;
- }
- }
+ sData.AppendBlock(sElement.GetBuffer(), sElement.GetSize());
+ nCount++;
+ }
+ }
- CFX_BinaryBuf sFile;
+ CFX_BinaryBuf sFile;
- FX_WORD wType = (FX_WORD)(('X' << 8) | 'F');
- sFile.AppendBlock(&wType, sizeof(FX_WORD));
- FX_WORD wVersion = 2;
- sFile.AppendBlock(&wVersion, sizeof(FX_WORD));
- sFile.AppendBlock(&nCount, sizeof(FX_DWORD));
- FX_DWORD dwSize = sData.GetSize();
- sFile.AppendBlock(&dwSize, sizeof(FX_DWORD));
+ FX_WORD wType = (FX_WORD)(('X' << 8) | 'F');
+ sFile.AppendBlock(&wType, sizeof(FX_WORD));
+ FX_WORD wVersion = 2;
+ sFile.AppendBlock(&wVersion, sizeof(FX_WORD));
+ sFile.AppendBlock(&nCount, sizeof(FX_DWORD));
+ FX_DWORD dwSize = sData.GetSize();
+ sFile.AppendBlock(&dwSize, sizeof(FX_DWORD));
- sFile.AppendBlock(sData.GetBuffer(), sData.GetSize());
+ sFile.AppendBlock(sData.GetBuffer(), sData.GetSize());
- CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, sizeof(JS_RC4KEY));
- WriteFileBuffer(m_sFilePath.c_str(), (const FX_CHAR*)sFile.GetBuffer(), sFile.GetSize());
+ CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, sizeof(JS_RC4KEY));
+ WriteFileBuffer(m_sFilePath.c_str(), (const FX_CHAR*)sFile.GetBuffer(), sFile.GetSize());
}
void CJS_GlobalData::LoadFileBuffer(const FX_WCHAR* sFilePath, uint8_t*& pBuffer, int32_t& nLength)
@@ -524,58 +522,53 @@ void CJS_GlobalData::WriteFileBuffer(const FX_WCHAR* sFilePath, const FX_CHAR* p
void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pData, CFX_BinaryBuf& sData)
{
- ASSERT(pData != NULL);
-
- FX_WORD wType = (FX_WORD)pData->nType;
-
- switch (wType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- {
- FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
- sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
- sData.AppendString(name);
-
- sData.AppendBlock(&wType, sizeof(FX_WORD));
- double dData = pData->dData;
- sData.AppendBlock(&dData, sizeof(double));
- }
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- {
- FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
- sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
- sData.AppendString(name);
-
- sData.AppendBlock(&wType, sizeof(FX_WORD));
- FX_WORD wData = (FX_WORD)pData->bData;
- sData.AppendBlock(&wData, sizeof(FX_WORD));
- }
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- {
- FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
- sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
- sData.AppendString(name);
-
- sData.AppendBlock(&wType, sizeof(FX_WORD));
-
- FX_DWORD dwDataLen = (FX_DWORD)pData->sData.GetLength();
- sData.AppendBlock(&dwDataLen, sizeof(FX_DWORD));
- sData.AppendString(pData->sData);
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- {
- FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
- sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
- sData.AppendString(name);
-
- sData.AppendBlock(&wType, sizeof(FX_DWORD));
- }
- break;
- default:
- break;
- }
+ FX_WORD wType = (FX_WORD)pData->nType;
+ switch (wType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ {
+ FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
+ sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
+ sData.AppendString(name);
+ sData.AppendBlock(&wType, sizeof(FX_WORD));
+
+ double dData = pData->dData;
+ sData.AppendBlock(&dData, sizeof(double));
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ {
+ FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
+ sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
+ sData.AppendString(name);
+ sData.AppendBlock(&wType, sizeof(FX_WORD));
+
+ FX_WORD wData = (FX_WORD)pData->bData;
+ sData.AppendBlock(&wData, sizeof(FX_WORD));
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ {
+ FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
+ sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
+ sData.AppendString(name);
+ sData.AppendBlock(&wType, sizeof(FX_WORD));
+
+ FX_DWORD dwDataLen = (FX_DWORD)pData->sData.GetLength();
+ sData.AppendBlock(&dwDataLen, sizeof(FX_DWORD));
+ sData.AppendString(pData->sData);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ {
+ FX_DWORD dwNameLen = (FX_DWORD)name.GetLength();
+ sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD));
+ sData.AppendString(name);
+ sData.AppendBlock(&wType, sizeof(FX_DWORD));
+ }
+ break;
+ default:
+ break;
+ }
}
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 34a451b0ee..485cd27813 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -31,67 +31,64 @@ CJS_RuntimeFactory::~CJS_RuntimeFactory()
{
}
-IFXJS_Runtime* CJS_RuntimeFactory::NewJSRuntime(CPDFDoc_Environment* pApp)
+IFXJS_Runtime* CJS_RuntimeFactory::NewJSRuntime(CPDFDoc_Environment* pApp)
{
- if (!m_bInit)
- {
- unsigned int embedderDataSlot = 0;
- if (pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) {
- embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot;
+ if (!m_bInit)
+ {
+ unsigned int embedderDataSlot = 0;
+ if (pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) {
+ embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot;
}
- JS_Initial(embedderDataSlot);
- m_bInit = TRUE;
- }
- return new CJS_Runtime(pApp);
+ JS_Initial(embedderDataSlot);
+ m_bInit = TRUE;
+ }
+ return new CJS_Runtime(pApp);
}
-void CJS_RuntimeFactory::AddRef()
+void CJS_RuntimeFactory::AddRef()
{
- //to do.Should be implemented as atom manipulation.
- m_nRef++;
+ //to do.Should be implemented as atom manipulation.
+ m_nRef++;
}
-void CJS_RuntimeFactory::Release()
+void CJS_RuntimeFactory::Release()
{
- if(m_bInit)
- {
- //to do.Should be implemented as atom manipulation.
- if (--m_nRef == 0)
- {
- JS_Release();
- ReleaseGlobalData();
- m_bInit = FALSE;
- }
- }
+ if(m_bInit)
+ {
+ //to do.Should be implemented as atom manipulation.
+ if (--m_nRef == 0)
+ {
+ JS_Release();
+ ReleaseGlobalData();
+ m_bInit = FALSE;
+ }
+ }
}
-void CJS_RuntimeFactory::DeleteJSRuntime(IFXJS_Runtime* pRuntime)
+void CJS_RuntimeFactory::DeleteJSRuntime(IFXJS_Runtime* pRuntime)
{
delete (CJS_Runtime*)pRuntime;
}
-CJS_GlobalData* CJS_RuntimeFactory::NewGlobalData(CPDFDoc_Environment* pApp)
+CJS_GlobalData* CJS_RuntimeFactory::NewGlobalData(CPDFDoc_Environment* pApp)
{
- if (m_pGlobalData)
- {
- m_nGlobalDataCount++;
- return m_pGlobalData;
- }
- else
- {
- m_nGlobalDataCount = 1;
- m_pGlobalData = new CJS_GlobalData(pApp);
- return m_pGlobalData;
- }
+ if (m_pGlobalData)
+ {
+ m_nGlobalDataCount++;
+ return m_pGlobalData;
+ }
+ m_nGlobalDataCount = 1;
+ m_pGlobalData = new CJS_GlobalData(pApp);
+ return m_pGlobalData;
}
void CJS_RuntimeFactory::ReleaseGlobalData()
{
- m_nGlobalDataCount--;
+ m_nGlobalDataCount--;
- if (m_nGlobalDataCount <= 0)
- {
- delete m_pGlobalData;
- m_pGlobalData = NULL;
- }
+ if (m_nGlobalDataCount <= 0)
+ {
+ delete m_pGlobalData;
+ m_pGlobalData = NULL;
+ }
}
void* CJS_ArrayBufferAllocator::Allocate(size_t length) {
@@ -113,237 +110,237 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) :
m_pDocument(NULL),
m_bBlocking(FALSE),
m_pFieldEventPath(NULL),
- m_isolate(NULL)
+ m_isolate(NULL)
{
- if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) {
- m_isolate = reinterpret_cast<v8::Isolate*>(m_pApp->GetFormFillInfo()->m_pJsPlatform->m_isolate);
- }
- if (!m_isolate) {
- m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator());
-
- v8::Isolate::CreateParams params;
- params.array_buffer_allocator = m_pArrayBufferAllocator.get();
- m_isolate = v8::Isolate::New(params);
+ if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) {
+ m_isolate = reinterpret_cast<v8::Isolate*>(m_pApp->GetFormFillInfo()->m_pJsPlatform->m_isolate);
+ }
+ if (!m_isolate) {
+ m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator());
+
+ v8::Isolate::CreateParams params;
+ params.array_buffer_allocator = m_pArrayBufferAllocator.get();
+ m_isolate = v8::Isolate::New(params);
}
- InitJSObjects();
+ InitJSObjects();
- CJS_Context * pContext = (CJS_Context*)NewContext();
- JS_InitialRuntime(*this, this, pContext, m_context);
- ReleaseContext(pContext);
+ CJS_Context * pContext = (CJS_Context*)NewContext();
+ JS_InitialRuntime(*this, this, pContext, m_context);
+ ReleaseContext(pContext);
}
CJS_Runtime::~CJS_Runtime()
{
- for (int i=0, sz=m_ContextArray.GetSize(); i<sz; i++)
- delete m_ContextArray.GetAt(i);
+ for (int i=0, sz=m_ContextArray.GetSize(); i<sz; i++)
+ delete m_ContextArray.GetAt(i);
- m_ContextArray.RemoveAll();
+ m_ContextArray.RemoveAll();
- JS_ReleaseRuntime(*this, m_context);
+ JS_ReleaseRuntime(*this, m_context);
- RemoveEventsInLoop(m_pFieldEventPath);
+ RemoveEventsInLoop(m_pFieldEventPath);
- m_pApp = NULL;
- m_pDocument = NULL;
- m_pFieldEventPath = NULL;
- m_context.Reset();
+ m_pApp = NULL;
+ m_pDocument = NULL;
+ m_pFieldEventPath = NULL;
+ m_context.Reset();
- //m_isolate->Exit();
- m_isolate->Dispose();
+ //m_isolate->Exit();
+ m_isolate->Dispose();
}
FX_BOOL CJS_Runtime::InitJSObjects()
{
- v8::Isolate::Scope isolate_scope(GetIsolate());
- v8::HandleScope handle_scope(GetIsolate());
- v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
- v8::Context::Scope context_scope(context);
- //0 - 8
- if (CJS_Border::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Display::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Font::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Highlight::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Position::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Style::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Zoomtype::Init(*this, JS_STATIC) < 0) return FALSE;
-
- //9 - 11
- if (CJS_App::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Color::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Console::Init(*this, JS_STATIC) < 0) return FALSE;
-
- //12 - 14
- if (CJS_Document::Init(*this, JS_DYNAMIC) < 0) return FALSE;
- if (CJS_Event::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Field::Init(*this, JS_DYNAMIC) < 0) return FALSE;
-
- //15 - 17
- if (CJS_Global::Init(*this, JS_STATIC) < 0) return FALSE;
- if (CJS_Icon::Init(*this, JS_DYNAMIC) < 0) return FALSE;
- if (CJS_Util::Init(*this, JS_STATIC) < 0) return FALSE;
-
- if (CJS_PublicMethods::Init(*this) < 0) return FALSE;
- if (CJS_GlobalConsts::Init(*this) < 0) return FALSE;
- if (CJS_GlobalArrays::Init(*this) < 0) return FALSE;
-
- if (CJS_TimerObj::Init(*this, JS_DYNAMIC) < 0) return FALSE;
- if (CJS_PrintParamsObj::Init(*this, JS_DYNAMIC) <0) return FALSE;
-
- return TRUE;
+ v8::Isolate::Scope isolate_scope(GetIsolate());
+ v8::HandleScope handle_scope(GetIsolate());
+ v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
+ v8::Context::Scope context_scope(context);
+ //0 - 8
+ if (CJS_Border::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Display::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Font::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Highlight::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Position::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Style::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Zoomtype::Init(*this, JS_STATIC) < 0) return FALSE;
+
+ //9 - 11
+ if (CJS_App::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Color::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Console::Init(*this, JS_STATIC) < 0) return FALSE;
+
+ //12 - 14
+ if (CJS_Document::Init(*this, JS_DYNAMIC) < 0) return FALSE;
+ if (CJS_Event::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Field::Init(*this, JS_DYNAMIC) < 0) return FALSE;
+
+ //15 - 17
+ if (CJS_Global::Init(*this, JS_STATIC) < 0) return FALSE;
+ if (CJS_Icon::Init(*this, JS_DYNAMIC) < 0) return FALSE;
+ if (CJS_Util::Init(*this, JS_STATIC) < 0) return FALSE;
+
+ if (CJS_PublicMethods::Init(*this) < 0) return FALSE;
+ if (CJS_GlobalConsts::Init(*this) < 0) return FALSE;
+ if (CJS_GlobalArrays::Init(*this) < 0) return FALSE;
+
+ if (CJS_TimerObj::Init(*this, JS_DYNAMIC) < 0) return FALSE;
+ if (CJS_PrintParamsObj::Init(*this, JS_DYNAMIC) <0) return FALSE;
+
+ return TRUE;
}
IFXJS_Context* CJS_Runtime::NewContext()
{
- CJS_Context * p = new CJS_Context(this);
- m_ContextArray.Add(p);
- return p;
+ CJS_Context * p = new CJS_Context(this);
+ m_ContextArray.Add(p);
+ return p;
}
void CJS_Runtime::ReleaseContext(IFXJS_Context * pContext)
{
- CJS_Context* pJSContext = (CJS_Context*)pContext;
-
- for (int i=0, sz=m_ContextArray.GetSize(); i<sz; i++)
- {
- if (pJSContext == m_ContextArray.GetAt(i))
- {
- delete pJSContext;
- m_ContextArray.RemoveAt(i);
- break;
- }
- }
+ CJS_Context* pJSContext = (CJS_Context*)pContext;
+
+ for (int i=0, sz=m_ContextArray.GetSize(); i<sz; i++)
+ {
+ if (pJSContext == m_ContextArray.GetAt(i))
+ {
+ delete pJSContext;
+ m_ContextArray.RemoveAt(i);
+ break;
+ }
+ }
}
-IFXJS_Context* CJS_Runtime::GetCurrentContext()
+IFXJS_Context* CJS_Runtime::GetCurrentContext()
{
- if(!m_ContextArray.GetSize())
- return NULL;
- return m_ContextArray.GetAt(m_ContextArray.GetSize()-1);
+ if(!m_ContextArray.GetSize())
+ return NULL;
+ return m_ContextArray.GetAt(m_ContextArray.GetSize()-1);
}
void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc)
{
- if (m_pDocument != pReaderDoc)
- {
- v8::Isolate::Scope isolate_scope(m_isolate);
- v8::HandleScope handle_scope(m_isolate);
- v8::Local<v8::Context> context =v8::Local<v8::Context>::New(m_isolate, m_context);
- v8::Context::Scope context_scope(context);
-
- m_pDocument = pReaderDoc;
-
- if (pReaderDoc)
- {
- JSObject pThis = JS_GetThisObj(*this);
- if(!pThis.IsEmpty())
- {
- if (JS_GetObjDefnID(pThis) == JS_GetObjDefnID(*this, L"Document"))
- {
- if (CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pThis))
- {
- if (Document * pDocument = (Document*)pJSDocument->GetEmbedObject())
- pDocument->AttachDoc(pReaderDoc);
- }
- }
- }
- JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"Document"));
- }
- else
- {
- JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"app"));
- }
- }
+ if (m_pDocument != pReaderDoc)
+ {
+ v8::Isolate::Scope isolate_scope(m_isolate);
+ v8::HandleScope handle_scope(m_isolate);
+ v8::Local<v8::Context> context =v8::Local<v8::Context>::New(m_isolate, m_context);
+ v8::Context::Scope context_scope(context);
+
+ m_pDocument = pReaderDoc;
+
+ if (pReaderDoc)
+ {
+ JSObject pThis = JS_GetThisObj(*this);
+ if(!pThis.IsEmpty())
+ {
+ if (JS_GetObjDefnID(pThis) == JS_GetObjDefnID(*this, L"Document"))
+ {
+ if (CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pThis))
+ {
+ if (Document * pDocument = (Document*)pJSDocument->GetEmbedObject())
+ pDocument->AttachDoc(pReaderDoc);
+ }
+ }
+ }
+ JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"Document"));
+ }
+ else
+ {
+ JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"app"));
+ }
+ }
}
-FX_BOOL CJS_Runtime::AddEventToLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType)
+FX_BOOL CJS_Runtime::AddEventToLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType)
{
- if (m_pFieldEventPath == NULL)
- {
- m_pFieldEventPath = new CJS_FieldEvent;
- m_pFieldEventPath->sTargetName = sTargetName;
- m_pFieldEventPath->eEventType = eEventType;
- m_pFieldEventPath->pNext = NULL;
-
- return TRUE;
- }
-
- //to search
- CJS_FieldEvent* p = m_pFieldEventPath;
- CJS_FieldEvent* pLast = m_pFieldEventPath;
- while (p)
- {
- if (p->eEventType == eEventType && p->sTargetName == sTargetName)
- return FALSE;
-
- pLast = p;
- p = p->pNext;
- }
-
- //to add
- CJS_FieldEvent* pNew = new CJS_FieldEvent;
- pNew->sTargetName = sTargetName;
- pNew->eEventType = eEventType;
- pNew->pNext = NULL;
-
- pLast->pNext = pNew;
-
- return TRUE;
+ if (m_pFieldEventPath == NULL)
+ {
+ m_pFieldEventPath = new CJS_FieldEvent;
+ m_pFieldEventPath->sTargetName = sTargetName;
+ m_pFieldEventPath->eEventType = eEventType;
+ m_pFieldEventPath->pNext = NULL;
+
+ return TRUE;
+ }
+
+ //to search
+ CJS_FieldEvent* p = m_pFieldEventPath;
+ CJS_FieldEvent* pLast = m_pFieldEventPath;
+ while (p)
+ {
+ if (p->eEventType == eEventType && p->sTargetName == sTargetName)
+ return FALSE;
+
+ pLast = p;
+ p = p->pNext;
+ }
+
+ //to add
+ CJS_FieldEvent* pNew = new CJS_FieldEvent;
+ pNew->sTargetName = sTargetName;
+ pNew->eEventType = eEventType;
+ pNew->pNext = NULL;
+
+ pLast->pNext = pNew;
+
+ return TRUE;
}
void CJS_Runtime::RemoveEventInLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType)
{
- FX_BOOL bFind = FALSE;
-
- CJS_FieldEvent* p = m_pFieldEventPath;
- CJS_FieldEvent* pLast = NULL;
- while (p)
- {
- if (p->eEventType == eEventType && p->sTargetName == sTargetName)
- {
- bFind = TRUE;
- break;
- }
-
- pLast = p;
- p = p->pNext;
- }
-
- if (bFind)
- {
- RemoveEventsInLoop(p);
-
- if (p == m_pFieldEventPath)
- m_pFieldEventPath = NULL;
-
- if (pLast)
- pLast->pNext = NULL;
- }
+ FX_BOOL bFind = FALSE;
+
+ CJS_FieldEvent* p = m_pFieldEventPath;
+ CJS_FieldEvent* pLast = NULL;
+ while (p)
+ {
+ if (p->eEventType == eEventType && p->sTargetName == sTargetName)
+ {
+ bFind = TRUE;
+ break;
+ }
+
+ pLast = p;
+ p = p->pNext;
+ }
+
+ if (bFind)
+ {
+ RemoveEventsInLoop(p);
+
+ if (p == m_pFieldEventPath)
+ m_pFieldEventPath = NULL;
+
+ if (pLast)
+ pLast->pNext = NULL;
+ }
}
void CJS_Runtime::RemoveEventsInLoop(CJS_FieldEvent* pStart)
{
- CJS_FieldEvent* p = pStart;
+ CJS_FieldEvent* p = pStart;
- while (p)
- {
- CJS_FieldEvent* pOld = p;
- p = pOld->pNext;
+ while (p)
+ {
+ CJS_FieldEvent* pOld = p;
+ p = pOld->pNext;
- delete pOld;
- }
+ delete pOld;
+ }
}
-v8::Local<v8::Context> CJS_Runtime::NewJSContext()
+v8::Local<v8::Context> CJS_Runtime::NewJSContext()
{
- return v8::Local<v8::Context>::New(m_isolate, m_context);
+ return v8::Local<v8::Context>::New(m_isolate, m_context);
}
CFX_WideString ChangeObjName(const CFX_WideString& str)
{
- CFX_WideString sRet = str;
- sRet.Replace(L"_", L".");
- return sRet;
+ CFX_WideString sRet = str;
+ sRet.Replace(L"_", L".");
+ return sRet;
}
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp
index a615d4409b..b8967c4d53 100644
--- a/fpdfsdk/src/javascript/PublicMethods.cpp
+++ b/fpdfsdk/src/javascript/PublicMethods.cpp
@@ -21,130 +21,131 @@
static v8::Isolate* GetIsolate(IFXJS_Context* cc)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- return pRuntime->GetIsolate();
+ return pRuntime->GetIsolate();
}
/* -------------------------------- CJS_PublicMethods -------------------------------- */
-#define DOUBLE_CORRECT 0.000000000000001
+#define DOUBLE_CORRECT 0.000000000000001
BEGIN_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Format)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Keystroke)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_FormatEx)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_KeystrokeEx)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Format)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Keystroke)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_FormatEx)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_KeystrokeEx)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Format)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Keystroke)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Format)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Keystroke)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_KeystrokeEx)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx)
- JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Format)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Keystroke)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_FormatEx)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_KeystrokeEx)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Format)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Keystroke)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_FormatEx)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_KeystrokeEx)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Format)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Keystroke)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Format)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Keystroke)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_KeystrokeEx)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx)
+ JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums)
END_JS_STATIC_GLOBAL_FUN()
IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
static const FX_WCHAR* months[] =
{
- L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
+ L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
};
static const FX_WCHAR* fullmonths[] =
{
- L"January", L"February", L"March", L"April", L"May", L"June", L"July", L"August", L"September", L"October", L"November", L"December"
+ L"January", L"February", L"March", L"April", L"May", L"June", L"July", L"August", L"September", L"October", L"November", L"December"
};
FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* string)
{
- CFX_WideString sTrim = StrTrim(string);
- const FX_WCHAR* pTrim = sTrim.c_str();
- const FX_WCHAR* p = pTrim;
-
-
- FX_BOOL bDot = FALSE;
- FX_BOOL bKXJS = FALSE;
-
- wchar_t c;
- while ((c = *p))
- {
- if (c == '.' || c == ',')
- {
- if (bDot) return FALSE;
- bDot = TRUE;
- }
- else if (c == '-' || c == '+')
- {
- if (p != pTrim)
- return FALSE;
- }
- else if (c == 'e' || c == 'E')
- {
- if (bKXJS) return FALSE;
-
- p++;
- c = *p;
- if (c == '+' || c == '-')
- {
- bKXJS = TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else if (!IsDigit(c))
- {
- return FALSE;
- }
- p++;
- }
-
- return TRUE;
+ CFX_WideString sTrim = StrTrim(string);
+ const FX_WCHAR* pTrim = sTrim.c_str();
+ const FX_WCHAR* p = pTrim;
+
+
+ FX_BOOL bDot = FALSE;
+ FX_BOOL bKXJS = FALSE;
+
+ wchar_t c;
+ while ((c = *p))
+ {
+ if (c == '.' || c == ',')
+ {
+ if (bDot) return FALSE;
+ bDot = TRUE;
+ }
+ else if (c == '-' || c == '+')
+ {
+ if (p != pTrim)
+ return FALSE;
+ }
+ else if (c == 'e' || c == 'E')
+ {
+ if (bKXJS)
+ return FALSE;
+
+ p++;
+ c = *p;
+ if (c == '+' || c == '-')
+ {
+ bKXJS = TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else if (!IsDigit(c))
+ {
+ return FALSE;
+ }
+ p++;
+ }
+
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch)
{
- return (ch >= L'0' && ch <= L'9');
+ return (ch >= L'0' && ch <= L'9');
}
FX_BOOL CJS_PublicMethods::IsDigit(char ch)
{
- return (ch >= '0' && ch <= '9');
+ return (ch >= '0' && ch <= '9');
}
FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch)
{
- return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z'));
+ return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z'));
}
FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch)
{
- return (IsDigit(ch) || IsAlphabetic(ch));
+ return (IsDigit(ch) || IsAlphabetic(ch));
}
FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask)
{
- switch (c_Mask)
- {
- case L'9':
+ switch (c_Mask)
+ {
+ case L'9':
return IsDigit(c_Change);
case L'A':
return IsAlphabetic(c_Change);
@@ -152,870 +153,869 @@ FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask)
return IsAlphaNumeric(c_Change);
case L'X':
return TRUE;
- default:
+ default:
return (c_Change == c_Mask);
- }
+ }
}
FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch)
{
- return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X';
+ return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X';
}
double CJS_PublicMethods::AF_Simple(const FX_WCHAR* sFuction, double dValue1, double dValue2)
{
- if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,L"SUM") == 0)
- {
- return dValue1 + dValue2;
- }
- else if (FXSYS_wcsicmp(sFuction, L"PRD") == 0)
- {
- return dValue1 * dValue2;
- }
- else if (FXSYS_wcsicmp(sFuction,L"MIN") == 0)
- {
- return FX_MIN(dValue1, dValue2);
- }
- else if (FXSYS_wcsicmp(sFuction,L"MAX") == 0)
- {
- return FX_MAX(dValue1, dValue2);
- }
-
- return dValue1;
+ if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,L"SUM") == 0)
+ {
+ return dValue1 + dValue2;
+ }
+ if (FXSYS_wcsicmp(sFuction, L"PRD") == 0)
+ {
+ return dValue1 * dValue2;
+ }
+ if (FXSYS_wcsicmp(sFuction,L"MIN") == 0)
+ {
+ return FX_MIN(dValue1, dValue2);
+ }
+ if (FXSYS_wcsicmp(sFuction,L"MAX") == 0)
+ {
+ return FX_MAX(dValue1, dValue2);
+ }
+ return dValue1;
}
CFX_WideString CJS_PublicMethods::StrLTrim(const FX_WCHAR* pStr)
{
- while (*pStr && *pStr == L' ') pStr++;
+ while (*pStr && *pStr == L' ') pStr++;
- return pStr;
+ return pStr;
}
CFX_WideString CJS_PublicMethods::StrRTrim(const FX_WCHAR* pStr)
{
- const FX_WCHAR* p = pStr;
- while (*p) p++;
- while (p > pStr && *(p - 1) == L' ') p--;
+ const FX_WCHAR* p = pStr;
+ while (*p) p++;
+ while (p > pStr && *(p - 1) == L' ') p--;
- return CFX_WideString(pStr, p - pStr);
+ return CFX_WideString(pStr, p - pStr);
}
CFX_WideString CJS_PublicMethods::StrTrim(const FX_WCHAR* pStr)
{
- return StrRTrim(StrLTrim(pStr).c_str());
+ return StrRTrim(StrLTrim(pStr).c_str());
}
CFX_ByteString CJS_PublicMethods::StrLTrim(const FX_CHAR* pStr)
{
- while (*pStr && *pStr == ' ') pStr++;
+ while (*pStr && *pStr == ' ') pStr++;
return pStr;
}
CFX_ByteString CJS_PublicMethods::StrRTrim(const FX_CHAR* pStr)
{
- const FX_CHAR* p = pStr;
- while (*p) p++;
- while (p > pStr && *(p - 1) == L' ') p--;
+ const FX_CHAR* p = pStr;
+ while (*p) p++;
+ while (p > pStr && *(p - 1) == L' ') p--;
- return CFX_ByteString(pStr,p-pStr);
+ return CFX_ByteString(pStr,p-pStr);
}
CFX_ByteString CJS_PublicMethods::StrTrim(const FX_CHAR* pStr)
{
- return StrRTrim(StrLTrim(pStr));
+ return StrRTrim(StrLTrim(pStr));
}
double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDigits, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS)
{
- bDot = FALSE;
- bSign = FALSE;
- bKXJS = FALSE;
-
- FX_BOOL bDigitExist = FALSE;
-
- const FX_WCHAR* p = swSource;
- wchar_t c;
-
- const FX_WCHAR* pStart = NULL;
- const FX_WCHAR* pEnd = NULL;
-
- while ((c = *p))
- {
- if (!pStart && c != L' ')
- {
- pStart = p;
- }
-
- pEnd = p;
- p++;
- }
-
- if (!pStart)
- {
- bAllDigits = FALSE;
- return 0;
- }
-
- while (pEnd != pStart)
- {
- if (*pEnd == L' ')
- pEnd --;
- else
- break;
- }
-
- double dRet = 0;
- p = pStart;
- bAllDigits = TRUE;
- CFX_WideString swDigits;
-
- while (p <= pEnd)
- {
- c = *p;
-
- if (IsDigit(c))
- {
- swDigits += c;
- bDigitExist = TRUE;
- }
- else
- {
- switch (c)
- {
- case L' ':
- bAllDigits = FALSE;
- break;
- case L'.':
- case L',':
- if (!bDot)
- {
- if (bDigitExist)
- {
- swDigits += L'.';
- }
- else
- {
- swDigits += L'0';
- swDigits += L'.';
- bDigitExist = TRUE;
- }
-
- bDot = TRUE;
- break;
- }
- case 'e':
- case 'E':
- if (!bKXJS)
- {
- p++;
- c = *p;
- if (c == '+' || c == '-')
- {
- bKXJS = TRUE;
- swDigits += 'e';
- swDigits += c;
- }
- break;
- }
- case L'-':
- if (!bDigitExist && !bSign)
- {
- swDigits += c;
- bSign = TRUE;
- break;
- }
- default:
- bAllDigits = FALSE;
-
- if (p != pStart && !bDot && bDigitExist)
- {
- swDigits += L'.';
- bDot = TRUE;
- }
- else
- {
- bDot = FALSE;
- bDigitExist = FALSE;
- swDigits = L"";
- }
- break;
- }
- }
-
- p++;
- }
-
- if (swDigits.GetLength() > 0 && swDigits.GetLength() < 17)
- {
- CFX_ByteString sDigits = swDigits.UTF8Encode();
-
- if (bKXJS)
- {
- dRet = atof(sDigits);
- }
- else
- {
- if (bDot)
- {
- char* pStopString;
- dRet = ::strtod(sDigits, &pStopString);
- }
- else
- {
- dRet = atol(sDigits);
- }
- }
-
- }
-
- return dRet;
+ bDot = FALSE;
+ bSign = FALSE;
+ bKXJS = FALSE;
+
+ FX_BOOL bDigitExist = FALSE;
+
+ const FX_WCHAR* p = swSource;
+ wchar_t c;
+
+ const FX_WCHAR* pStart = NULL;
+ const FX_WCHAR* pEnd = NULL;
+
+ while ((c = *p))
+ {
+ if (!pStart && c != L' ')
+ {
+ pStart = p;
+ }
+
+ pEnd = p;
+ p++;
+ }
+
+ if (!pStart)
+ {
+ bAllDigits = FALSE;
+ return 0;
+ }
+
+ while (pEnd != pStart)
+ {
+ if (*pEnd == L' ')
+ pEnd --;
+ else
+ break;
+ }
+
+ double dRet = 0;
+ p = pStart;
+ bAllDigits = TRUE;
+ CFX_WideString swDigits;
+
+ while (p <= pEnd)
+ {
+ c = *p;
+
+ if (IsDigit(c))
+ {
+ swDigits += c;
+ bDigitExist = TRUE;
+ }
+ else
+ {
+ switch (c)
+ {
+ case L' ':
+ bAllDigits = FALSE;
+ break;
+ case L'.':
+ case L',':
+ if (!bDot)
+ {
+ if (bDigitExist)
+ {
+ swDigits += L'.';
+ }
+ else
+ {
+ swDigits += L'0';
+ swDigits += L'.';
+ bDigitExist = TRUE;
+ }
+
+ bDot = TRUE;
+ break;
+ }
+ case 'e':
+ case 'E':
+ if (!bKXJS)
+ {
+ p++;
+ c = *p;
+ if (c == '+' || c == '-')
+ {
+ bKXJS = TRUE;
+ swDigits += 'e';
+ swDigits += c;
+ }
+ break;
+ }
+ case L'-':
+ if (!bDigitExist && !bSign)
+ {
+ swDigits += c;
+ bSign = TRUE;
+ break;
+ }
+ default:
+ bAllDigits = FALSE;
+
+ if (p != pStart && !bDot && bDigitExist)
+ {
+ swDigits += L'.';
+ bDot = TRUE;
+ }
+ else
+ {
+ bDot = FALSE;
+ bDigitExist = FALSE;
+ swDigits = L"";
+ }
+ break;
+ }
+ }
+
+ p++;
+ }
+
+ if (swDigits.GetLength() > 0 && swDigits.GetLength() < 17)
+ {
+ CFX_ByteString sDigits = swDigits.UTF8Encode();
+
+ if (bKXJS)
+ {
+ dRet = atof(sDigits);
+ }
+ else
+ {
+ if (bDot)
+ {
+ char* pStopString;
+ dRet = ::strtod(sDigits, &pStopString);
+ }
+ else
+ {
+ dRet = atol(sDigits);
+ }
+ }
+
+ }
+
+ return dRet;
}
double CJS_PublicMethods::ParseStringToNumber(const FX_WCHAR* swSource)
{
- FX_BOOL bAllDigits = FALSE;
- FX_BOOL bDot = FALSE;
- FX_BOOL bSign = FALSE;
- FX_BOOL bKXJS = FALSE;
+ FX_BOOL bAllDigits = FALSE;
+ FX_BOOL bDot = FALSE;
+ FX_BOOL bSign = FALSE;
+ FX_BOOL bKXJS = FALSE;
- return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS);
+ return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS);
}
-FX_BOOL CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, double & dRet, FX_BOOL & bDot)
+FX_BOOL CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, double & dRet, FX_BOOL & bDot)
{
- FX_BOOL bAllDigits = FALSE;
- FX_BOOL bSign = FALSE;
- FX_BOOL bKXJS = FALSE;
+ FX_BOOL bAllDigits = FALSE;
+ FX_BOOL bSign = FALSE;
+ FX_BOOL bKXJS = FALSE;
- dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS);
+ dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS);
- return bAllDigits;
+ return bAllDigits;
}
CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Value val)
{
- CJS_Array StrArray(isolate);
- if(val.IsArrayObject())
- {
- val.ConvertToArray(StrArray);
- return StrArray;
- }
- CFX_WideString wsStr = val.ToCFXWideString();
- CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
- const char * p = (const char *)t;
-
-
- int ch = ',' ;
- int nIndex = 0;
-
- while (*p)
- {
- const char * pTemp = strchr(p, ch);
- if (pTemp == NULL)
- {
- StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(p).c_str()));
- break;
- }
- else
- {
- char * pSub = new char[pTemp - p + 1];
- strncpy(pSub, p, pTemp - p);
- *(pSub + (pTemp - p)) = '\0';
-
- StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(pSub).c_str()));
- delete []pSub;
-
- nIndex ++;
- p = ++pTemp;
- }
-
- }
- return StrArray;
+ CJS_Array StrArray(isolate);
+ if(val.IsArrayObject())
+ {
+ val.ConvertToArray(StrArray);
+ return StrArray;
+ }
+ CFX_WideString wsStr = val.ToCFXWideString();
+ CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
+ const char * p = (const char *)t;
+
+
+ int ch = ',' ;
+ int nIndex = 0;
+
+ while (*p)
+ {
+ const char * pTemp = strchr(p, ch);
+ if (pTemp == NULL)
+ {
+ StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(p).c_str()));
+ break;
+ }
+ else
+ {
+ char * pSub = new char[pTemp - p + 1];
+ strncpy(pSub, p, pTemp - p);
+ *(pSub + (pTemp - p)) = '\0';
+
+ StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(pSub).c_str()));
+ delete []pSub;
+
+ nIndex ++;
+ p = ++pTemp;
+ }
+
+ }
+ return StrArray;
}
int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string,int nStart,int& nSkip, int nMaxStep)
{
- int nRet = 0;
- nSkip = 0;
- for (int i=nStart, sz=string.GetLength(); i < sz; i++)
- {
- if (i-nStart > 10)
- break;
-
- FX_WCHAR c = string.GetAt(i);
- if (IsDigit((wchar_t)c))
- {
- nRet = nRet * 10 + (c - '0');
- nSkip = i - nStart + 1;
- if (nSkip >= nMaxStep)
- break;
- }
- else
- break;
- }
-
- return nRet;
+ int nRet = 0;
+ nSkip = 0;
+ for (int i=nStart, sz=string.GetLength(); i < sz; i++)
+ {
+ if (i-nStart > 10)
+ break;
+
+ FX_WCHAR c = string.GetAt(i);
+ if (IsDigit((wchar_t)c))
+ {
+ nRet = nRet * 10 + (c - '0');
+ nSkip = i - nStart + 1;
+ if (nSkip >= nMaxStep)
+ break;
+ }
+ else
+ break;
+ }
+
+ return nRet;
}
CFX_WideString CJS_PublicMethods::ParseStringString(const CFX_WideString& string, int nStart, int& nSkip)
{
- CFX_WideString swRet;
- nSkip = 0;
- for (int i=nStart, sz=string.GetLength(); i < sz; i++)
- {
- FX_WCHAR c = string.GetAt(i);
- if ((c >= L'a' && c <= L'z') || (c >= L'A' && c <= L'Z'))
- {
- swRet += c;
- nSkip = i - nStart + 1;
- }
- else
- break;
- }
-
- return swRet;
+ CFX_WideString swRet;
+ nSkip = 0;
+ for (int i=nStart, sz=string.GetLength(); i < sz; i++)
+ {
+ FX_WCHAR c = string.GetAt(i);
+ if ((c >= L'a' && c <= L'z') || (c >= L'A' && c <= L'Z'))
+ {
+ swRet += c;
+ nSkip = i - nStart + 1;
+ }
+ else
+ break;
+ }
+
+ return swRet;
}
double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& bWrongFormat)
{
- double dt = JS_GetDateTime();
-
- int nYear = JS_GetYearFromTime(dt);
- int nMonth = JS_GetMonthFromTime(dt) + 1;
- int nDay = JS_GetDayFromTime(dt);
- int nHour = JS_GetHourFromTime(dt);
- int nMin = JS_GetMinFromTime(dt);
- int nSec = JS_GetSecFromTime(dt);
-
- int number[3];
-
- int nSkip = 0;
- int nLen = value.GetLength();
- int nIndex = 0;
- int i = 0;
- while (i < nLen)
- {
- if (nIndex > 2) break;
-
- FX_WCHAR c = value.GetAt(i);
- if (IsDigit((wchar_t)c))
- {
- number[nIndex++] = ParseStringInteger(value, i, nSkip, 4);
- i += nSkip;
- }
- else
- {
- i ++;
- }
- }
-
- if (nIndex == 2)
- {
- // case2: month/day
- // case3: day/month
- if ((number[0] >= 1 && number[0] <= 12) && (number[1] >= 1 && number[1] <= 31))
- {
- nMonth = number[0];
- nDay = number[1];
- }
- else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12))
- {
- nDay = number[0];
- nMonth = number[1];
- }
-
- bWrongFormat = FALSE;
- }
- else if (nIndex == 3)
- {
- // case1: year/month/day
- // case2: month/day/year
- // case3: day/month/year
-
- if (number[0] > 12 && (number[1] >= 1 && number[1] <= 12) && (number[2] >= 1 && number[2] <= 31))
- {
- nYear = number[0];
- nMonth = number[1];
- nDay = number[2];
- }
- else if ((number[0] >= 1 && number[0] <= 12) && (number[1] >= 1 && number[1] <= 31) && number[2] > 31)
- {
- nMonth = number[0];
- nDay = number[1];
- nYear = number[2];
- }
- else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12) && number[2] > 31)
- {
- nDay = number[0];
- nMonth = number[1];
- nYear = number[2];
- }
-
- bWrongFormat = FALSE;
- }
- else
- {
- bWrongFormat = TRUE;
- return dt;
- }
-
- CFX_WideString swTemp;
- swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec);
- return JS_DateParse(swTemp.c_str());
+ double dt = JS_GetDateTime();
+
+ int nYear = JS_GetYearFromTime(dt);
+ int nMonth = JS_GetMonthFromTime(dt) + 1;
+ int nDay = JS_GetDayFromTime(dt);
+ int nHour = JS_GetHourFromTime(dt);
+ int nMin = JS_GetMinFromTime(dt);
+ int nSec = JS_GetSecFromTime(dt);
+
+ int number[3];
+
+ int nSkip = 0;
+ int nLen = value.GetLength();
+ int nIndex = 0;
+ int i = 0;
+ while (i < nLen)
+ {
+ if (nIndex > 2) break;
+
+ FX_WCHAR c = value.GetAt(i);
+ if (IsDigit((wchar_t)c))
+ {
+ number[nIndex++] = ParseStringInteger(value, i, nSkip, 4);
+ i += nSkip;
+ }
+ else
+ {
+ i ++;
+ }
+ }
+
+ if (nIndex == 2)
+ {
+ // case2: month/day
+ // case3: day/month
+ if ((number[0] >= 1 && number[0] <= 12) && (number[1] >= 1 && number[1] <= 31))
+ {
+ nMonth = number[0];
+ nDay = number[1];
+ }
+ else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12))
+ {
+ nDay = number[0];
+ nMonth = number[1];
+ }
+
+ bWrongFormat = FALSE;
+ }
+ else if (nIndex == 3)
+ {
+ // case1: year/month/day
+ // case2: month/day/year
+ // case3: day/month/year
+
+ if (number[0] > 12 && (number[1] >= 1 && number[1] <= 12) && (number[2] >= 1 && number[2] <= 31))
+ {
+ nYear = number[0];
+ nMonth = number[1];
+ nDay = number[2];
+ }
+ else if ((number[0] >= 1 && number[0] <= 12) && (number[1] >= 1 && number[1] <= 31) && number[2] > 31)
+ {
+ nMonth = number[0];
+ nDay = number[1];
+ nYear = number[2];
+ }
+ else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12) && number[2] > 31)
+ {
+ nDay = number[0];
+ nMonth = number[1];
+ nYear = number[2];
+ }
+
+ bWrongFormat = FALSE;
+ }
+ else
+ {
+ bWrongFormat = TRUE;
+ return dt;
+ }
+
+ CFX_WideString swTemp;
+ swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec);
+ return JS_DateParse(swTemp.c_str());
}
double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CFX_WideString & format, FX_BOOL& bWrongFormat)
{
- double dt = JS_GetDateTime();
-
- if (format.IsEmpty() || value.IsEmpty())
- return dt;
-
- int nYear = JS_GetYearFromTime(dt);
- int nMonth = JS_GetMonthFromTime(dt) + 1;
- int nDay = JS_GetDayFromTime(dt);
- int nHour = JS_GetHourFromTime(dt);
- int nMin = JS_GetMinFromTime(dt);
- int nSec = JS_GetSecFromTime(dt);
-
- int nYearSub = 99; //nYear - 2000;
-
- FX_BOOL bPm = FALSE;
- FX_BOOL bExit = FALSE;
- bWrongFormat = FALSE;
-
- int i=0;
- int j=0;
-
- while (i < format.GetLength())
- {
- if (bExit) break;
-
- FX_WCHAR c = format.GetAt(i);
- switch (c)
- {
- case ':':
- case '.':
- case '-':
- case '\\':
- case '/':
- i++;
- j++;
- break;
-
- case 'y':
- case 'm':
- case 'd':
- case 'H':
- case 'h':
- case 'M':
- case 's':
- case 't':
- {
- int oldj = j;
- int nSkip = 0;
- int remaining = format.GetLength() - i - 1;
-
- if (remaining == 0 || format.GetAt(i+1) != c)
- {
- switch (c)
- {
- case 'y':
- i++;
- j++;
- break;
- case 'm':
- nMonth = ParseStringInteger(value, j, nSkip, 2);
- i++;
- j += nSkip;
- break;
- case 'd':
- nDay = ParseStringInteger(value, j, nSkip, 2);
- i++;
- j += nSkip;
- break;
- case 'H':
- nHour = ParseStringInteger(value, j, nSkip, 2);
- i++;
- j += nSkip;
- break;
- case 'h':
- nHour = ParseStringInteger(value, j, nSkip, 2);
- i++;
- j += nSkip;
- break;
- case 'M':
- nMin = ParseStringInteger(value, j, nSkip, 2);
- i++;
- j += nSkip;
- break;
- case 's':
- nSec = ParseStringInteger(value, j, nSkip, 2);
- i++;
- j += nSkip;
- break;
- case 't':
- bPm = (j < value.GetLength() && value.GetAt(j) == 'p');
- i++;
- j++;
- break;
- }
- }
- else if (remaining == 1 || format.GetAt(i+2) != c)
- {
- switch (c)
- {
- case 'y':
- nYear = ParseStringInteger(value, j, nSkip, 4);
- i += 2;
- j += nSkip;
- break;
- case 'm':
- nMonth = ParseStringInteger(value, j, nSkip, 2);
- i += 2;
- j += nSkip;
- break;
- case 'd':
- nDay = ParseStringInteger(value, j, nSkip, 2);
- i += 2;
- j += nSkip;
- break;
- case 'H':
- nHour = ParseStringInteger(value, j, nSkip, 2);
- i += 2;
- j += nSkip;
- break;
- case 'h':
- nHour = ParseStringInteger(value, j, nSkip, 2);
- i += 2;
- j += nSkip;
- break;
- case 'M':
- nMin = ParseStringInteger(value, j, nSkip, 2);
- i += 2;
- j += nSkip;
- break;
- case 's':
- nSec = ParseStringInteger(value, j, nSkip, 2);
- i += 2;
- j += nSkip;
- break;
- case 't':
- bPm = (j + 1 < value.GetLength() && value.GetAt(j) == 'p' && value.GetAt(j+1) == 'm');
- i += 2;
- j += 2;
- break;
- }
- }
- else if (remaining == 2 || format.GetAt(i+3) != c)
- {
- switch (c)
- {
- case 'm':
- {
- CFX_WideString sMonth = ParseStringString(value, j, nSkip);
- FX_BOOL bFind = FALSE;
- for (int m = 0; m < 12; m++)
- {
- if (sMonth.CompareNoCase(months[m]) == 0)
- {
- nMonth = m + 1;
- i+=3;
- j+=nSkip;
- bFind = TRUE;
- break;
- }
- }
-
- if (!bFind)
- {
- nMonth = ParseStringInteger(value, j, nSkip, 3);
- i+=3;
- j += nSkip;
- }
- }
- break;
- case 'y':
- break;
- default:
- i+=3;
- j+=3;
- break;
- }
- }
- else if (remaining == 3 || format.GetAt(i+4) != c)
- {
- switch (c)
- {
-
-
- case 'y':
- nYear = ParseStringInteger(value, j, nSkip, 4);
- j += nSkip;
- i += 4;
- break;
- case 'm':
- {
- FX_BOOL bFind = FALSE;
-
- CFX_WideString sMonth = ParseStringString(value, j, nSkip);
- sMonth.MakeLower();
-
- for (int m = 0; m < 12; m++)
- {
- CFX_WideString sFullMonths = fullmonths[m];
- sFullMonths.MakeLower();
-
- if (sFullMonths.Find(sMonth.c_str(), 0) != -1)
- {
- nMonth = m + 1;
- i += 4;
- j += nSkip;
- bFind = TRUE;
- break;
- }
- }
-
- if (!bFind)
- {
- nMonth = ParseStringInteger(value, j, nSkip, 4);
- i+=4;
- j += nSkip;
- }
- }
- break;
- default:
- i += 4;
- j += 4;
- break;
- }
- }
- else
- {
- if (j >= value.GetLength() || format.GetAt(i) != value.GetAt(j))
- {
- bWrongFormat = TRUE;
- bExit = TRUE;
- }
- i++;
- j++;
- }
-
- if (oldj == j)
- {
- bWrongFormat = TRUE;
- bExit = TRUE;
- }
- }
-
- break;
- default:
- if (value.GetLength() <= j)
- {
- bExit = TRUE;
- }
- else if (format.GetAt(i) != value.GetAt(j))
- {
- bWrongFormat = TRUE;
- bExit = TRUE;
- }
-
- i++;
- j++;
- break;
- }
- }
-
- if (bPm) nHour += 12;
-
- if (nYear >= 0 && nYear <= nYearSub)
- nYear += 2000;
-
- if (nMonth < 1 || nMonth > 12)
- bWrongFormat = TRUE;
-
- if (nDay < 1 || nDay > 31)
- bWrongFormat = TRUE;
-
- if (nHour < 0 || nHour > 24)
- bWrongFormat = TRUE;
-
- if (nMin < 0 || nMin > 60)
- bWrongFormat = TRUE;
-
- if (nSec < 0 || nSec > 60)
- bWrongFormat = TRUE;
-
- double dRet = 0;
-
- if (bWrongFormat)
- {
- dRet = ParseNormalDate(value, bWrongFormat);
- }
- else
- {
- dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0));
-
- if (JS_PortIsNan(dRet))
- {
- dRet = JS_DateParse(value.c_str());
- }
- }
-
- if (JS_PortIsNan(dRet))
- {
- dRet = ParseNormalDate(value, bWrongFormat);
- }
-
- return dRet;
+ double dt = JS_GetDateTime();
+
+ if (format.IsEmpty() || value.IsEmpty())
+ return dt;
+
+ int nYear = JS_GetYearFromTime(dt);
+ int nMonth = JS_GetMonthFromTime(dt) + 1;
+ int nDay = JS_GetDayFromTime(dt);
+ int nHour = JS_GetHourFromTime(dt);
+ int nMin = JS_GetMinFromTime(dt);
+ int nSec = JS_GetSecFromTime(dt);
+
+ int nYearSub = 99; //nYear - 2000;
+
+ FX_BOOL bPm = FALSE;
+ FX_BOOL bExit = FALSE;
+ bWrongFormat = FALSE;
+
+ int i=0;
+ int j=0;
+
+ while (i < format.GetLength())
+ {
+ if (bExit) break;
+
+ FX_WCHAR c = format.GetAt(i);
+ switch (c)
+ {
+ case ':':
+ case '.':
+ case '-':
+ case '\\':
+ case '/':
+ i++;
+ j++;
+ break;
+
+ case 'y':
+ case 'm':
+ case 'd':
+ case 'H':
+ case 'h':
+ case 'M':
+ case 's':
+ case 't':
+ {
+ int oldj = j;
+ int nSkip = 0;
+ int remaining = format.GetLength() - i - 1;
+
+ if (remaining == 0 || format.GetAt(i+1) != c)
+ {
+ switch (c)
+ {
+ case 'y':
+ i++;
+ j++;
+ break;
+ case 'm':
+ nMonth = ParseStringInteger(value, j, nSkip, 2);
+ i++;
+ j += nSkip;
+ break;
+ case 'd':
+ nDay = ParseStringInteger(value, j, nSkip, 2);
+ i++;
+ j += nSkip;
+ break;
+ case 'H':
+ nHour = ParseStringInteger(value, j, nSkip, 2);
+ i++;
+ j += nSkip;
+ break;
+ case 'h':
+ nHour = ParseStringInteger(value, j, nSkip, 2);
+ i++;
+ j += nSkip;
+ break;
+ case 'M':
+ nMin = ParseStringInteger(value, j, nSkip, 2);
+ i++;
+ j += nSkip;
+ break;
+ case 's':
+ nSec = ParseStringInteger(value, j, nSkip, 2);
+ i++;
+ j += nSkip;
+ break;
+ case 't':
+ bPm = (j < value.GetLength() && value.GetAt(j) == 'p');
+ i++;
+ j++;
+ break;
+ }
+ }
+ else if (remaining == 1 || format.GetAt(i+2) != c)
+ {
+ switch (c)
+ {
+ case 'y':
+ nYear = ParseStringInteger(value, j, nSkip, 4);
+ i += 2;
+ j += nSkip;
+ break;
+ case 'm':
+ nMonth = ParseStringInteger(value, j, nSkip, 2);
+ i += 2;
+ j += nSkip;
+ break;
+ case 'd':
+ nDay = ParseStringInteger(value, j, nSkip, 2);
+ i += 2;
+ j += nSkip;
+ break;
+ case 'H':
+ nHour = ParseStringInteger(value, j, nSkip, 2);
+ i += 2;
+ j += nSkip;
+ break;
+ case 'h':
+ nHour = ParseStringInteger(value, j, nSkip, 2);
+ i += 2;
+ j += nSkip;
+ break;
+ case 'M':
+ nMin = ParseStringInteger(value, j, nSkip, 2);
+ i += 2;
+ j += nSkip;
+ break;
+ case 's':
+ nSec = ParseStringInteger(value, j, nSkip, 2);
+ i += 2;
+ j += nSkip;
+ break;
+ case 't':
+ bPm = (j + 1 < value.GetLength() && value.GetAt(j) == 'p' && value.GetAt(j+1) == 'm');
+ i += 2;
+ j += 2;
+ break;
+ }
+ }
+ else if (remaining == 2 || format.GetAt(i+3) != c)
+ {
+ switch (c)
+ {
+ case 'm':
+ {
+ CFX_WideString sMonth = ParseStringString(value, j, nSkip);
+ FX_BOOL bFind = FALSE;
+ for (int m = 0; m < 12; m++)
+ {
+ if (sMonth.CompareNoCase(months[m]) == 0)
+ {
+ nMonth = m + 1;
+ i+=3;
+ j+=nSkip;
+ bFind = TRUE;
+ break;
+ }
+ }
+
+ if (!bFind)
+ {
+ nMonth = ParseStringInteger(value, j, nSkip, 3);
+ i+=3;
+ j += nSkip;
+ }
+ }
+ break;
+ case 'y':
+ break;
+ default:
+ i+=3;
+ j+=3;
+ break;
+ }
+ }
+ else if (remaining == 3 || format.GetAt(i+4) != c)
+ {
+ switch (c)
+ {
+
+
+ case 'y':
+ nYear = ParseStringInteger(value, j, nSkip, 4);
+ j += nSkip;
+ i += 4;
+ break;
+ case 'm':
+ {
+ FX_BOOL bFind = FALSE;
+
+ CFX_WideString sMonth = ParseStringString(value, j, nSkip);
+ sMonth.MakeLower();
+
+ for (int m = 0; m < 12; m++)
+ {
+ CFX_WideString sFullMonths = fullmonths[m];
+ sFullMonths.MakeLower();
+
+ if (sFullMonths.Find(sMonth.c_str(), 0) != -1)
+ {
+ nMonth = m + 1;
+ i += 4;
+ j += nSkip;
+ bFind = TRUE;
+ break;
+ }
+ }
+
+ if (!bFind)
+ {
+ nMonth = ParseStringInteger(value, j, nSkip, 4);
+ i+=4;
+ j += nSkip;
+ }
+ }
+ break;
+ default:
+ i += 4;
+ j += 4;
+ break;
+ }
+ }
+ else
+ {
+ if (j >= value.GetLength() || format.GetAt(i) != value.GetAt(j))
+ {
+ bWrongFormat = TRUE;
+ bExit = TRUE;
+ }
+ i++;
+ j++;
+ }
+
+ if (oldj == j)
+ {
+ bWrongFormat = TRUE;
+ bExit = TRUE;
+ }
+ }
+
+ break;
+ default:
+ if (value.GetLength() <= j)
+ {
+ bExit = TRUE;
+ }
+ else if (format.GetAt(i) != value.GetAt(j))
+ {
+ bWrongFormat = TRUE;
+ bExit = TRUE;
+ }
+
+ i++;
+ j++;
+ break;
+ }
+ }
+
+ if (bPm) nHour += 12;
+
+ if (nYear >= 0 && nYear <= nYearSub)
+ nYear += 2000;
+
+ if (nMonth < 1 || nMonth > 12)
+ bWrongFormat = TRUE;
+
+ if (nDay < 1 || nDay > 31)
+ bWrongFormat = TRUE;
+
+ if (nHour < 0 || nHour > 24)
+ bWrongFormat = TRUE;
+
+ if (nMin < 0 || nMin > 60)
+ bWrongFormat = TRUE;
+
+ if (nSec < 0 || nSec > 60)
+ bWrongFormat = TRUE;
+
+ double dRet = 0;
+
+ if (bWrongFormat)
+ {
+ dRet = ParseNormalDate(value, bWrongFormat);
+ }
+ else
+ {
+ dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0));
+
+ if (JS_PortIsNan(dRet))
+ {
+ dRet = JS_DateParse(value.c_str());
+ }
+ }
+
+ if (JS_PortIsNan(dRet))
+ {
+ dRet = ParseNormalDate(value, bWrongFormat);
+ }
+
+ return dRet;
}
CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideString & format)
{
- CFX_WideString sRet = L"",sPart = L"";
-
- int nYear = JS_GetYearFromTime(dDate);
- int nMonth = JS_GetMonthFromTime(dDate) + 1;
- int nDay = JS_GetDayFromTime(dDate);
- int nHour = JS_GetHourFromTime(dDate);
- int nMin = JS_GetMinFromTime(dDate);
- int nSec = JS_GetSecFromTime(dDate);
-
- int i = 0;
- while (i < format.GetLength())
- {
- FX_WCHAR c = format.GetAt(i);
+ CFX_WideString sRet = L"",sPart = L"";
+
+ int nYear = JS_GetYearFromTime(dDate);
+ int nMonth = JS_GetMonthFromTime(dDate) + 1;
+ int nDay = JS_GetDayFromTime(dDate);
+ int nHour = JS_GetHourFromTime(dDate);
+ int nMin = JS_GetMinFromTime(dDate);
+ int nSec = JS_GetSecFromTime(dDate);
+
+ int i = 0;
+ while (i < format.GetLength())
+ {
+ FX_WCHAR c = format.GetAt(i);
int remaining = format.GetLength() - i - 1;
- sPart = L"";
- switch (c)
- {
- case 'y':
- case 'm':
- case 'd':
- case 'H':
- case 'h':
- case 'M':
- case 's':
- case 't':
- if (remaining == 0 || format.GetAt(i+1) != c)
- {
- switch (c)
- {
- case 'y':
- sPart += c;
- break;
- case 'm':
- sPart.Format(L"%d",nMonth);
- break;
- case 'd':
- sPart.Format(L"%d",nDay);
- break;
- case 'H':
- sPart.Format(L"%d",nHour);
- break;
- case 'h':
- sPart.Format(L"%d",nHour>12?nHour - 12:nHour);
- break;
- case 'M':
- sPart.Format(L"%d",nMin);
- break;
- case 's':
- sPart.Format(L"%d",nSec);
- break;
- case 't':
- sPart += nHour>12?'p':'a';
- break;
- }
- i++;
- }
- else if (remaining == 1 || format.GetAt(i+2) != c)
- {
- switch (c)
- {
- case 'y':
- sPart.Format(L"%02d",nYear - (nYear / 100) * 100);
- break;
- case 'm':
- sPart.Format(L"%02d",nMonth);
- break;
- case 'd':
- sPart.Format(L"%02d",nDay);
- break;
- case 'H':
- sPart.Format(L"%02d",nHour);
- break;
- case 'h':
- sPart.Format(L"%02d",nHour>12?nHour - 12:nHour);
- break;
- case 'M':
- sPart.Format(L"%02d",nMin);
- break;
- case 's':
- sPart.Format(L"%02d",nSec);
- break;
- case 't':
- sPart = nHour>12? L"pm": L"am";
- break;
- }
- i+=2;
- }
- else if (remaining == 2 || format.GetAt(i+3) != c)
- {
- switch (c)
- {
- case 'm':
- i+=3;
- if (nMonth > 0&&nMonth <= 12)
- sPart += months[nMonth - 1];
- break;
- default:
- i+=3;
- sPart += c;
- sPart += c;
- sPart += c;
- break;
- }
- }
- else if (remaining == 3 || format.GetAt(i+4) != c)
- {
- switch (c)
- {
- case 'y':
- sPart.Format(L"%04d",nYear);
- i += 4;
- break;
- case 'm':
- i+=4;
- if (nMonth > 0&&nMonth <= 12)
- sPart += fullmonths[nMonth - 1];
- break;
- default:
- i += 4;
- sPart += c;
- sPart += c;
- sPart += c;
- sPart += c;
- break;
- }
- }
- else
- {
- i++;
- sPart += c;
- }
- break;
- default:
- i++;
- sPart += c;
- break;
- }
-
- sRet += sPart;
- }
-
- return sRet;
+ sPart = L"";
+ switch (c)
+ {
+ case 'y':
+ case 'm':
+ case 'd':
+ case 'H':
+ case 'h':
+ case 'M':
+ case 's':
+ case 't':
+ if (remaining == 0 || format.GetAt(i+1) != c)
+ {
+ switch (c)
+ {
+ case 'y':
+ sPart += c;
+ break;
+ case 'm':
+ sPart.Format(L"%d",nMonth);
+ break;
+ case 'd':
+ sPart.Format(L"%d",nDay);
+ break;
+ case 'H':
+ sPart.Format(L"%d",nHour);
+ break;
+ case 'h':
+ sPart.Format(L"%d",nHour>12?nHour - 12:nHour);
+ break;
+ case 'M':
+ sPart.Format(L"%d",nMin);
+ break;
+ case 's':
+ sPart.Format(L"%d",nSec);
+ break;
+ case 't':
+ sPart += nHour>12?'p':'a';
+ break;
+ }
+ i++;
+ }
+ else if (remaining == 1 || format.GetAt(i+2) != c)
+ {
+ switch (c)
+ {
+ case 'y':
+ sPart.Format(L"%02d",nYear - (nYear / 100) * 100);
+ break;
+ case 'm':
+ sPart.Format(L"%02d",nMonth);
+ break;
+ case 'd':
+ sPart.Format(L"%02d",nDay);
+ break;
+ case 'H':
+ sPart.Format(L"%02d",nHour);
+ break;
+ case 'h':
+ sPart.Format(L"%02d",nHour>12?nHour - 12:nHour);
+ break;
+ case 'M':
+ sPart.Format(L"%02d",nMin);
+ break;
+ case 's':
+ sPart.Format(L"%02d",nSec);
+ break;
+ case 't':
+ sPart = nHour>12? L"pm": L"am";
+ break;
+ }
+ i+=2;
+ }
+ else if (remaining == 2 || format.GetAt(i+3) != c)
+ {
+ switch (c)
+ {
+ case 'm':
+ i+=3;
+ if (nMonth > 0&&nMonth <= 12)
+ sPart += months[nMonth - 1];
+ break;
+ default:
+ i+=3;
+ sPart += c;
+ sPart += c;
+ sPart += c;
+ break;
+ }
+ }
+ else if (remaining == 3 || format.GetAt(i+4) != c)
+ {
+ switch (c)
+ {
+ case 'y':
+ sPart.Format(L"%04d",nYear);
+ i += 4;
+ break;
+ case 'm':
+ i+=4;
+ if (nMonth > 0&&nMonth <= 12)
+ sPart += fullmonths[nMonth - 1];
+ break;
+ default:
+ i += 4;
+ sPart += c;
+ sPart += c;
+ sPart += c;
+ sPart += c;
+ break;
+ }
+ }
+ else
+ {
+ i++;
+ sPart += c;
+ }
+ break;
+ default:
+ i++;
+ sPart += c;
+ break;
+ }
+
+ sRet += sPart;
+ }
+
+ return sRet;
}
/* -------------------------------------------------------------------------- */
@@ -1024,337 +1024,334 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideStr
FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
#if _FX_OS_ != _FX_ANDROID_
- v8::Isolate* isolate = ::GetIsolate(cc);
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if (params.size() != 6)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
- if(!pEvent->m_pValue)
- return FALSE;
- CFX_WideString& Value = pEvent->Value();
- CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
-
- if (strValue.IsEmpty()) return TRUE;
-
- int iDec = params[0].ToInt();
- int iSepStyle = params[1].ToInt();
- int iNegStyle = params[2].ToInt();
- // params[3] is iCurrStyle, it's not used.
- std::wstring wstrCurrency(params[4].ToCFXWideString().c_str());
- FX_BOOL bCurrencyPrepend = params[5].ToBool();
-
- if (iDec < 0) iDec = -iDec;
-
- if (iSepStyle < 0 || iSepStyle > 3)
- iSepStyle = 0;
-
- if (iNegStyle < 0 || iNegStyle > 3)
- iNegStyle = 0;
-
-
- //////////////////////////////////////////////////////
- //for processing decimal places
- strValue.Replace(",", ".");
- double dValue = atof(strValue);
- if (iDec > 0)
- dValue += DOUBLE_CORRECT;
-
- int iDec2;
- FX_BOOL bNegative = FALSE;
-
- strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
- if (strValue.IsEmpty())
- {
- dValue = 0;
- strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
- if (strValue.IsEmpty())
- {
- strValue = "0";
- iDec2 = 1;
- }
-
- }
-
- if (iDec2 < 0)
- {
- for (int iNum = 0;iNum < abs(iDec2);iNum++)
- {
- strValue = "0" + strValue;
- }
- iDec2 = 0;
-
- }
- int iMax = strValue.GetLength();
- if (iDec2 > iMax)
- {
- for (int iNum = 0;iNum <= iDec2 - iMax ;iNum++)
- {
- strValue += "0";
- }
- iMax = iDec2+1;
- }
- ///////////////////////////////////////////////////////
+ v8::Isolate* isolate = ::GetIsolate(cc);
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if (params.size() != 6)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+ if(!pEvent->m_pValue)
+ return FALSE;
+ CFX_WideString& Value = pEvent->Value();
+ CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
+
+ if (strValue.IsEmpty()) return TRUE;
+
+ int iDec = params[0].ToInt();
+ int iSepStyle = params[1].ToInt();
+ int iNegStyle = params[2].ToInt();
+ // params[3] is iCurrStyle, it's not used.
+ std::wstring wstrCurrency(params[4].ToCFXWideString().c_str());
+ FX_BOOL bCurrencyPrepend = params[5].ToBool();
+
+ if (iDec < 0) iDec = -iDec;
+
+ if (iSepStyle < 0 || iSepStyle > 3)
+ iSepStyle = 0;
+
+ if (iNegStyle < 0 || iNegStyle > 3)
+ iNegStyle = 0;
+
+
+ //////////////////////////////////////////////////////
+ //for processing decimal places
+ strValue.Replace(",", ".");
+ double dValue = atof(strValue);
+ if (iDec > 0)
+ dValue += DOUBLE_CORRECT;
+
+ int iDec2;
+ FX_BOOL bNegative = FALSE;
+
+ strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
+ if (strValue.IsEmpty())
+ {
+ dValue = 0;
+ strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
+ if (strValue.IsEmpty())
+ {
+ strValue = "0";
+ iDec2 = 1;
+ }
+
+ }
+
+ if (iDec2 < 0)
+ {
+ for (int iNum = 0;iNum < abs(iDec2);iNum++)
+ {
+ strValue = "0" + strValue;
+ }
+ iDec2 = 0;
+
+ }
+ int iMax = strValue.GetLength();
+ if (iDec2 > iMax)
+ {
+ for (int iNum = 0;iNum <= iDec2 - iMax ;iNum++)
+ {
+ strValue += "0";
+ }
+ iMax = iDec2+1;
+ }
+ ///////////////////////////////////////////////////////
//for processing seperator style
- if (iDec2 < iMax)
- {
- if (iSepStyle == 0 || iSepStyle == 1)
- {
- strValue.Insert(iDec2, '.');
- iMax++;
- }
- else if (iSepStyle == 2 || iSepStyle == 3)
- {
- strValue.Insert(iDec2, ',');
- iMax++;
- }
-
- if (iDec2 == 0)
- strValue.Insert(iDec2, '0');
- }
- if (iSepStyle == 0 || iSepStyle == 2)
- {
- char cSeperator;
- if (iSepStyle == 0)
- cSeperator = ',';
- else
- cSeperator = '.';
-
- int iDecPositive;
- iDecPositive = iDec2;
-
- for (iDecPositive = iDec2 -3; iDecPositive > 0;iDecPositive -= 3)
- {
- strValue.Insert(iDecPositive, cSeperator);
- iMax++;
- }
- }
-
- //////////////////////////////////////////////////////////////////////
+ if (iDec2 < iMax)
+ {
+ if (iSepStyle == 0 || iSepStyle == 1)
+ {
+ strValue.Insert(iDec2, '.');
+ iMax++;
+ }
+ else if (iSepStyle == 2 || iSepStyle == 3)
+ {
+ strValue.Insert(iDec2, ',');
+ iMax++;
+ }
+
+ if (iDec2 == 0)
+ strValue.Insert(iDec2, '0');
+ }
+ if (iSepStyle == 0 || iSepStyle == 2)
+ {
+ char cSeperator;
+ if (iSepStyle == 0)
+ cSeperator = ',';
+ else
+ cSeperator = '.';
+
+ int iDecPositive;
+ iDecPositive = iDec2;
+
+ for (iDecPositive = iDec2 -3; iDecPositive > 0;iDecPositive -= 3)
+ {
+ strValue.Insert(iDecPositive, cSeperator);
+ iMax++;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
//for processing currency string
- Value = CFX_WideString::FromLocal(strValue);
- std::wstring strValue2 = Value.c_str();
-
- if (bCurrencyPrepend)
- strValue2 = wstrCurrency + strValue2;
- else
- strValue2 = strValue2 + wstrCurrency;
-
-
-
- /////////////////////////////////////////////////////////////////////////
- //for processing negative style
- if (bNegative)
- {
- if (iNegStyle == 0)
- {
- strValue2.insert(0,L"-");
- }
- if (iNegStyle == 2 || iNegStyle == 3)
- {
- strValue2.insert(0,L"(");
- strValue2.insert(strValue2.length(),L")");
- }
- if (iNegStyle == 1 || iNegStyle == 3)
- {
- if (Field * fTarget = pEvent->Target_Field())
- {
- CJS_Array arColor(isolate);
- CJS_Value vColElm(isolate);
- vColElm = L"RGB";
- arColor.SetElement(0,vColElm);
- vColElm = 1;
- arColor.SetElement(1,vColElm);
- vColElm = 0;
- arColor.SetElement(2,vColElm);
-
- arColor.SetElement(3,vColElm);
-
- CJS_PropValue vProp(isolate);
- vProp.StartGetting();
- vProp<<arColor;
- vProp.StartSetting();
- fTarget->textColor(cc,vProp,sError);// red
- }
- }
- }
- else
- {
- if (iNegStyle == 1 || iNegStyle == 3)
- {
- if (Field *fTarget = pEvent->Target_Field())
- {
- CJS_Array arColor(isolate);
- CJS_Value vColElm(isolate);
- vColElm = L"RGB";
- arColor.SetElement(0,vColElm);
- vColElm = 0;
- arColor.SetElement(1,vColElm);
- arColor.SetElement(2,vColElm);
- arColor.SetElement(3,vColElm);
-
- CJS_PropValue vProp(isolate);
- vProp.StartGetting();
- fTarget->textColor(cc,vProp,sError);
-
- CJS_Array aProp(isolate);
- vProp.ConvertToArray(aProp);
-
- CPWL_Color crProp;
- CPWL_Color crColor;
- color::ConvertArrayToPWLColor(aProp, crProp);
- color::ConvertArrayToPWLColor(arColor, crColor);
-
- if (crColor != crProp)
- {
- CJS_PropValue vProp2(isolate);
- vProp2.StartGetting();
- vProp2<<arColor;
- vProp2.StartSetting();
- fTarget->textColor(cc,vProp2,sError);
- }
- }
- }
- }
- Value = strValue2.c_str();
+ Value = CFX_WideString::FromLocal(strValue);
+ std::wstring strValue2 = Value.c_str();
+
+ if (bCurrencyPrepend)
+ strValue2 = wstrCurrency + strValue2;
+ else
+ strValue2 = strValue2 + wstrCurrency;
+
+
+
+ /////////////////////////////////////////////////////////////////////////
+ //for processing negative style
+ if (bNegative)
+ {
+ if (iNegStyle == 0)
+ {
+ strValue2.insert(0,L"-");
+ }
+ if (iNegStyle == 2 || iNegStyle == 3)
+ {
+ strValue2.insert(0,L"(");
+ strValue2.insert(strValue2.length(),L")");
+ }
+ if (iNegStyle == 1 || iNegStyle == 3)
+ {
+ if (Field * fTarget = pEvent->Target_Field())
+ {
+ CJS_Array arColor(isolate);
+ CJS_Value vColElm(isolate);
+ vColElm = L"RGB";
+ arColor.SetElement(0,vColElm);
+ vColElm = 1;
+ arColor.SetElement(1,vColElm);
+ vColElm = 0;
+ arColor.SetElement(2,vColElm);
+
+ arColor.SetElement(3,vColElm);
+
+ CJS_PropValue vProp(isolate);
+ vProp.StartGetting();
+ vProp<<arColor;
+ vProp.StartSetting();
+ fTarget->textColor(cc,vProp,sError);// red
+ }
+ }
+ }
+ else
+ {
+ if (iNegStyle == 1 || iNegStyle == 3)
+ {
+ if (Field *fTarget = pEvent->Target_Field())
+ {
+ CJS_Array arColor(isolate);
+ CJS_Value vColElm(isolate);
+ vColElm = L"RGB";
+ arColor.SetElement(0,vColElm);
+ vColElm = 0;
+ arColor.SetElement(1,vColElm);
+ arColor.SetElement(2,vColElm);
+ arColor.SetElement(3,vColElm);
+
+ CJS_PropValue vProp(isolate);
+ vProp.StartGetting();
+ fTarget->textColor(cc,vProp,sError);
+
+ CJS_Array aProp(isolate);
+ vProp.ConvertToArray(aProp);
+
+ CPWL_Color crProp;
+ CPWL_Color crColor;
+ color::ConvertArrayToPWLColor(aProp, crProp);
+ color::ConvertArrayToPWLColor(arColor, crColor);
+
+ if (crColor != crProp)
+ {
+ CJS_PropValue vProp2(isolate);
+ vProp2.StartGetting();
+ vProp2<<arColor;
+ vProp2.StartSetting();
+ fTarget->textColor(cc,vProp2,sError);
+ }
+ }
+ }
+ }
+ Value = strValue2.c_str();
#endif
- return TRUE;
+ return TRUE;
}
//function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend)
FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if(params.size() < 2)
- return FALSE;
- int iSepStyle = params[1].ToInt();
-
- if (iSepStyle < 0 || iSepStyle > 3)
- iSepStyle = 0;
- if(!pEvent->m_pValue)
- return FALSE;
- CFX_WideString & val = pEvent->Value();
- CFX_WideString & w_strChange = pEvent->Change();
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if(params.size() < 2)
+ return FALSE;
+ int iSepStyle = params[1].ToInt();
+
+ if (iSepStyle < 0 || iSepStyle > 3)
+ iSepStyle = 0;
+ if(!pEvent->m_pValue)
+ return FALSE;
+ CFX_WideString & val = pEvent->Value();
+ CFX_WideString & w_strChange = pEvent->Change();
CFX_WideString w_strValue = val;
- if (pEvent->WillCommit())
- {
- CFX_WideString wstrChange = w_strChange;
- CFX_WideString wstrValue = StrLTrim(w_strValue.c_str());
- if (wstrValue.IsEmpty())
- return TRUE;
-
- CFX_WideString swTemp = wstrValue;
- swTemp.Replace(L",", L".");
- if (!IsNumber(swTemp.c_str()))
- {
- pEvent->Rc() = FALSE;
- sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
- Alert(pContext, sError.c_str());
- return TRUE;
- }
- return TRUE; // it happens after the last keystroke and before validating,
- }
-
- std::wstring w_strValue2 = w_strValue.c_str();
- std::wstring w_strChange2 = w_strChange.c_str();
- std::wstring w_strSelected;
- if(-1 != pEvent->SelStart())
- w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart()));
- FX_BOOL bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find('-') == -1);
- if (bHasSign)
- {
- //can't insert "change" in front to sign postion.
- if (pEvent->SelStart() == 0)
- {
+ if (pEvent->WillCommit())
+ {
+ CFX_WideString wstrChange = w_strChange;
+ CFX_WideString wstrValue = StrLTrim(w_strValue.c_str());
+ if (wstrValue.IsEmpty())
+ return TRUE;
+
+ CFX_WideString swTemp = wstrValue;
+ swTemp.Replace(L",", L".");
+ if (!IsNumber(swTemp.c_str()))
+ {
+ pEvent->Rc() = FALSE;
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
+ Alert(pContext, sError.c_str());
+ return TRUE;
+ }
+ return TRUE; // it happens after the last keystroke and before validating,
+ }
+
+ std::wstring w_strValue2 = w_strValue.c_str();
+ std::wstring w_strChange2 = w_strChange.c_str();
+ std::wstring w_strSelected;
+ if(-1 != pEvent->SelStart())
+ w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart()));
+ FX_BOOL bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find('-') == -1);
+ if (bHasSign)
+ {
+ //can't insert "change" in front to sign postion.
+ if (pEvent->SelStart() == 0)
+ {
+ FX_BOOL &bRc = pEvent->Rc();
+ bRc = FALSE;
+ return TRUE;
+ }
+ }
+
+ char cSep = L'.';
+
+ switch (iSepStyle)
+ {
+ case 0:
+ case 1:
+ cSep = L'.';
+ break;
+ case 2:
+ case 3:
+ cSep = L',';
+ break;
+ }
+
+ FX_BOOL bHasSep = (w_strValue2.find(cSep) != -1);
+ for (std::wstring::iterator it = w_strChange2.begin(); it != w_strChange2.end(); it++)
+ {
+ if (*it == cSep)
+ {
+ if (bHasSep)
+ {
+ FX_BOOL &bRc = pEvent->Rc();
+ bRc = FALSE;
+ return TRUE;
+ }
+ bHasSep = TRUE;
+ continue;
+ }
+ if (*it == L'-')
+ {
+ if (bHasSign)
+ {
+ FX_BOOL &bRc = pEvent->Rc();
+ bRc = FALSE;
+ return TRUE;
+ }
+ if (it != w_strChange2.begin()) //sign's position is not correct
+ {
+ FX_BOOL &bRc = pEvent->Rc();
+ bRc = FALSE;
+ return TRUE;
+ }
+ if (pEvent->SelStart() != 0)
+ {
+ FX_BOOL &bRc = pEvent->Rc();
+ bRc = FALSE;
+ return TRUE;
+ }
+ bHasSign = TRUE;
+ continue;
+ }
+
+ if (!IsDigit(*it))
+ {
FX_BOOL &bRc = pEvent->Rc();
- bRc = FALSE;
- return TRUE;
- }
- }
-
- char cSep = L'.';
-
- switch (iSepStyle)
- {
- case 0:
- case 1:
- cSep = L'.';
- break;
- case 2:
- case 3:
- cSep = L',';
- break;
- }
-
- FX_BOOL bHasSep = (w_strValue2.find(cSep) != -1);
- for (std::wstring::iterator it = w_strChange2.begin(); it != w_strChange2.end(); it++)
- {
- if (*it == cSep)
- {
- if (bHasSep)
- {
- FX_BOOL &bRc = pEvent->Rc();
- bRc = FALSE;
- return TRUE;
- }
- else
- {
- bHasSep = TRUE;
- continue;
- }
- }
- if (*it == L'-')
- {
- if (bHasSign)
- {
- FX_BOOL &bRc = pEvent->Rc();
- bRc = FALSE;
- return TRUE;
- }
- else if (it != w_strChange2.begin()) //sign's position is not correct
- {
- FX_BOOL &bRc = pEvent->Rc();
- bRc = FALSE;
- return TRUE;
- }
- else if (pEvent->SelStart() != 0)
- {
- FX_BOOL &bRc = pEvent->Rc();
- bRc = FALSE;
- return TRUE;
- }
- bHasSign = TRUE;
- continue;
- }
-
- if (!IsDigit(*it))
- {
- FX_BOOL &bRc = pEvent->Rc();
- bRc = FALSE;
- return TRUE;
- }
- }
-
-
- std::wstring w_prefix = w_strValue2.substr(0,pEvent->SelStart());
- std::wstring w_postfix;
- if (pEvent->SelEnd()<(int)w_strValue2.length())
- w_postfix = w_strValue2.substr(pEvent->SelEnd());
- w_strValue2 = w_prefix + w_strChange2 + w_postfix;
- w_strValue = w_strValue2.c_str();
- val = w_strValue;
- return TRUE;
+ bRc = FALSE;
+ return TRUE;
+ }
+ }
+
+
+ std::wstring w_prefix = w_strValue2.substr(0,pEvent->SelStart());
+ std::wstring w_postfix;
+ if (pEvent->SelEnd()<(int)w_strValue2.length())
+ w_postfix = w_strValue2.substr(pEvent->SelEnd());
+ w_strValue2 = w_prefix + w_strChange2 + w_postfix;
+ w_strValue = w_strValue2.c_str();
+ val = w_strValue;
+ return TRUE;
}
@@ -1362,810 +1359,810 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param
FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
#if _FX_OS_ != _FX_ANDROID_
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
if (params.size() != 2)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
- if(!pEvent->m_pValue)
- return FALSE;
-
- CFX_WideString& Value = pEvent->Value();
- CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
- if (strValue.IsEmpty())
- return TRUE;
-
- int iDec = params[0].ToInt();
- if (iDec < 0)
- iDec = -iDec;
-
- int iSepStyle = params[1].ToInt();
- if (iSepStyle < 0 || iSepStyle > 3)
- iSepStyle = 0;
-
- //////////////////////////////////////////////////////
- //for processing decimal places
- double dValue = atof(strValue);
- dValue *= 100;
- if (iDec > 0)
- dValue += DOUBLE_CORRECT;//УÕý
-
- int iDec2;
- FX_BOOL bNegative = FALSE;
- strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+ if(!pEvent->m_pValue)
+ return FALSE;
+
+ CFX_WideString& Value = pEvent->Value();
+ CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
+ if (strValue.IsEmpty())
+ return TRUE;
+
+ int iDec = params[0].ToInt();
+ if (iDec < 0)
+ iDec = -iDec;
+
+ int iSepStyle = params[1].ToInt();
+ if (iSepStyle < 0 || iSepStyle > 3)
+ iSepStyle = 0;
+
+ //////////////////////////////////////////////////////
+ //for processing decimal places
+ double dValue = atof(strValue);
+ dValue *= 100;
+ if (iDec > 0)
+ dValue += DOUBLE_CORRECT;//УÕý
+
+ int iDec2;
+ FX_BOOL bNegative = FALSE;
+ strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
if (strValue.IsEmpty())
- {
- dValue = 0;
- strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
- }
-
- if (iDec2 < 0)
- {
- for (int iNum = 0; iNum < abs(iDec2); iNum++)
- {
- strValue = "0" + strValue;
- }
- iDec2 = 0;
-
- }
- int iMax = strValue.GetLength();
- if (iDec2 > iMax)
- {
- for (int iNum = 0; iNum <= iDec2 - iMax; iNum++)
- {
- strValue += "0";
- }
- iMax = iDec2+1;
- }
- ///////////////////////////////////////////////////////
+ {
+ dValue = 0;
+ strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
+ }
+
+ if (iDec2 < 0)
+ {
+ for (int iNum = 0; iNum < abs(iDec2); iNum++)
+ {
+ strValue = "0" + strValue;
+ }
+ iDec2 = 0;
+
+ }
+ int iMax = strValue.GetLength();
+ if (iDec2 > iMax)
+ {
+ for (int iNum = 0; iNum <= iDec2 - iMax; iNum++)
+ {
+ strValue += "0";
+ }
+ iMax = iDec2+1;
+ }
+ ///////////////////////////////////////////////////////
//for processing seperator style
- if (iDec2 < iMax)
- {
- if (iSepStyle == 0 || iSepStyle == 1)
- {
- strValue.Insert(iDec2, '.');
- iMax++;
- }
- else if (iSepStyle == 2 || iSepStyle == 3)
- {
- strValue.Insert(iDec2, ',');
- iMax++;
- }
-
- if (iDec2 == 0)
- strValue.Insert(iDec2, '0');
- }
- if (iSepStyle == 0 || iSepStyle == 2)
- {
- char cSeperator;
- if (iSepStyle == 0)
- cSeperator = ',';
- else
- cSeperator = '.';
-
- int iDecPositive;
- iDecPositive = iDec2;
-
- for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3)
- {
- strValue.Insert(iDecPositive,cSeperator);
- iMax++;
- }
- }
- ////////////////////////////////////////////////////////////////////
- //negative mark
- if(bNegative)
- strValue = "-" + strValue;
- strValue += "%";
- Value = CFX_WideString::FromLocal(strValue);
+ if (iDec2 < iMax)
+ {
+ if (iSepStyle == 0 || iSepStyle == 1)
+ {
+ strValue.Insert(iDec2, '.');
+ iMax++;
+ }
+ else if (iSepStyle == 2 || iSepStyle == 3)
+ {
+ strValue.Insert(iDec2, ',');
+ iMax++;
+ }
+
+ if (iDec2 == 0)
+ strValue.Insert(iDec2, '0');
+ }
+ if (iSepStyle == 0 || iSepStyle == 2)
+ {
+ char cSeperator;
+ if (iSepStyle == 0)
+ cSeperator = ',';
+ else
+ cSeperator = '.';
+
+ int iDecPositive;
+ iDecPositive = iDec2;
+
+ for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3)
+ {
+ strValue.Insert(iDecPositive,cSeperator);
+ iMax++;
+ }
+ }
+ ////////////////////////////////////////////////////////////////////
+ //negative mark
+ if(bNegative)
+ strValue = "-" + strValue;
+ strValue += "%";
+ Value = CFX_WideString::FromLocal(strValue);
#endif
- return TRUE;
+ return TRUE;
}
//AFPercent_Keystroke(nDec, sepStyle)
FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return AFNumber_Keystroke(cc,params,vRet,sError);
+ return AFNumber_Keystroke(cc,params,vRet,sError);
}
//function AFDate_FormatEx(cFormat)
FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if (params.size() != 1)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
- if(!pEvent->m_pValue)
- return FALSE;
-
- CFX_WideString& val = pEvent->Value();
- CFX_WideString strValue = val;
- if (strValue.IsEmpty())
- return TRUE;
-
- CFX_WideString sFormat = params[0].ToCFXWideString();
- FX_BOOL bWrongFormat = FALSE;
- double dDate = 0.0f;
-
- if(strValue.Find(L"GMT") != -1)
- {
- //for GMT format time
- //such as "Tue Aug 11 14:24:16 GMT+08002009"
- dDate = MakeInterDate(strValue);
- }
- else
- {
- dDate = MakeRegularDate(strValue,sFormat,bWrongFormat);
- }
-
- if (JS_PortIsNan(dDate))
- {
- CFX_WideString swMsg;
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
- Alert(pContext, swMsg.c_str());
- return FALSE;
- }
-
- val = MakeFormatDate(dDate,sFormat);
- return TRUE;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if (params.size() != 1)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+ if(!pEvent->m_pValue)
+ return FALSE;
+
+ CFX_WideString& val = pEvent->Value();
+ CFX_WideString strValue = val;
+ if (strValue.IsEmpty())
+ return TRUE;
+
+ CFX_WideString sFormat = params[0].ToCFXWideString();
+ FX_BOOL bWrongFormat = FALSE;
+ double dDate = 0.0f;
+
+ if(strValue.Find(L"GMT") != -1)
+ {
+ //for GMT format time
+ //such as "Tue Aug 11 14:24:16 GMT+08002009"
+ dDate = MakeInterDate(strValue);
+ }
+ else
+ {
+ dDate = MakeRegularDate(strValue,sFormat,bWrongFormat);
+ }
+
+ if (JS_PortIsNan(dDate))
+ {
+ CFX_WideString swMsg;
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+ Alert(pContext, swMsg.c_str());
+ return FALSE;
+ }
+
+ val = MakeFormatDate(dDate,sFormat);
+ return TRUE;
}
double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue)
{
- int nHour;
- int nMin;
- int nSec;
- int nYear;
- int nMonth;
- int nDay;
-
- CFX_WideStringArray wsArray;
- CFX_WideString sMonth = L"";
- CFX_WideString sTemp = L"";
- int nSize = strValue.GetLength();
-
- for(int i = 0; i < nSize; i++)
- {
- FX_WCHAR c = strValue.GetAt(i);
- if(c == L' ' || c == L':')
- {
- wsArray.Add(sTemp);
- sTemp = L"";
- continue;
- }
-
- sTemp += c;
- }
-
- wsArray.Add(sTemp);
- if(wsArray.GetSize() != 8)return 0;
-
- sTemp = wsArray[1];
- if(sTemp.Compare(L"Jan") == 0) nMonth = 1;
- if(sTemp.Compare(L"Feb") == 0) nMonth = 2;
- if(sTemp.Compare(L"Mar") == 0) nMonth = 3;
- if(sTemp.Compare(L"Apr") == 0) nMonth = 4;
- if(sTemp.Compare(L"May") == 0) nMonth = 5;
- if(sTemp.Compare(L"Jun") == 0) nMonth = 6;
- if(sTemp.Compare(L"Jul") == 0) nMonth = 7;
- if(sTemp.Compare(L"Aug") == 0) nMonth = 8;
- if(sTemp.Compare(L"Sep") == 0) nMonth = 9;
- if(sTemp.Compare(L"Oct") == 0) nMonth = 10;
- if(sTemp.Compare(L"Nov") == 0) nMonth = 11;
- if(sTemp.Compare(L"Dec") == 0) nMonth = 12;
-
- nDay = (int)ParseStringToNumber(wsArray[2].c_str());
- nHour = (int)ParseStringToNumber(wsArray[3].c_str());
- nMin = (int)ParseStringToNumber(wsArray[4].c_str());
- nSec = (int)ParseStringToNumber(wsArray[5].c_str());
- nYear = (int)ParseStringToNumber(wsArray[7].c_str());
-
- double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0));
-
- if (JS_PortIsNan(dRet))
- {
- dRet = JS_DateParse(strValue.c_str());
- }
-
- return dRet;
+ int nHour;
+ int nMin;
+ int nSec;
+ int nYear;
+ int nMonth;
+ int nDay;
+
+ CFX_WideStringArray wsArray;
+ CFX_WideString sMonth = L"";
+ CFX_WideString sTemp = L"";
+ int nSize = strValue.GetLength();
+
+ for(int i = 0; i < nSize; i++)
+ {
+ FX_WCHAR c = strValue.GetAt(i);
+ if(c == L' ' || c == L':')
+ {
+ wsArray.Add(sTemp);
+ sTemp = L"";
+ continue;
+ }
+
+ sTemp += c;
+ }
+
+ wsArray.Add(sTemp);
+ if(wsArray.GetSize() != 8)return 0;
+
+ sTemp = wsArray[1];
+ if(sTemp.Compare(L"Jan") == 0) nMonth = 1;
+ if(sTemp.Compare(L"Feb") == 0) nMonth = 2;
+ if(sTemp.Compare(L"Mar") == 0) nMonth = 3;
+ if(sTemp.Compare(L"Apr") == 0) nMonth = 4;
+ if(sTemp.Compare(L"May") == 0) nMonth = 5;
+ if(sTemp.Compare(L"Jun") == 0) nMonth = 6;
+ if(sTemp.Compare(L"Jul") == 0) nMonth = 7;
+ if(sTemp.Compare(L"Aug") == 0) nMonth = 8;
+ if(sTemp.Compare(L"Sep") == 0) nMonth = 9;
+ if(sTemp.Compare(L"Oct") == 0) nMonth = 10;
+ if(sTemp.Compare(L"Nov") == 0) nMonth = 11;
+ if(sTemp.Compare(L"Dec") == 0) nMonth = 12;
+
+ nDay = (int)ParseStringToNumber(wsArray[2].c_str());
+ nHour = (int)ParseStringToNumber(wsArray[3].c_str());
+ nMin = (int)ParseStringToNumber(wsArray[4].c_str());
+ nSec = (int)ParseStringToNumber(wsArray[5].c_str());
+ nYear = (int)ParseStringToNumber(wsArray[7].c_str());
+
+ double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0));
+
+ if (JS_PortIsNan(dRet))
+ {
+ dRet = JS_DateParse(strValue.c_str());
+ }
+
+ return dRet;
}
//AFDate_KeystrokeEx(cFormat)
FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if (params.size() != 1)
- {
- sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
- return FALSE;
- }
-
- if (pEvent->WillCommit())
- {
- if(!pEvent->m_pValue)
- return FALSE;
- CFX_WideString strValue = pEvent->Value();
- if (strValue.IsEmpty())
- return TRUE;
-
- CFX_WideString sFormat = params[0].ToCFXWideString();
- FX_BOOL bWrongFormat = FALSE;
- double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat);
- if (bWrongFormat || JS_PortIsNan(dRet))
- {
- CFX_WideString swMsg;
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
- Alert(pContext, swMsg.c_str());
- pEvent->Rc() = FALSE;
- return TRUE;
- }
- }
- return TRUE;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if (params.size() != 1)
+ {
+ sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
+ return FALSE;
+ }
+
+ if (pEvent->WillCommit())
+ {
+ if(!pEvent->m_pValue)
+ return FALSE;
+ CFX_WideString strValue = pEvent->Value();
+ if (strValue.IsEmpty())
+ return TRUE;
+
+ CFX_WideString sFormat = params[0].ToCFXWideString();
+ FX_BOOL bWrongFormat = FALSE;
+ double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat);
+ if (bWrongFormat || JS_PortIsNan(dRet))
+ {
+ CFX_WideString swMsg;
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+ Alert(pContext, swMsg.c_str());
+ pEvent->Rc() = FALSE;
+ return TRUE;
+ }
+ }
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
-
- if (params.size() != 1)
- {
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
-
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- int iIndex = params[0].ToInt();
- const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
- L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
- L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
-
- ASSERT(iIndex < FX_ArraySize(cFormats));
-
- if (iIndex < 0)
- iIndex = 0;
- if (iIndex >= FX_ArraySize(cFormats))
- iIndex = 0;
- CJS_Parameters newParams;
- CJS_Value val(isolate,cFormats[iIndex]);
- newParams.push_back(val);
- return AFDate_FormatEx(cc,newParams,vRet,sError);
+ v8::Isolate* isolate = ::GetIsolate(cc);
+
+ if (params.size() != 1)
+ {
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ int iIndex = params[0].ToInt();
+ const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
+ L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
+ L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
+
+ ASSERT(iIndex < FX_ArraySize(cFormats));
+
+ if (iIndex < 0)
+ iIndex = 0;
+ if (iIndex >= FX_ArraySize(cFormats))
+ iIndex = 0;
+ CJS_Parameters newParams;
+ CJS_Value val(isolate,cFormats[iIndex]);
+ newParams.push_back(val);
+ return AFDate_FormatEx(cc,newParams,vRet,sError);
}
//AFDate_KeystrokeEx(cFormat)
FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
-
- if (params.size() != 1)
- {
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
-
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- int iIndex = params[0].ToInt();
- const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
- L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
- L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
-
- ASSERT(iIndex<FX_ArraySize(cFormats));
-
- if (iIndex < 0)
- iIndex = 0;
- if (iIndex >= FX_ArraySize(cFormats))
- iIndex = 0;
- CJS_Parameters newParams;
- CJS_Value val(isolate,cFormats[iIndex]);
- newParams.push_back(val);
- return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
+ v8::Isolate* isolate = ::GetIsolate(cc);
+
+ if (params.size() != 1)
+ {
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ int iIndex = params[0].ToInt();
+ const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
+ L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
+ L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
+
+ ASSERT(iIndex<FX_ArraySize(cFormats));
+
+ if (iIndex < 0)
+ iIndex = 0;
+ if (iIndex >= FX_ArraySize(cFormats))
+ iIndex = 0;
+ CJS_Parameters newParams;
+ CJS_Value val(isolate,cFormats[iIndex]);
+ newParams.push_back(val);
+ return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
}
//function AFTime_Format(ptf)
FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
-
- if (params.size() != 1)
- {
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- int iIndex = params[0].ToInt();
- const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
-
- ASSERT(iIndex<FX_ArraySize(cFormats));
-
- if (iIndex < 0)
- iIndex = 0;
- if (iIndex >= FX_ArraySize(cFormats))
- iIndex = 0;
- CJS_Parameters newParams;
- CJS_Value val(isolate,cFormats[iIndex]);
- newParams.push_back(val);
- return AFDate_FormatEx(cc,newParams,vRet,sError);
+ v8::Isolate* isolate = ::GetIsolate(cc);
+
+ if (params.size() != 1)
+ {
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ int iIndex = params[0].ToInt();
+ const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
+
+ ASSERT(iIndex<FX_ArraySize(cFormats));
+
+ if (iIndex < 0)
+ iIndex = 0;
+ if (iIndex >= FX_ArraySize(cFormats))
+ iIndex = 0;
+ CJS_Parameters newParams;
+ CJS_Value val(isolate,cFormats[iIndex]);
+ newParams.push_back(val);
+ return AFDate_FormatEx(cc,newParams,vRet,sError);
}
FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
- if (params.size() != 1)
- {
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- int iIndex = params[0].ToInt();
- const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
-
- ASSERT(iIndex<FX_ArraySize(cFormats));
-
- if (iIndex < 0)
- iIndex = 0;
- if (iIndex >= FX_ArraySize(cFormats))
- iIndex = 0;
- CJS_Parameters newParams;
- CJS_Value val(isolate,cFormats[iIndex]);
- newParams.push_back(val);
- return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
+ v8::Isolate* isolate = ::GetIsolate(cc);
+ if (params.size() != 1)
+ {
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ int iIndex = params[0].ToInt();
+ const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
+
+ ASSERT(iIndex<FX_ArraySize(cFormats));
+
+ if (iIndex < 0)
+ iIndex = 0;
+ if (iIndex >= FX_ArraySize(cFormats))
+ iIndex = 0;
+ CJS_Parameters newParams;
+ CJS_Value val(isolate,cFormats[iIndex]);
+ newParams.push_back(val);
+ return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
}
FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return AFDate_FormatEx(cc,params,vRet,sError);
+ return AFDate_FormatEx(cc,params,vRet,sError);
}
FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- return AFDate_KeystrokeEx(cc,params,vRet,sError);
+ return AFDate_KeystrokeEx(cc,params,vRet,sError);
}
//function AFSpecial_Format(psf)
FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
-
- if (params.size() != 1)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- std::string cFormat;
- int iIndex = params[0].ToInt();
-
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if(!pEvent->m_pValue)
- return FALSE;
- CFX_WideString& Value = pEvent->Value();
- std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str();
-
- switch (iIndex)
- {
- case 0:
- cFormat = "99999";
- break;
- case 1:
- cFormat = "99999-9999";
- break;
- case 2:
- {
- std::string NumberStr;
- util::printx("9999999999", strSrc,NumberStr);
- if (NumberStr.length() >= 10 )
- cFormat = "(999) 999-9999";
- else
- cFormat = "999-9999";
- break;
- }
- case 3:
- cFormat = "999-99-9999";
- break;
- }
-
- std::string strDes;
- util::printx(cFormat,strSrc,strDes);
- Value = CFX_WideString::FromLocal(strDes.c_str());
- return TRUE;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+
+ if (params.size() != 1)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ std::string cFormat;
+ int iIndex = params[0].ToInt();
+
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if(!pEvent->m_pValue)
+ return FALSE;
+ CFX_WideString& Value = pEvent->Value();
+ std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str();
+
+ switch (iIndex)
+ {
+ case 0:
+ cFormat = "99999";
+ break;
+ case 1:
+ cFormat = "99999-9999";
+ break;
+ case 2:
+ {
+ std::string NumberStr;
+ util::printx("9999999999", strSrc,NumberStr);
+ if (NumberStr.length() >= 10 )
+ cFormat = "(999) 999-9999";
+ else
+ cFormat = "999-9999";
+ break;
+ }
+ case 3:
+ cFormat = "999-99-9999";
+ break;
+ }
+
+ std::string strDes;
+ util::printx(cFormat,strSrc,strDes);
+ Value = CFX_WideString::FromLocal(strDes.c_str());
+ return TRUE;
}
//function AFSpecial_KeystrokeEx(mask)
FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
-
- ASSERT(pEvent != NULL);
-
- if (params.size() < 1)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- if(!pEvent->m_pValue)
- return FALSE;
- CFX_WideString& valEvent = pEvent->Value();
-
- CFX_WideString wstrMask = params[0].ToCFXWideString();
- if (wstrMask.IsEmpty())
- return TRUE;
-
- std::wstring wstrValue = valEvent.c_str();
-
- if (pEvent->WillCommit())
- {
- if (wstrValue.empty())
- return TRUE;
- int iIndexMask = 0;
- for (std::wstring::iterator it = wstrValue.begin(); it != wstrValue.end(); it++)
- {
- wchar_t w_Value = *it;
- if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
- break;
- iIndexMask++;
- }
-
- if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrValue.size() && wstrMask.GetLength() != 0))
- {
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
- pEvent->Rc() = FALSE;
- }
- return TRUE;
- }
-
- CFX_WideString &wideChange = pEvent->Change();
- std::wstring wChange = wideChange.c_str();
- if (wChange.empty())
- return TRUE;
-
- int iIndexMask = pEvent->SelStart();
-
- if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange.length() > (FX_DWORD)wstrMask.GetLength())
- {
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
- pEvent->Rc() = FALSE;
- return TRUE;
- }
-
- if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty()))
- {
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
- pEvent->Rc() = FALSE;
- return TRUE;
- }
-
- for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++)
- {
- if (iIndexMask >= wstrMask.GetLength())
- {
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
- pEvent->Rc() = FALSE;
- return TRUE;
- }
- wchar_t w_Mask = wstrMask[iIndexMask];
- if (!isReservedMaskChar(w_Mask))
- {
- *it = w_Mask;
- }
- wchar_t w_Change = *it;
- if (!maskSatisfied(w_Change,w_Mask))
- {
- pEvent->Rc() = FALSE;
- return TRUE;
- }
- iIndexMask++;
- }
-
- wideChange = wChange.c_str();
- return TRUE;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+
+ ASSERT(pEvent != NULL);
+
+ if (params.size() < 1)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ if(!pEvent->m_pValue)
+ return FALSE;
+ CFX_WideString& valEvent = pEvent->Value();
+
+ CFX_WideString wstrMask = params[0].ToCFXWideString();
+ if (wstrMask.IsEmpty())
+ return TRUE;
+
+ std::wstring wstrValue = valEvent.c_str();
+
+ if (pEvent->WillCommit())
+ {
+ if (wstrValue.empty())
+ return TRUE;
+ int iIndexMask = 0;
+ for (std::wstring::iterator it = wstrValue.begin(); it != wstrValue.end(); it++)
+ {
+ wchar_t w_Value = *it;
+ if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
+ break;
+ iIndexMask++;
+ }
+
+ if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrValue.size() && wstrMask.GetLength() != 0))
+ {
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
+ pEvent->Rc() = FALSE;
+ }
+ return TRUE;
+ }
+
+ CFX_WideString &wideChange = pEvent->Change();
+ std::wstring wChange = wideChange.c_str();
+ if (wChange.empty())
+ return TRUE;
+
+ int iIndexMask = pEvent->SelStart();
+
+ if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange.length() > (FX_DWORD)wstrMask.GetLength())
+ {
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ pEvent->Rc() = FALSE;
+ return TRUE;
+ }
+
+ if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty()))
+ {
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ pEvent->Rc() = FALSE;
+ return TRUE;
+ }
+
+ for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++)
+ {
+ if (iIndexMask >= wstrMask.GetLength())
+ {
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ pEvent->Rc() = FALSE;
+ return TRUE;
+ }
+ wchar_t w_Mask = wstrMask[iIndexMask];
+ if (!isReservedMaskChar(w_Mask))
+ {
+ *it = w_Mask;
+ }
+ wchar_t w_Change = *it;
+ if (!maskSatisfied(w_Change,w_Mask))
+ {
+ pEvent->Rc() = FALSE;
+ return TRUE;
+ }
+ iIndexMask++;
+ }
+
+ wideChange = wChange.c_str();
+ return TRUE;
}
//function AFSpecial_Keystroke(psf)
FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
-
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if (params.size() != 1)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- std::string cFormat;
- int iIndex = params[0].ToInt();
-
- if(!pEvent->m_pValue)
- return FALSE;
- //CJS_Value val = pEvent->Value();
- CFX_WideString& val = pEvent->Value();
- std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
- std::wstring wstrChange = pEvent->Change().c_str();
-
- switch (iIndex)
- {
- case 0:
- cFormat = "99999";
- break;
- case 1:
- //cFormat = "99999-9999";
- cFormat = "999999999";
- break;
- case 2:
- {
- std::string NumberStr;
- util::printx("9999999999", strSrc,NumberStr);
- if (strSrc.length() + wstrChange.length() > 7 )
- //cFormat = "(999) 999-9999";
- cFormat = "9999999999";
- else
- //cFormat = "999-9999";
- cFormat = "9999999";
- break;
- }
- case 3:
- //cFormat = "999-99-9999";
- cFormat = "999999999";
- break;
- }
-
- CJS_Parameters params2;
- CJS_Value vMask(isolate, cFormat.c_str());
- params2.push_back(vMask);
+ v8::Isolate* isolate = ::GetIsolate(cc);
+
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if (params.size() != 1)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ std::string cFormat;
+ int iIndex = params[0].ToInt();
+
+ if(!pEvent->m_pValue)
+ return FALSE;
+ //CJS_Value val = pEvent->Value();
+ CFX_WideString& val = pEvent->Value();
+ std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
+ std::wstring wstrChange = pEvent->Change().c_str();
+
+ switch (iIndex)
+ {
+ case 0:
+ cFormat = "99999";
+ break;
+ case 1:
+ //cFormat = "99999-9999";
+ cFormat = "999999999";
+ break;
+ case 2:
+ {
+ std::string NumberStr;
+ util::printx("9999999999", strSrc,NumberStr);
+ if (strSrc.length() + wstrChange.length() > 7 )
+ //cFormat = "(999) 999-9999";
+ cFormat = "9999999999";
+ else
+ //cFormat = "999-9999";
+ cFormat = "9999999";
+ break;
+ }
+ case 3:
+ //cFormat = "999-99-9999";
+ cFormat = "999999999";
+ break;
+ }
+
+ CJS_Parameters params2;
+ CJS_Value vMask(isolate, cFormat.c_str());
+ params2.push_back(vMask);
return AFSpecial_KeystrokeEx(cc,params2,vRet,sError);
}
FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
- ASSERT(pEventHandler != NULL);
-
- if (params.size() != 1)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- CFX_WideString swValue;
- if (pEventHandler->m_pValue != NULL)
- swValue = pEventHandler->Value();
-
- if (pEventHandler->WillCommit())
- {
- vRet = swValue.c_str();
- return TRUE;
- }
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
+ ASSERT(pEventHandler != NULL);
+
+ if (params.size() != 1)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ CFX_WideString swValue;
+ if (pEventHandler->m_pValue != NULL)
+ swValue = pEventHandler->Value();
+
+ if (pEventHandler->WillCommit())
+ {
+ vRet = swValue.c_str();
+ return TRUE;
+ }
- CFX_WideString prefix,postfix;
+ CFX_WideString prefix,postfix;
- if (pEventHandler->SelStart() >= 0)
- prefix = swValue.Mid(0,pEventHandler->SelStart());
- else
- prefix = L"";
+ if (pEventHandler->SelStart() >= 0)
+ prefix = swValue.Mid(0,pEventHandler->SelStart());
+ else
+ prefix = L"";
- if (pEventHandler->SelEnd() >= 0 && pEventHandler->SelEnd() <= swValue.GetLength())
- postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength() - pEventHandler->SelEnd());
- else postfix = L"";
+ if (pEventHandler->SelEnd() >= 0 && pEventHandler->SelEnd() <= swValue.GetLength())
+ postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength() - pEventHandler->SelEnd());
+ else postfix = L"";
- vRet = (prefix + pEventHandler->Change() + postfix).c_str();
+ vRet = (prefix + pEventHandler->Change() + postfix).c_str();
- return TRUE;
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
-
- if (params.size() != 2)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- CFX_WideString sValue = params[0].ToCFXWideString();
- CFX_WideString sFormat = params[1].ToCFXWideString();
-
- FX_BOOL bWrongFormat = FALSE;
- double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat);
-
- if (JS_PortIsNan(dDate))
- {
- CFX_WideString swMsg;
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
- Alert((CJS_Context *)cc, swMsg.c_str());
- return FALSE;
- }
-
- vRet = dDate;
- return TRUE;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+
+ if (params.size() != 2)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ CFX_WideString sValue = params[0].ToCFXWideString();
+ CFX_WideString sFormat = params[1].ToCFXWideString();
+
+ FX_BOOL bWrongFormat = FALSE;
+ double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat);
+
+ if (JS_PortIsNan(dDate))
+ {
+ CFX_WideString swMsg;
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+ Alert((CJS_Context *)cc, swMsg.c_str());
+ return FALSE;
+ }
+
+ vRet = dDate;
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- if (params.size() != 3)
- {
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
+ if (params.size() != 3)
+ {
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble());
- return TRUE;
+ vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble());
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- if (params.size() != 1)
- {
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
-
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
- vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
- return TRUE;
+ if (params.size() != 1)
+ {
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+ vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
+ v8::Isolate* isolate = ::GetIsolate(cc);
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
- if (params.size() != 2)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ if (params.size() != 2)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- CJS_Value params1 = params[1];
+ CJS_Value params1 = params[1];
- if (!params1.IsArrayObject() && params1.GetType() != VT_string)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+ if (!params1.IsArrayObject() && params1.GetType() != VT_string)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
- CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument();
+ CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument();
ASSERT(pReaderDoc != NULL);
- CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm();
- ASSERT(pReaderInterForm != NULL);
+ CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm();
+ ASSERT(pReaderInterForm != NULL);
- CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
+ ASSERT(pInterForm != NULL);
- double dValue;
- CFX_WideString sFunction = params[0].ToCFXWideString();
- if (wcscmp(sFunction.c_str(), L"PRD") == 0)
- dValue = 1.0;
- else
- dValue = 0.0;
+ double dValue;
+ CFX_WideString sFunction = params[0].ToCFXWideString();
+ if (wcscmp(sFunction.c_str(), L"PRD") == 0)
+ dValue = 1.0;
+ else
+ dValue = 0.0;
- CJS_Array FieldNameArray = AF_MakeArrayFromList(isolate,params1);
+ CJS_Array FieldNameArray = AF_MakeArrayFromList(isolate,params1);
- int nFieldsCount = 0;
+ int nFieldsCount = 0;
- for (int i=0,isz=FieldNameArray.GetLength(); i<isz; i++)
- {
- CJS_Value jsValue(isolate);
- FieldNameArray.GetElement(i,jsValue);
- CFX_WideString wsFieldName = jsValue.ToCFXWideString();
+ for (int i=0,isz=FieldNameArray.GetLength(); i<isz; i++)
+ {
+ CJS_Value jsValue(isolate);
+ FieldNameArray.GetElement(i,jsValue);
+ CFX_WideString wsFieldName = jsValue.ToCFXWideString();
for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++)
- {
- if (CPDF_FormField* pFormField = pInterForm->GetField(j, wsFieldName))
- {
- double dTemp = 0.0;
-
- switch (pFormField->GetFieldType())
- {
- case FIELDTYPE_TEXTFIELD:
- case FIELDTYPE_COMBOBOX:
- {
- dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
- break;
- }
- case FIELDTYPE_PUSHBUTTON:
- {
- dTemp = 0.0;
- break;
- }
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- {
- dTemp = 0.0;
- for (int c=0,csz=pFormField->CountControls(); c<csz; c++)
- {
- if (CPDF_FormControl* pFormCtrl = pFormField->GetControl(c))
- {
- if (pFormCtrl->IsChecked())
- {
- dTemp += ParseStringToNumber(pFormCtrl->GetExportValue().c_str());
- break;
- }
- else
- continue;
- }
- }
- break;
- }
- case FIELDTYPE_LISTBOX:
- {
- dTemp = 0.0;
- if (pFormField->CountSelectedItems() > 1)
- break;
- else
- {
- dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
- break;
- }
- }
- default:
- break;
- }
-
- if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0))
- dValue = dTemp;
-
- dValue = AF_Simple(sFunction.c_str(), dValue, dTemp);
-
- nFieldsCount++;
- }
- }
- }
-
- if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0)
- dValue /= nFieldsCount;
-
- dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6);
- CJS_Value jsValue(isolate,dValue);
- if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue)
- ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue.ToCFXWideString();
-
- return TRUE;
+ {
+ if (CPDF_FormField* pFormField = pInterForm->GetField(j, wsFieldName))
+ {
+ double dTemp = 0.0;
+
+ switch (pFormField->GetFieldType())
+ {
+ case FIELDTYPE_TEXTFIELD:
+ case FIELDTYPE_COMBOBOX:
+ {
+ dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
+ break;
+ }
+ case FIELDTYPE_PUSHBUTTON:
+ {
+ dTemp = 0.0;
+ break;
+ }
+ case FIELDTYPE_CHECKBOX:
+ case FIELDTYPE_RADIOBUTTON:
+ {
+ dTemp = 0.0;
+ for (int c=0,csz=pFormField->CountControls(); c<csz; c++)
+ {
+ if (CPDF_FormControl* pFormCtrl = pFormField->GetControl(c))
+ {
+ if (pFormCtrl->IsChecked())
+ {
+ dTemp += ParseStringToNumber(pFormCtrl->GetExportValue().c_str());
+ break;
+ }
+ else
+ continue;
+ }
+ }
+ break;
+ }
+ case FIELDTYPE_LISTBOX:
+ {
+ dTemp = 0.0;
+ if (pFormField->CountSelectedItems() > 1)
+ break;
+ else
+ {
+ dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
+ break;
+ }
+ }
+ default:
+ break;
+ }
+
+ if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0))
+ dValue = dTemp;
+
+ dValue = AF_Simple(sFunction.c_str(), dValue, dTemp);
+
+ nFieldsCount++;
+ }
+ }
+ }
+
+ if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0)
+ dValue /= nFieldsCount;
+
+ dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6);
+ CJS_Value jsValue(isolate,dValue);
+ if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue)
+ ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue.ToCFXWideString();
+
+ return TRUE;
}
/* This function validates the current event to ensure that its value is
@@ -2173,104 +2170,104 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
- CJS_EventHandler* pEvent = pContext->GetEventHandler();
- ASSERT(pEvent != NULL);
-
- if (params.size() != 4)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- if(!pEvent->m_pValue)
- return FALSE;
- if (pEvent->Value().IsEmpty() )
- return TRUE;
- double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
- FX_BOOL bGreaterThan = params[0].ToBool();
- double dGreaterThan = params[1].ToDouble();
- FX_BOOL bLessThan = params[2].ToBool();
- double dLessThan = params[3].ToDouble();
- CFX_WideString swMsg;
-
- if (bGreaterThan && bLessThan)
- {
- if (dEentValue < dGreaterThan || dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1).c_str(),
- params[1].ToCFXWideString().c_str(),
- params[3].ToCFXWideString().c_str());
- }
- else if (bGreaterThan)
- {
- if (dEentValue < dGreaterThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2).c_str(),
- params[1].ToCFXWideString().c_str());
- }
- else if (bLessThan)
- {
- if (dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3).c_str(),
- params[3].ToCFXWideString().c_str());
- }
-
- if (!swMsg.IsEmpty())
- {
- Alert(pContext, swMsg.c_str());
- pEvent->Rc() = FALSE;
- }
- return TRUE;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+ CJS_EventHandler* pEvent = pContext->GetEventHandler();
+ ASSERT(pEvent != NULL);
+
+ if (params.size() != 4)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ if(!pEvent->m_pValue)
+ return FALSE;
+ if (pEvent->Value().IsEmpty() )
+ return TRUE;
+ double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
+ FX_BOOL bGreaterThan = params[0].ToBool();
+ double dGreaterThan = params[1].ToDouble();
+ FX_BOOL bLessThan = params[2].ToBool();
+ double dLessThan = params[3].ToDouble();
+ CFX_WideString swMsg;
+
+ if (bGreaterThan && bLessThan)
+ {
+ if (dEentValue < dGreaterThan || dEentValue > dLessThan)
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1).c_str(),
+ params[1].ToCFXWideString().c_str(),
+ params[3].ToCFXWideString().c_str());
+ }
+ else if (bGreaterThan)
+ {
+ if (dEentValue < dGreaterThan)
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2).c_str(),
+ params[1].ToCFXWideString().c_str());
+ }
+ else if (bLessThan)
+ {
+ if (dEentValue > dLessThan)
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3).c_str(),
+ params[3].ToCFXWideString().c_str());
+ }
+
+ if (!swMsg.IsEmpty())
+ {
+ Alert(pContext, swMsg.c_str());
+ pEvent->Rc() = FALSE;
+ }
+ return TRUE;
}
FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = ::GetIsolate(cc);
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
-
- if (params.size() != 1)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- CJS_Array nums(isolate);
-
- CFX_WideString str = params[0].ToCFXWideString();
- CFX_WideString sPart;
-
- if (str.GetAt(0) == L'.' || str.GetAt(0) == L',')
- str = L"0" + str;
-
- int nIndex = 0;
- for (int i=0, sz=str.GetLength(); i<sz; i++)
- {
- FX_WCHAR wc = str.GetAt(i);
- if (IsDigit((wchar_t)wc))
- {
- sPart += wc;
- }
- else
- {
- if (sPart.GetLength() > 0)
- {
- nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
- sPart = L"";
- nIndex ++;
- }
- }
- }
-
- if (sPart.GetLength() > 0)
- {
- nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
- }
-
- if (nums.GetLength() > 0)
- vRet = nums;
- else
- vRet.SetNull();
-
- return TRUE;
+ v8::Isolate* isolate = ::GetIsolate(cc);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
+
+ if (params.size() != 1)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ CJS_Array nums(isolate);
+
+ CFX_WideString str = params[0].ToCFXWideString();
+ CFX_WideString sPart;
+
+ if (str.GetAt(0) == L'.' || str.GetAt(0) == L',')
+ str = L"0" + str;
+
+ int nIndex = 0;
+ for (int i=0, sz=str.GetLength(); i<sz; i++)
+ {
+ FX_WCHAR wc = str.GetAt(i);
+ if (IsDigit((wchar_t)wc))
+ {
+ sPart += wc;
+ }
+ else
+ {
+ if (sPart.GetLength() > 0)
+ {
+ nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
+ sPart = L"";
+ nIndex ++;
+ }
+ }
+ }
+
+ if (sPart.GetLength() > 0)
+ {
+ nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
+ }
+
+ if (nums.GetLength() > 0)
+ vRet = nums;
+ else
+ vRet.SetNull();
+
+ return TRUE;
}
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 6eea290f68..6965c8c884 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -91,509 +91,496 @@ BEGIN_JS_STATIC_PROP(CJS_Global)
END_JS_STATIC_PROP()
BEGIN_JS_STATIC_METHOD(CJS_Global)
- JS_STATIC_METHOD_ENTRY(setPersistent)
+ JS_STATIC_METHOD_ENTRY(setPersistent)
END_JS_STATIC_METHOD()
IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, global_alternate, global);
-FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc)
+FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc)
{
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context*)cc;
+ ASSERT(pContext != NULL);
- global_alternate* pGlobal = (global_alternate*)GetEmbedObject();
- ASSERT(pGlobal != NULL);
+ global_alternate* pGlobal = (global_alternate*)GetEmbedObject();
+ ASSERT(pGlobal != NULL);
- pGlobal->Initial(pContext->GetReaderApp());
+ pGlobal->Initial(pContext->GetReaderApp());
- return TRUE;
+ return TRUE;
};
global_alternate::global_alternate(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject),
- m_pApp(NULL)
+ : CJS_EmbedObj(pJSObject),
+ m_pApp(NULL)
{
}
global_alternate::~global_alternate(void)
{
- DestroyGlobalPersisitentVariables();
- m_pApp->GetRuntimeFactory()->ReleaseGlobalData();
+ DestroyGlobalPersisitentVariables();
+ m_pApp->GetRuntimeFactory()->ReleaseGlobalData();
}
void global_alternate::Initial(CPDFDoc_Environment* pApp)
{
- m_pApp = pApp;
- m_pGlobalData = pApp->GetRuntimeFactory()->NewGlobalData(pApp);
- UpdateGlobalPersistentVariables();
+ m_pApp = pApp;
+ m_pGlobalData = pApp->GetRuntimeFactory()->NewGlobalData(pApp);
+ UpdateGlobalPersistentVariables();
}
-FX_BOOL global_alternate::QueryProperty(const FX_WCHAR* propname)
+FX_BOOL global_alternate::QueryProperty(const FX_WCHAR* propname)
{
- return CFX_WideString(propname) != L"setPersistent";
+ return CFX_WideString(propname) != L"setPersistent";
}
-FX_BOOL global_alternate::DelProperty(IFXJS_Context* cc, const FX_WCHAR* propname, CFX_WideString& sError)
+FX_BOOL global_alternate::DelProperty(IFXJS_Context* cc, const FX_WCHAR* propname, CFX_WideString& sError)
{
- js_global_data* pData = NULL;
- CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
+ js_global_data* pData = NULL;
+ CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
- if (m_mapGlobal.Lookup(sPropName, (void*&)pData))
- {
- pData->bDeleted = TRUE;
- return TRUE;
- }
+ if (m_mapGlobal.Lookup(sPropName, (void*&)pData))
+ {
+ pData->bDeleted = TRUE;
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, const FX_WCHAR* propname, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsSetting())
- {
- CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
- switch (vp.GetType())
- {
- case VT_number:
- {
- double dData;
- vp >> dData;
- return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData, false, "", v8::Local<v8::Object>(), FALSE);
- }
- case VT_boolean:
- {
- bool bData;
- vp >> bData;
- return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Local<v8::Object>(), FALSE);
- }
- case VT_string:
- {
- CFX_ByteString sData;
- vp >> sData;
- return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_STRING, 0, false, sData, v8::Local<v8::Object>(), FALSE);
- }
- case VT_object:
- {
- JSObject pData;
- vp >> pData;
- return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", pData, FALSE);
- }
- case VT_null:
- {
- return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local<v8::Object>(), FALSE);
- }
- case VT_undefined:
- {
- DelProperty(cc, propname, sError);
- return TRUE;
- }
- default:
- return FALSE;
- }
- }
- else
- {
- js_global_data* pData = NULL;
- CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
-
- if (m_mapGlobal.Lookup(sPropName, (void*&)pData))
- {
- if (pData)
- {
- if (!pData->bDeleted)
- {
- switch (pData->nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- vp << pData->dData;
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- vp << pData->bData;
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- vp << pData->sData;
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- {
- v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(vp.GetIsolate(),pData->pData);
- vp << obj;
- break;
- }
- case JS_GLOBALDATA_TYPE_NULL:
- vp.SetNull();
- break;
- default:
- return FALSE;
- }
- return TRUE;
- }
- else
- {
- return TRUE;
- }
- }
- else
- {
- vp.SetNull();
- return TRUE;
- }
- }
- else
- {
- vp.SetNull();
- return TRUE;
- }
- }
-
- return FALSE;
+ if (vp.IsSetting())
+ {
+ CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
+ switch (vp.GetType())
+ {
+ case VT_number:
+ {
+ double dData;
+ vp >> dData;
+ return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData, false, "", v8::Local<v8::Object>(), FALSE);
+ }
+ case VT_boolean:
+ {
+ bool bData;
+ vp >> bData;
+ return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Local<v8::Object>(), FALSE);
+ }
+ case VT_string:
+ {
+ CFX_ByteString sData;
+ vp >> sData;
+ return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_STRING, 0, false, sData, v8::Local<v8::Object>(), FALSE);
+ }
+ case VT_object:
+ {
+ JSObject pData;
+ vp >> pData;
+ return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", pData, FALSE);
+ }
+ case VT_null:
+ {
+ return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local<v8::Object>(), FALSE);
+ }
+ case VT_undefined:
+ {
+ DelProperty(cc, propname, sError);
+ return TRUE;
+ }
+ default:
+ break;
+ }
+ }
+ else
+ {
+ void* pVoid = nullptr;
+ if (!m_mapGlobal.Lookup(CFX_ByteString::FromUnicode(propname), pVoid))
+ {
+ vp.SetNull();
+ return TRUE;
+ }
+ if (!pVoid)
+ {
+ vp.SetNull();
+ return TRUE;
+ }
+ js_global_data* pData = (js_global_data*)pVoid;
+ if (pData->bDeleted)
+ return TRUE;
+
+ switch (pData->nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ vp << pData->dData;
+ return TRUE;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ vp << pData->bData;
+ return TRUE;
+ case JS_GLOBALDATA_TYPE_STRING:
+ vp << pData->sData;
+ return TRUE;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ {
+ v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(vp.GetIsolate(),pData->pData);
+ vp << obj;
+ return TRUE;
+ }
+ case JS_GLOBALDATA_TYPE_NULL:
+ vp.SetNull();
+ return TRUE;
+ default:
+ break;
+ }
+ }
+ return FALSE;
}
FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- if (params.size() != 2)
- {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
-
- CFX_ByteString sName = params[0].ToCFXByteString();
-
- js_global_data* pData = NULL;
- if (m_mapGlobal.Lookup(sName, (void*&)pData))
- {
- if (pData && !pData->bDeleted)
- {
- pData->bPersistent = params[1].ToBool();
- return TRUE;
- }
- }
-
- sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL);
- return FALSE;
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ if (params.size() != 2)
+ {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+
+ CFX_ByteString sName = params[0].ToCFXByteString();
+
+ js_global_data* pData = NULL;
+ if (m_mapGlobal.Lookup(sName, (void*&)pData))
+ {
+ if (pData && !pData->bDeleted)
+ {
+ pData->bPersistent = params[1].ToBool();
+ return TRUE;
+ }
+ }
+
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL);
+ return FALSE;
}
void global_alternate::UpdateGlobalPersistentVariables()
{
- ASSERT(m_pGlobalData != NULL);
-
- for (int i=0,sz=m_pGlobalData->GetSize(); i<sz; i++)
- {
- CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i);
- ASSERT(pData != NULL);
-
- switch (pData->data.nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Local<v8::Object>(), pData->bPersistent == 1);
- JS_PutObjectNumber(NULL,(JSFXObject)(*m_pJSObject),
- pData->data.sKey.UTF8Decode().c_str(), pData->data.dData);
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Local<v8::Object>(), pData->bPersistent == 1);
- JS_PutObjectBoolean(NULL,(JSFXObject)(*m_pJSObject),
- pData->data.sKey.UTF8Decode().c_str(), (bool)(pData->data.bData == 1));
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Local<v8::Object>(), pData->bPersistent == 1);
- JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject),
- pData->data.sKey.UTF8Decode().c_str(),
- pData->data.sData.UTF8Decode().c_str());
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- {
- IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject));
- v8::Local<v8::Object> pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1);
-
- PutObjectProperty(pObj, &pData->data);
-
- SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "",
- (JSObject)pObj, pData->bPersistent == 1);
- JS_PutObjectObject(NULL,(JSFXObject)(*m_pJSObject),
- pData->data.sKey.UTF8Decode().c_str(), (JSObject)pObj);
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local<v8::Object>(), pData->bPersistent == 1);
- JS_PutObjectNull(NULL,(JSFXObject)(*m_pJSObject),
- pData->data.sKey.UTF8Decode().c_str());
- break;
- }
- }
+ ASSERT(m_pGlobalData != NULL);
+
+ for (int i=0,sz=m_pGlobalData->GetSize(); i<sz; i++)
+ {
+ CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i);
+ ASSERT(pData != NULL);
+
+ switch (pData->data.nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Local<v8::Object>(), pData->bPersistent == 1);
+ JS_PutObjectNumber(NULL,(JSFXObject)(*m_pJSObject),
+ pData->data.sKey.UTF8Decode().c_str(), pData->data.dData);
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Local<v8::Object>(), pData->bPersistent == 1);
+ JS_PutObjectBoolean(NULL,(JSFXObject)(*m_pJSObject),
+ pData->data.sKey.UTF8Decode().c_str(), (bool)(pData->data.bData == 1));
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Local<v8::Object>(), pData->bPersistent == 1);
+ JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject),
+ pData->data.sKey.UTF8Decode().c_str(),
+ pData->data.sData.UTF8Decode().c_str());
+ break;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ {
+ IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject));
+ v8::Local<v8::Object> pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1);
+
+ PutObjectProperty(pObj, &pData->data);
+
+ SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "",
+ (JSObject)pObj, pData->bPersistent == 1);
+ JS_PutObjectObject(NULL,(JSFXObject)(*m_pJSObject),
+ pData->data.sKey.UTF8Decode().c_str(), (JSObject)pObj);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local<v8::Object>(), pData->bPersistent == 1);
+ JS_PutObjectNull(NULL,(JSFXObject)(*m_pJSObject),
+ pData->data.sKey.UTF8Decode().c_str());
+ break;
+ }
+ }
}
void global_alternate::CommitGlobalPersisitentVariables()
{
- ASSERT(m_pGlobalData != NULL);
-
- FX_POSITION pos = m_mapGlobal.GetStartPosition();
- while (pos)
- {
- CFX_ByteString name;
- js_global_data* pData = NULL;
- m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
-
- if (pData)
- {
- if (pData->bDeleted)
- {
- m_pGlobalData->DeleteGlobalVariable(name);
- }
- else
- {
- switch (pData->nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- m_pGlobalData->SetGlobalVariableNumber(name, pData->dData);
- m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- m_pGlobalData->SetGlobalVariableBoolean(name, pData->bData);
- m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- m_pGlobalData->SetGlobalVariableString(name, pData->sData);
- m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- //if (pData->pData)
- {
- CJS_GlobalVariableArray array;
- v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(GetJSObject()->GetIsolate(),pData->pData);
- ObjectToArray(obj, array);
- m_pGlobalData->SetGlobalVariableObject(name, array);
- m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- m_pGlobalData->SetGlobalVariableNull(name);
- m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
- break;
- }
- }
- }
- }
+ ASSERT(m_pGlobalData != NULL);
+
+ FX_POSITION pos = m_mapGlobal.GetStartPosition();
+ while (pos)
+ {
+ CFX_ByteString name;
+ js_global_data* pData = NULL;
+ m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
+
+ if (pData)
+ {
+ if (pData->bDeleted)
+ {
+ m_pGlobalData->DeleteGlobalVariable(name);
+ }
+ else
+ {
+ switch (pData->nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ m_pGlobalData->SetGlobalVariableNumber(name, pData->dData);
+ m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ m_pGlobalData->SetGlobalVariableBoolean(name, pData->bData);
+ m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ m_pGlobalData->SetGlobalVariableString(name, pData->sData);
+ m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
+ break;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ //if (pData->pData)
+ {
+ CJS_GlobalVariableArray array;
+ v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(GetJSObject()->GetIsolate(),pData->pData);
+ ObjectToArray(obj, array);
+ m_pGlobalData->SetGlobalVariableObject(name, array);
+ m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ m_pGlobalData->SetGlobalVariableNull(name);
+ m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
+ break;
+ }
+ }
+ }
+ }
}
void global_alternate::ObjectToArray(v8::Local<v8::Object> pObj, CJS_GlobalVariableArray& array)
{
- v8::Local<v8::Context> context = pObj->CreationContext();
- v8::Isolate* isolate = context->GetIsolate();
- v8::Local<v8::Array> pKeyList = JS_GetObjectElementNames(isolate, pObj);
- int nObjElements = pKeyList->Length();
-
- for (int i=0; i<nObjElements; i++)
- {
-
- CFX_WideString ws = JS_ToString(isolate, JS_GetArrayElement(isolate, pKeyList, i));
- CFX_ByteString sKey = ws.UTF8Encode();
-
- v8::Local<v8::Value> v = JS_GetObjectElement(isolate, pObj, ws.c_str());
- FXJSVALUETYPE vt = GET_VALUE_TYPE(v);
- switch (vt)
- {
- case VT_number:
- {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
- pObjElement->nType = JS_GLOBALDATA_TYPE_NUMBER;
- pObjElement->sKey = sKey;
- pObjElement->dData = JS_ToNumber(isolate, v);
- array.Add(pObjElement);
- }
- break;
- case VT_boolean:
- {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
- pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN;
- pObjElement->sKey = sKey;
- pObjElement->dData = JS_ToBoolean(isolate, v);
- array.Add(pObjElement);
- }
- break;
- case VT_string:
- {
- CFX_ByteString sValue = CJS_Value(isolate, v, VT_string).ToCFXByteString();
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
- pObjElement->nType = JS_GLOBALDATA_TYPE_STRING;
- pObjElement->sKey = sKey;
- pObjElement->sData = sValue;
- array.Add(pObjElement);
- }
- break;
- case VT_object:
- {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
- pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT;
- pObjElement->sKey = sKey;
- ObjectToArray(JS_ToObject(isolate, v), pObjElement->objData);
- array.Add(pObjElement);
- }
- break;
- case VT_null:
- {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
- pObjElement->nType = JS_GLOBALDATA_TYPE_NULL;
- pObjElement->sKey = sKey;
- array.Add(pObjElement);
- }
- break;
- default:
- break;
- }
- }
+ v8::Local<v8::Context> context = pObj->CreationContext();
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::Local<v8::Array> pKeyList = JS_GetObjectElementNames(isolate, pObj);
+ int nObjElements = pKeyList->Length();
+
+ for (int i=0; i<nObjElements; i++)
+ {
+
+ CFX_WideString ws = JS_ToString(isolate, JS_GetArrayElement(isolate, pKeyList, i));
+ CFX_ByteString sKey = ws.UTF8Encode();
+
+ v8::Local<v8::Value> v = JS_GetObjectElement(isolate, pObj, ws.c_str());
+ FXJSVALUETYPE vt = GET_VALUE_TYPE(v);
+ switch (vt)
+ {
+ case VT_number:
+ {
+ CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ pObjElement->nType = JS_GLOBALDATA_TYPE_NUMBER;
+ pObjElement->sKey = sKey;
+ pObjElement->dData = JS_ToNumber(isolate, v);
+ array.Add(pObjElement);
+ }
+ break;
+ case VT_boolean:
+ {
+ CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN;
+ pObjElement->sKey = sKey;
+ pObjElement->dData = JS_ToBoolean(isolate, v);
+ array.Add(pObjElement);
+ }
+ break;
+ case VT_string:
+ {
+ CFX_ByteString sValue = CJS_Value(isolate, v, VT_string).ToCFXByteString();
+ CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ pObjElement->nType = JS_GLOBALDATA_TYPE_STRING;
+ pObjElement->sKey = sKey;
+ pObjElement->sData = sValue;
+ array.Add(pObjElement);
+ }
+ break;
+ case VT_object:
+ {
+ CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT;
+ pObjElement->sKey = sKey;
+ ObjectToArray(JS_ToObject(isolate, v), pObjElement->objData);
+ array.Add(pObjElement);
+ }
+ break;
+ case VT_null:
+ {
+ CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ pObjElement->nType = JS_GLOBALDATA_TYPE_NULL;
+ pObjElement->sKey = sKey;
+ array.Add(pObjElement);
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
void global_alternate::PutObjectProperty(v8::Local<v8::Object> pObj, CJS_KeyValue* pData)
{
- ASSERT(pData != NULL);
-
- for (int i=0,sz=pData->objData.Count(); i<sz; i++)
- {
- CJS_KeyValue* pObjData = pData->objData.GetAt(i);
- ASSERT(pObjData != NULL);
-
- switch (pObjData->nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- JS_PutObjectNumber(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->dData);
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- JS_PutObjectBoolean(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (bool)(pObjData->bData == 1));
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- JS_PutObjectString(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->sData.UTF8Decode().c_str());
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- {
- IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject));
- v8::Local<v8::Object> pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1);
- PutObjectProperty(pNewObj, pObjData);
- JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (JSObject)pNewObj);
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- JS_PutObjectNull(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str());
- break;
- }
- }
+ ASSERT(pData != NULL);
+
+ for (int i=0,sz=pData->objData.Count(); i<sz; i++)
+ {
+ CJS_KeyValue* pObjData = pData->objData.GetAt(i);
+ ASSERT(pObjData != NULL);
+
+ switch (pObjData->nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ JS_PutObjectNumber(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->dData);
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ JS_PutObjectBoolean(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (bool)(pObjData->bData == 1));
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ JS_PutObjectString(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->sData.UTF8Decode().c_str());
+ break;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ {
+ IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject));
+ v8::Local<v8::Object> pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1);
+ PutObjectProperty(pNewObj, pObjData);
+ JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (JSObject)pNewObj);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ JS_PutObjectNull(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str());
+ break;
+ }
+ }
}
void global_alternate::DestroyGlobalPersisitentVariables()
{
- FX_POSITION pos = m_mapGlobal.GetStartPosition();
- while (pos)
- {
- CFX_ByteString name;
- js_global_data* pData = NULL;
- m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
- delete pData;
- }
-
- m_mapGlobal.RemoveAll();
+ FX_POSITION pos = m_mapGlobal.GetStartPosition();
+ while (pos)
+ {
+ CFX_ByteString name;
+ js_global_data* pData = NULL;
+ m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
+ delete pData;
+ }
+
+ m_mapGlobal.RemoveAll();
}
FX_BOOL global_alternate::SetGlobalVariables(const FX_CHAR* propname, int nType,
- double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent)
+ double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent)
{
- if (propname == NULL) return FALSE;
-
- js_global_data* pTemp = NULL;
- m_mapGlobal.Lookup(propname, (void*&)pTemp);
-
- if (pTemp)
- {
- if (pTemp->bDeleted || pTemp->nType != nType)
- {
- pTemp->dData = 0;
- pTemp->bData = 0;
- pTemp->sData = "";
- pTemp->nType = nType;
- }
-
- pTemp->bDeleted = FALSE;
-
- switch (nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- {
- pTemp->dData = dData;
- }
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- {
- pTemp->bData = bData;
- }
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- {
- pTemp->sData = sData;
- }
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- {
- pTemp->pData.Reset(JS_GetRuntime(pData), pData);
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
- }
-
- js_global_data* pNewData = NULL;
-
- switch (nType)
- {
- case JS_GLOBALDATA_TYPE_NUMBER:
- {
- pNewData = new js_global_data;
- pNewData->nType = JS_GLOBALDATA_TYPE_NUMBER;
- pNewData->dData = dData;
- pNewData->bPersistent = bDefaultPersistent;
- }
- break;
- case JS_GLOBALDATA_TYPE_BOOLEAN:
- {
- pNewData = new js_global_data;
- pNewData->nType = JS_GLOBALDATA_TYPE_BOOLEAN;
- pNewData->bData = bData;
- pNewData->bPersistent = bDefaultPersistent;
- }
- break;
- case JS_GLOBALDATA_TYPE_STRING:
- {
- pNewData = new js_global_data;
- pNewData->nType = JS_GLOBALDATA_TYPE_STRING;
- pNewData->sData = sData;
- pNewData->bPersistent = bDefaultPersistent;
- }
- break;
- case JS_GLOBALDATA_TYPE_OBJECT:
- {
- pNewData = new js_global_data;
- pNewData->nType = JS_GLOBALDATA_TYPE_OBJECT;
- pNewData->pData.Reset(JS_GetRuntime(pData), pData);
- pNewData->bPersistent = bDefaultPersistent;
- }
- break;
- case JS_GLOBALDATA_TYPE_NULL:
- {
- pNewData = new js_global_data;
- pNewData->nType = JS_GLOBALDATA_TYPE_NULL;
- pNewData->bPersistent = bDefaultPersistent;
- }
- break;
- default:
- return FALSE;
- }
-
- m_mapGlobal.SetAt(propname, (void*)pNewData);
-
- return TRUE;
+ if (propname == NULL) return FALSE;
+
+ js_global_data* pTemp = NULL;
+ m_mapGlobal.Lookup(propname, (void*&)pTemp);
+
+ if (pTemp)
+ {
+ if (pTemp->bDeleted || pTemp->nType != nType)
+ {
+ pTemp->dData = 0;
+ pTemp->bData = 0;
+ pTemp->sData = "";
+ pTemp->nType = nType;
+ }
+
+ pTemp->bDeleted = FALSE;
+
+ switch (nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ {
+ pTemp->dData = dData;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ {
+ pTemp->bData = bData;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ {
+ pTemp->sData = sData;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ {
+ pTemp->pData.Reset(JS_GetRuntime(pData), pData);
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ js_global_data* pNewData = NULL;
+
+ switch (nType)
+ {
+ case JS_GLOBALDATA_TYPE_NUMBER:
+ {
+ pNewData = new js_global_data;
+ pNewData->nType = JS_GLOBALDATA_TYPE_NUMBER;
+ pNewData->dData = dData;
+ pNewData->bPersistent = bDefaultPersistent;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_BOOLEAN:
+ {
+ pNewData = new js_global_data;
+ pNewData->nType = JS_GLOBALDATA_TYPE_BOOLEAN;
+ pNewData->bData = bData;
+ pNewData->bPersistent = bDefaultPersistent;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_STRING:
+ {
+ pNewData = new js_global_data;
+ pNewData->nType = JS_GLOBALDATA_TYPE_STRING;
+ pNewData->sData = sData;
+ pNewData->bPersistent = bDefaultPersistent;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_OBJECT:
+ {
+ pNewData = new js_global_data;
+ pNewData->nType = JS_GLOBALDATA_TYPE_OBJECT;
+ pNewData->pData.Reset(JS_GetRuntime(pData), pData);
+ pNewData->bPersistent = bDefaultPersistent;
+ }
+ break;
+ case JS_GLOBALDATA_TYPE_NULL:
+ {
+ pNewData = new js_global_data;
+ pNewData->nType = JS_GLOBALDATA_TYPE_NULL;
+ pNewData->bPersistent = bDefaultPersistent;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+
+ m_mapGlobal.SetAt(propname, (void*)pNewData);
+
+ return TRUE;
}
FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p)
@@ -619,4 +606,3 @@ FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p)
return VT_unknown;
}
-
diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp
index c4f03093a7..4083ed58da 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -22,13 +22,13 @@
static v8::Isolate* GetIsolate(IFXJS_Context* cc)
{
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ ASSERT(pRuntime != NULL);
- return pRuntime->GetIsolate();
+ return pRuntime->GetIsolate();
}
BEGIN_JS_STATIC_CONST(CJS_Util)
@@ -38,11 +38,11 @@ BEGIN_JS_STATIC_PROP(CJS_Util)
END_JS_STATIC_PROP()
BEGIN_JS_STATIC_METHOD(CJS_Util)
- JS_STATIC_METHOD_ENTRY(printd)
- JS_STATIC_METHOD_ENTRY(printf)
- JS_STATIC_METHOD_ENTRY(printx)
- JS_STATIC_METHOD_ENTRY(scand)
- JS_STATIC_METHOD_ENTRY(byteToChar)
+ JS_STATIC_METHOD_ENTRY(printd)
+ JS_STATIC_METHOD_ENTRY(printf)
+ JS_STATIC_METHOD_ENTRY(printx)
+ JS_STATIC_METHOD_ENTRY(scand)
+ JS_STATIC_METHOD_ENTRY(byteToChar)
END_JS_STATIC_METHOD()
IMPLEMENT_JS_CLASS(CJS_Util,util)
@@ -58,549 +58,539 @@ util::~util(void)
struct stru_TbConvert
{
- const FX_WCHAR* lpszJSMark;
- const FX_WCHAR* lpszCppMark;
+ const FX_WCHAR* lpszJSMark;
+ const FX_WCHAR* lpszCppMark;
};
const stru_TbConvert fcTable[] = {
- { L"mmmm", L"%B" },
- { L"mmm", L"%b" },
- { L"mm", L"%m" },
- //"m"
- { L"dddd", L"%A" },
- { L"ddd", L"%a" },
- { L"dd", L"%d" },
- //"d", "%w",
- { L"yyyy", L"%Y" },
- { L"yy", L"%y" },
- { L"HH", L"%H" },
- //"H"
- { L"hh", L"%I" },
- //"h"
- { L"MM", L"%M" },
- //"M"
- { L"ss", L"%S" },
- //"s
- { L"TT", L"%p" },
- //"t"
+ { L"mmmm", L"%B" },
+ { L"mmm", L"%b" },
+ { L"mm", L"%m" },
+ //"m"
+ { L"dddd", L"%A" },
+ { L"ddd", L"%a" },
+ { L"dd", L"%d" },
+ //"d", "%w",
+ { L"yyyy", L"%Y" },
+ { L"yy", L"%y" },
+ { L"HH", L"%H" },
+ //"H"
+ { L"hh", L"%I" },
+ //"h"
+ { L"MM", L"%M" },
+ //"M"
+ { L"ss", L"%S" },
+ //"s
+ { L"TT", L"%p" },
+ //"t"
#if defined(_WIN32)
- { L"tt", L"%p" },
- { L"h", L"%#I" },
+ { L"tt", L"%p" },
+ { L"h", L"%#I" },
#else
- { L"tt", L"%P" },
- { L"h", L"%l" },
+ { L"tt", L"%P" },
+ { L"h", L"%l" },
#endif
};
-#define UTIL_INT 0
-#define UTIL_DOUBLE 1
-#define UTIL_STRING 2
+#define UTIL_INT 0
+#define UTIL_DOUBLE 1
+#define UTIL_STRING 2
int util::ParstDataType(std::wstring* sFormat)
{
- size_t i = 0;
- bool bPercent = FALSE;
- for (i=0; i<sFormat->length(); ++i)
- {
- wchar_t c = (*sFormat)[i];
- if (c == L'%')
- {
- bPercent = true;
- continue;
- }
-
- if (bPercent)
- {
- if (c == L'c' || c == L'C' || c == L'd' || c == L'i' || c == L'o' || c == L'u' || c == L'x' || c == L'X')
- {
- return UTIL_INT;
- }
- else if (c == L'e' || c == L'E' || c == L'f' || c == L'g' || c == L'G')
- {
- return UTIL_DOUBLE;
- }
- else if (c == L's' || c == L'S')
- {
- // Map s to S since we always deal internally
- // with wchar_t strings.
- (*sFormat)[i] = L'S';
- return UTIL_STRING;
- }
- else if (c == L'.' || c == L'+' || c == L'-' || c == L'#' || c == L' ' || CJS_PublicMethods::IsDigit(c))
- {
- continue;
- }
- else break;
- }
- }
-
- return -1;
+ bool bPercent = FALSE;
+ for (size_t i = 0; i < sFormat->length(); ++i)
+ {
+ wchar_t c = (*sFormat)[i];
+ if (c == L'%')
+ {
+ bPercent = true;
+ continue;
+ }
+
+ if (bPercent)
+ {
+ if (c == L'c' || c == L'C' || c == L'd' || c == L'i' || c == L'o' || c == L'u' || c == L'x' || c == L'X')
+ {
+ return UTIL_INT;
+ }
+ if (c == L'e' || c == L'E' || c == L'f' || c == L'g' || c == L'G')
+ {
+ return UTIL_DOUBLE;
+ }
+ if (c == L's' || c == L'S')
+ {
+ // Map s to S since we always deal internally
+ // with wchar_t strings.
+ (*sFormat)[i] = L'S';
+ return UTIL_STRING;
+ }
+ if (c == L'.' || c == L'+' || c == L'-' || c == L'#' || c == L' ' || CJS_PublicMethods::IsDigit(c))
+ {
+ continue;
+ }
+ break;
+ }
+ }
+
+ return -1;
}
FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- int iSize = params.size();
- if (iSize < 1)
- return FALSE;
- std::wstring c_ConvChar(params[0].ToCFXWideString().c_str());
- std::vector<std::wstring> c_strConvers;
- int iOffset = 0;
- int iOffend = 0;
- c_ConvChar.insert(c_ConvChar.begin(),L'S');
- while(iOffset != -1)
- {
- iOffend = c_ConvChar.find(L"%",iOffset+1);
- std::wstring strSub;
- if (iOffend == -1)
- strSub = c_ConvChar.substr(iOffset);
- else
- strSub = c_ConvChar.substr(iOffset ,iOffend - iOffset);
- c_strConvers.push_back(strSub);
- iOffset = iOffend ;
- }
-
- std::wstring c_strResult;
-
- //for(int iIndex = 1;iIndex < params.size();iIndex++)
- std::wstring c_strFormat;
- for(int iIndex = 0;iIndex < (int)c_strConvers.size();iIndex++)
- {
- c_strFormat = c_strConvers[iIndex];
- if (iIndex == 0)
- {
- c_strResult = c_strFormat;
- continue;
- }
-
-
- CFX_WideString strSegment;
- if (iIndex >= iSize) {
- c_strResult += c_strFormat;
- continue;
- }
-
- switch (ParstDataType(&c_strFormat))
- {
- case UTIL_INT:
- strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt());
- break;
- case UTIL_DOUBLE:
- strSegment.Format(c_strFormat.c_str(), params[iIndex].ToDouble());
- break;
- case UTIL_STRING:
- strSegment.Format(c_strFormat.c_str(), params[iIndex].ToCFXWideString().c_str());
- break;
- default:
- strSegment.Format(L"%S", c_strFormat.c_str());
- break;
- }
- c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1);
- }
-
- c_strResult.erase(c_strResult.begin());
- vRet = c_strResult.c_str();
- return TRUE;
+ int iSize = params.size();
+ if (iSize < 1)
+ return FALSE;
+ std::wstring c_ConvChar(params[0].ToCFXWideString().c_str());
+ std::vector<std::wstring> c_strConvers;
+ int iOffset = 0;
+ int iOffend = 0;
+ c_ConvChar.insert(c_ConvChar.begin(),L'S');
+ while(iOffset != -1)
+ {
+ iOffend = c_ConvChar.find(L"%",iOffset+1);
+ std::wstring strSub;
+ if (iOffend == -1)
+ strSub = c_ConvChar.substr(iOffset);
+ else
+ strSub = c_ConvChar.substr(iOffset ,iOffend - iOffset);
+ c_strConvers.push_back(strSub);
+ iOffset = iOffend ;
+ }
+
+ std::wstring c_strResult;
+
+ //for(int iIndex = 1;iIndex < params.size();iIndex++)
+ std::wstring c_strFormat;
+ for(int iIndex = 0;iIndex < (int)c_strConvers.size();iIndex++)
+ {
+ c_strFormat = c_strConvers[iIndex];
+ if (iIndex == 0)
+ {
+ c_strResult = c_strFormat;
+ continue;
+ }
+
+
+ CFX_WideString strSegment;
+ if (iIndex >= iSize) {
+ c_strResult += c_strFormat;
+ continue;
+ }
+
+ switch (ParstDataType(&c_strFormat))
+ {
+ case UTIL_INT:
+ strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt());
+ break;
+ case UTIL_DOUBLE:
+ strSegment.Format(c_strFormat.c_str(), params[iIndex].ToDouble());
+ break;
+ case UTIL_STRING:
+ strSegment.Format(c_strFormat.c_str(), params[iIndex].ToCFXWideString().c_str());
+ break;
+ default:
+ strSegment.Format(L"%S", c_strFormat.c_str());
+ break;
+ }
+ c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1);
+ }
+
+ c_strResult.erase(c_strResult.begin());
+ vRet = c_strResult.c_str();
+ return TRUE;
}
FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = GetIsolate(cc);
-
- int iSize = params.size();
- if (iSize < 2)
- return FALSE;
-
- CJS_Value p1(isolate);
- p1 = params[0];
-
- CJS_Value p2 = params[1];
- CJS_Date jsDate(isolate);
- if (!p2.ConvertToDate(jsDate))
- {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT1);
- return FALSE;
- }
-
- if (!jsDate.IsValidDate())
- {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT2);
- return FALSE;
- }
-
- if (p1.GetType() == VT_number)
- {
- int nFormat = p1.ToInt();
- CFX_WideString swResult;
-
- switch (nFormat)
- {
- case 0:
- swResult.Format(L"D:%04d%02d%02d%02d%02d%02d",
- jsDate.GetYear(),
- jsDate.GetMonth() + 1,
- jsDate.GetDay(),
- jsDate.GetHours(),
- jsDate.GetMinutes(),
- jsDate.GetSeconds());
- break;
- case 1:
- swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d",
- jsDate.GetYear(),
- jsDate.GetMonth() + 1,
- jsDate.GetDay(),
- jsDate.GetHours(),
- jsDate.GetMinutes(),
- jsDate.GetSeconds());
- break;
- case 2:
- swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d",
- jsDate.GetYear(),
- jsDate.GetMonth() + 1,
- jsDate.GetDay(),
- jsDate.GetHours(),
- jsDate.GetMinutes(),
- jsDate.GetSeconds());
- break;
- default:
- return FALSE;
- }
-
- vRet = swResult.c_str();
- return TRUE;
- }
- else if (p1.GetType() == VT_string)
- {
- std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str();
-
- bool bXFAPicture = false;
- if (iSize > 2)
- {
- bXFAPicture = params[2].ToBool();
- }
-
- if (bXFAPicture)
- {
- return FALSE; //currently, it doesn't support XFAPicture.
- }
+ v8::Isolate* isolate = GetIsolate(cc);
+
+ int iSize = params.size();
+ if (iSize < 2)
+ return FALSE;
+
+ CJS_Value p1(isolate);
+ p1 = params[0];
+
+ CJS_Value p2 = params[1];
+ CJS_Date jsDate(isolate);
+ if (!p2.ConvertToDate(jsDate))
+ {
+ sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT1);
+ return FALSE;
+ }
+
+ if (!jsDate.IsValidDate())
+ {
+ sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT2);
+ return FALSE;
+ }
+
+ if (p1.GetType() == VT_number)
+ {
+ int nFormat = p1.ToInt();
+ CFX_WideString swResult;
+
+ switch (nFormat)
+ {
+ case 0:
+ swResult.Format(L"D:%04d%02d%02d%02d%02d%02d",
+ jsDate.GetYear(),
+ jsDate.GetMonth() + 1,
+ jsDate.GetDay(),
+ jsDate.GetHours(),
+ jsDate.GetMinutes(),
+ jsDate.GetSeconds());
+ break;
+ case 1:
+ swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d",
+ jsDate.GetYear(),
+ jsDate.GetMonth() + 1,
+ jsDate.GetDay(),
+ jsDate.GetHours(),
+ jsDate.GetMinutes(),
+ jsDate.GetSeconds());
+ break;
+ case 2:
+ swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d",
+ jsDate.GetYear(),
+ jsDate.GetMonth() + 1,
+ jsDate.GetDay(),
+ jsDate.GetHours(),
+ jsDate.GetMinutes(),
+ jsDate.GetSeconds());
+ break;
+ default:
+ return FALSE;
+ }
+
+ vRet = swResult.c_str();
+ return TRUE;
+ }
+ if (p1.GetType() == VT_string)
+ {
+ std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str();
+
+ bool bXFAPicture = false;
+ if (iSize > 2)
+ {
+ bXFAPicture = params[2].ToBool();
+ }
+
+ if (bXFAPicture)
+ {
+ return FALSE; //currently, it doesn't support XFAPicture.
+ }
int iIndex;
- for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++)
- {
- int iStart = 0;
- int iEnd;
- while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1)
- {
- cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark);
- iStart = iEnd;
- }
- }
-
- int iYear,iMonth,iDay,iHour,iMin,iSec;
- iYear = jsDate.GetYear();
- iMonth = jsDate.GetMonth();
- iDay = jsDate.GetDay();
- iHour = jsDate.GetHours();
- iMin = jsDate.GetMinutes();
- iSec = jsDate.GetSeconds();
-
- struct tm time = {};
- time.tm_year = iYear-1900;
- time.tm_mon = iMonth;
- time.tm_mday = iDay;
- time.tm_hour = iHour;
- time.tm_min = iMin;
- time.tm_sec = iSec;
- //COleDateTime cppTm(iYear,iMonth+1,iDay,iHour,iMin,iSec);
- //CString strFormat = cppTm.Format(cFormat.c_str());
-
- struct stru_TbConvertAd
- {
- const FX_WCHAR* lpszJSMark;
- int iValue;
- };
-
- stru_TbConvertAd cTableAd[] ={
- { L"m", iMonth+1 },
- { L"d", iDay },
- { L"H", iHour },
- { L"h", iHour>12?iHour-12:iHour },
- { L"M", iMin },
- { L"s", iSec },
- };
-
- //cFormat = strFormat.GetBuffer(strFormat.GetLength()+1);
- for(iIndex = 0;iIndex<sizeof(cTableAd)/sizeof(stru_TbConvertAd);iIndex++)
- {
- wchar_t tszValue[10];
- //_itot(cTableAd[iIndex].iValue,tszValue,10);
- CFX_WideString sValue;
- sValue.Format(L"%d",cTableAd[iIndex].iValue);
- memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+1),
+ for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++)
+ {
+ int iStart = 0;
+ int iEnd;
+ while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1)
+ {
+ cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark);
+ iStart = iEnd;
+ }
+ }
+
+ int iYear,iMonth,iDay,iHour,iMin,iSec;
+ iYear = jsDate.GetYear();
+ iMonth = jsDate.GetMonth();
+ iDay = jsDate.GetDay();
+ iHour = jsDate.GetHours();
+ iMin = jsDate.GetMinutes();
+ iSec = jsDate.GetSeconds();
+
+ struct tm time = {};
+ time.tm_year = iYear-1900;
+ time.tm_mon = iMonth;
+ time.tm_mday = iDay;
+ time.tm_hour = iHour;
+ time.tm_min = iMin;
+ time.tm_sec = iSec;
+
+ struct stru_TbConvertAd
+ {
+ const FX_WCHAR* lpszJSMark;
+ int iValue;
+ };
+
+ stru_TbConvertAd cTableAd[] ={
+ { L"m", iMonth+1 },
+ { L"d", iDay },
+ { L"H", iHour },
+ { L"h", iHour>12?iHour-12:iHour },
+ { L"M", iMin },
+ { L"s", iSec },
+ };
+
+ for(iIndex = 0;iIndex<sizeof(cTableAd)/sizeof(stru_TbConvertAd);iIndex++)
+ {
+ wchar_t tszValue[10];
+ CFX_WideString sValue;
+ sValue.Format(L"%d",cTableAd[iIndex].iValue);
+ memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+1),
(sValue.GetLength()+1)*sizeof(wchar_t));
- //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d");
- //strFormat.Format(strFormat,cTableAd[iIndex].iValue);
- int iStart = 0;
- int iEnd;
- while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1)
- {
- if (iEnd > 0)
- {
- if (cFormat[iEnd-1] == L'%')
- {
- iStart = iEnd+1;
- continue;
- }
- }
- cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[iIndex].lpszJSMark), tszValue);
- iStart = iEnd;
- }
- }
-
- CFX_WideString strFormat;
-// strFormat.Format(L"%d,%d,%d,%d,%d,%d",iYear, iMonth, iDay, iHour, iMin, iSec);
-// CString strFormat = cppTm.Format(cFormat.c_str());
- wchar_t buf[64] = {};
- strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
- cFormat = buf;
- vRet = cFormat.c_str();
- //rtRet = strFormat.GetBuffer(strFormat.GetLength()+1);
- return TRUE;
- }
- return FALSE;
+ int iStart = 0;
+ int iEnd;
+ while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1)
+ {
+ if (iEnd > 0)
+ {
+ if (cFormat[iEnd-1] == L'%')
+ {
+ iStart = iEnd+1;
+ continue;
+ }
+ }
+ cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[iIndex].lpszJSMark), tszValue);
+ iStart = iEnd;
+ }
+ }
+
+ CFX_WideString strFormat;
+ wchar_t buf[64] = {};
+ strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
+ cFormat = buf;
+ vRet = cFormat.c_str();
+ return TRUE;
+ }
+ return FALSE;
}
void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPicture, std::wstring &cPurpose)
{
- std::wstring cFormat = cFormat2;
+ std::wstring cFormat = cFormat2;
- if (bXFAPicture)
- {
- return ; //currently, it doesn't support XFAPicture.
- }
+ if (bXFAPicture)
+ {
+ return ; //currently, it doesn't support XFAPicture.
+ }
int iIndex;
- for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++)
- {
- int iStart = 0;
- int iEnd;
- while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1)
- {
- cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark);
- iStart = iEnd;
- }
- }
-
- int iYear,iMonth,iDay,iHour,iMin,iSec;
- iYear = jsDate.GetYear();
- iMonth = jsDate.GetMonth();
- iDay = jsDate.GetDay();
- iHour = jsDate.GetHours();
- iMin = jsDate.GetMinutes();
- iSec = jsDate.GetSeconds();
-
- struct tm time = {};
- time.tm_year = iYear-1900;
- time.tm_mon = iMonth;
- time.tm_mday = iDay;
- time.tm_hour = iHour;
- time.tm_min = iMin;
- time.tm_sec = iSec;
-// COleDateTime cppTm(iYear,iMonth+1,iDay,iHour,iMin,iSec);
- //CString strFormat = cppTm.Format(cFormat.c_str());
-
- struct stru_TbConvertAd
- {
- const FX_WCHAR* lpszJSMark;
- int iValue;
- };
-
- stru_TbConvertAd cTableAd[] ={
- { L"m", iMonth+1 },
- { L"d", iDay },
- { L"H", iHour },
- { L"h", iHour>12?iHour-12:iHour },
- { L"M", iMin },
- { L"s", iSec },
- };
-
- //cFormat = strFormat.GetBuffer(strFormat.GetLength()+1);
- for(iIndex = 0;iIndex<sizeof(cTableAd)/sizeof(stru_TbConvertAd);iIndex++)
- {
- wchar_t tszValue[10];
- //_itot(cTableAd[iIndex].iValue,tszValue,10);
- CFX_WideString sValue;
- sValue.Format(L"%d",cTableAd[iIndex].iValue);
- memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+1),sValue.GetLength()*sizeof(wchar_t));
-
-
- //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d");
- //strFormat.Format(strFormat,cTableAd[iIndex].iValue);
- int iStart = 0;
- int iEnd;
- while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1)
- {
- if (iEnd > 0)
- {
- if (cFormat[iEnd-1] == L'%')
- {
- iStart = iEnd+1;
- continue;
- }
- }
- cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJSMark),tszValue);
- iStart = iEnd;
- }
- }
-
- CFX_WideString strFormat;
- wchar_t buf[64] = {};
- strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
- cFormat = buf;
- cPurpose = cFormat;
+ for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++)
+ {
+ int iStart = 0;
+ int iEnd;
+ while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1)
+ {
+ cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark);
+ iStart = iEnd;
+ }
+ }
+
+ int iYear,iMonth,iDay,iHour,iMin,iSec;
+ iYear = jsDate.GetYear();
+ iMonth = jsDate.GetMonth();
+ iDay = jsDate.GetDay();
+ iHour = jsDate.GetHours();
+ iMin = jsDate.GetMinutes();
+ iSec = jsDate.GetSeconds();
+
+ struct tm time = {};
+ time.tm_year = iYear-1900;
+ time.tm_mon = iMonth;
+ time.tm_mday = iDay;
+ time.tm_hour = iHour;
+ time.tm_min = iMin;
+ time.tm_sec = iSec;
+// COleDateTime cppTm(iYear,iMonth+1,iDay,iHour,iMin,iSec);
+ //CString strFormat = cppTm.Format(cFormat.c_str());
+
+ struct stru_TbConvertAd
+ {
+ const FX_WCHAR* lpszJSMark;
+ int iValue;
+ };
+
+ stru_TbConvertAd cTableAd[] ={
+ { L"m", iMonth+1 },
+ { L"d", iDay },
+ { L"H", iHour },
+ { L"h", iHour>12?iHour-12:iHour },
+ { L"M", iMin },
+ { L"s", iSec },
+ };
+
+ //cFormat = strFormat.GetBuffer(strFormat.GetLength()+1);
+ for(iIndex = 0;iIndex<sizeof(cTableAd)/sizeof(stru_TbConvertAd);iIndex++)
+ {
+ wchar_t tszValue[10];
+ //_itot(cTableAd[iIndex].iValue,tszValue,10);
+ CFX_WideString sValue;
+ sValue.Format(L"%d",cTableAd[iIndex].iValue);
+ memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+1),sValue.GetLength()*sizeof(wchar_t));
+
+
+ //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d");
+ //strFormat.Format(strFormat,cTableAd[iIndex].iValue);
+ int iStart = 0;
+ int iEnd;
+ while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1)
+ {
+ if (iEnd > 0)
+ {
+ if (cFormat[iEnd-1] == L'%')
+ {
+ iStart = iEnd+1;
+ continue;
+ }
+ }
+ cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJSMark),tszValue);
+ iStart = iEnd;
+ }
+ }
+
+ CFX_WideString strFormat;
+ wchar_t buf[64] = {};
+ strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
+ cFormat = buf;
+ cPurpose = cFormat;
}
FX_BOOL util::printx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- int iSize = params.size();
- if (iSize<2)
- return FALSE;
- CFX_WideString sFormat = params[0].ToCFXWideString();
- CFX_WideString sSource = params[1].ToCFXWideString();
- std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str();
- std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str();
- std::string cDest;
- printx(cFormat,cSource,cDest);
- vRet = cDest.c_str();
- return TRUE;
+ int iSize = params.size();
+ if (iSize<2)
+ return FALSE;
+ CFX_WideString sFormat = params[0].ToCFXWideString();
+ CFX_WideString sSource = params[1].ToCFXWideString();
+ std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str();
+ std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str();
+ std::string cDest;
+ printx(cFormat,cSource,cDest);
+ vRet = cDest.c_str();
+ return TRUE;
}
void util::printx(const std::string &cFormat,const std::string &cSource2,std::string &cPurpose)
{
- std::string cSource(cSource2);
- if (!cPurpose.empty())
- //cPurpose.clear();
- cPurpose.erase();
- int itSource = 0;
- int iSize = cSource.size();
- for(int iIndex = 0; iIndex < (int)cFormat.size() && itSource<iSize; iIndex++)
- {
- char letter = cFormat[iIndex];
- switch(letter)
- {
- case '?':
- //cPurpose.push_back(cSource[itSource]);
- cPurpose += cSource[itSource];
- itSource++;
- break;
- case 'X':
- {
- while(itSource < iSize)
- {
- if ((cSource[itSource]>='0'&&cSource[itSource]<='9') || (cSource[itSource]>='a' && cSource[itSource]<='z') || (cSource[itSource]>='A' && cSource[itSource]<='Z'))
- {
- //cPurpose.push_back(cSource[itSource]);
- cPurpose += cSource[itSource];
- itSource++;
- break;
- }
- itSource++;
- }
- break;
- }
- break;
- case 'A':
- {
- while(itSource < iSize)
- {
- if ((cSource[itSource]>='a' && cSource[itSource]<='z') || (cSource[itSource]>='A' && cSource[itSource]<='Z'))
- {
- //cPurpose.push_back(cSource[itSource]);
- cPurpose += cSource[itSource];
- itSource++;
- break;
- }
- itSource++;
- }
- break;
- }
- break;
- case '9':
- {
- while(itSource < iSize)
- {
- if (cSource[itSource]>='0'&&cSource[itSource]<='9')
- {
- //cPurpose.push_back(cSource[itSource]);
- cPurpose += cSource[itSource];
- itSource++;
- break;
- }
- itSource++;
- }
- break;
- }
- case '*':
- {
- cPurpose.append(cSource,itSource,iSize-itSource);
- itSource = iSize-1;
- break;
- }
- case '\\':
- break;
- case '>':
- {
- for(std::string::iterator it = cSource.begin();it != cSource.end(); it++)
- {
- *it = toupper(*it);
- }
- break;
- }
- case '<':
- {
- for(std::string::iterator it = cSource.begin();it != cSource.end(); it++)
- {
- *it = tolower(*it);
- }
- break;
- }
- case '=':
- break;
- default:
- //cPurpose.push_back(letter);
- cPurpose += letter;
- break;
- }
- }
+ std::string cSource(cSource2);
+ if (!cPurpose.empty())
+ //cPurpose.clear();
+ cPurpose.erase();
+ int itSource = 0;
+ int iSize = cSource.size();
+ for(int iIndex = 0; iIndex < (int)cFormat.size() && itSource<iSize; iIndex++)
+ {
+ char letter = cFormat[iIndex];
+ switch(letter)
+ {
+ case '?':
+ //cPurpose.push_back(cSource[itSource]);
+ cPurpose += cSource[itSource];
+ itSource++;
+ break;
+ case 'X':
+ {
+ while(itSource < iSize)
+ {
+ if ((cSource[itSource]>='0'&&cSource[itSource]<='9') || (cSource[itSource]>='a' && cSource[itSource]<='z') || (cSource[itSource]>='A' && cSource[itSource]<='Z'))
+ {
+ //cPurpose.push_back(cSource[itSource]);
+ cPurpose += cSource[itSource];
+ itSource++;
+ break;
+ }
+ itSource++;
+ }
+ break;
+ }
+ break;
+ case 'A':
+ {
+ while(itSource < iSize)
+ {
+ if ((cSource[itSource]>='a' && cSource[itSource]<='z') || (cSource[itSource]>='A' && cSource[itSource]<='Z'))
+ {
+ //cPurpose.push_back(cSource[itSource]);
+ cPurpose += cSource[itSource];
+ itSource++;
+ break;
+ }
+ itSource++;
+ }
+ break;
+ }
+ break;
+ case '9':
+ {
+ while(itSource < iSize)
+ {
+ if (cSource[itSource]>='0'&&cSource[itSource]<='9')
+ {
+ //cPurpose.push_back(cSource[itSource]);
+ cPurpose += cSource[itSource];
+ itSource++;
+ break;
+ }
+ itSource++;
+ }
+ break;
+ }
+ case '*':
+ {
+ cPurpose.append(cSource,itSource,iSize-itSource);
+ itSource = iSize-1;
+ break;
+ }
+ case '\\':
+ break;
+ case '>':
+ {
+ for(std::string::iterator it = cSource.begin();it != cSource.end(); it++)
+ {
+ *it = toupper(*it);
+ }
+ break;
+ }
+ case '<':
+ {
+ for(std::string::iterator it = cSource.begin();it != cSource.end(); it++)
+ {
+ *it = tolower(*it);
+ }
+ break;
+ }
+ case '=':
+ break;
+ default:
+ //cPurpose.push_back(letter);
+ cPurpose += letter;
+ break;
+ }
+ }
}
FX_BOOL util::scand(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- v8::Isolate* isolate = GetIsolate(cc);
- int iSize = params.size();
- if (iSize < 2)
- return FALSE;
-
- CFX_WideString sFormat = params[0].ToCFXWideString();
- CFX_WideString sDate = params[1].ToCFXWideString();
- double dDate = JS_GetDateTime();
- if (sDate.GetLength() > 0)
- {
- FX_BOOL bWrongFormat = FALSE;
- dDate = CJS_PublicMethods::MakeRegularDate(sDate,sFormat,bWrongFormat);
- }
-
- if (!JS_PortIsNan(dDate))
- {
- CJS_Date date(isolate,dDate);
- vRet = date;
- }
- else
- {
- vRet.SetNull();
- }
-
- return TRUE;
+ v8::Isolate* isolate = GetIsolate(cc);
+ int iSize = params.size();
+ if (iSize < 2)
+ return FALSE;
+
+ CFX_WideString sFormat = params[0].ToCFXWideString();
+ CFX_WideString sDate = params[1].ToCFXWideString();
+ double dDate = JS_GetDateTime();
+ if (sDate.GetLength() > 0)
+ {
+ FX_BOOL bWrongFormat = FALSE;
+ dDate = CJS_PublicMethods::MakeRegularDate(sDate,sFormat,bWrongFormat);
+ }
+
+ if (!JS_PortIsNan(dDate))
+ {
+ CJS_Date date(isolate,dDate);
+ vRet = date;
+ }
+ else
+ {
+ vRet.SetNull();
+ }
+
+ return TRUE;
}
int64_t FX_atoi64(const char *nptr)
@@ -625,21 +615,18 @@ int64_t FX_atoi64(const char *nptr)
c = (int)(unsigned char)*nptr++; /* get next char */
}
- if (sign == '-')
- return -total;
- else
- return total; /* return result, negated if necessary */
+ return sign == '-' ? -total : total;
}
FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
- int iSize = params.size();
- if (iSize == 0)
- return FALSE;
- int nByte = params[0].ToInt();
- unsigned char cByte = (unsigned char)nByte;
- CFX_WideString csValue;
- csValue.Format(L"%c", cByte);
- vRet = csValue.c_str();
- return TRUE;
+ int iSize = params.size();
+ if (iSize == 0)
+ return FALSE;
+ int nByte = params[0].ToInt();
+ unsigned char cByte = (unsigned char)nByte;
+ CFX_WideString csValue;
+ csValue.Format(L"%c", cByte);
+ vRet = csValue.c_str();
+ return TRUE;
}
diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
index bb2ef7510b..f5c8a815d4 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
@@ -14,649 +14,641 @@
#define PWLCB_DEFAULTFONTSIZE 12.0f
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
+#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
+#define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
/* ---------------------------- CPWL_CBListBox ---------------------------- */
-FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
+FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
+ CPWL_Wnd::OnLButtonUp(point,nFlag);
- if (m_bMouseDown)
- {
- ReleaseCapture();
- m_bMouseDown = FALSE;
+ if (m_bMouseDown)
+ {
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
- if (ClientHitTest(point))
- {
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this,PNM_LBUTTONUP,0,PWL_MAKEDWORD(point.x,point.y));
- }
+ if (ClientHitTest(point))
+ {
+ if (CPWL_Wnd * pParent = GetParentWindow())
+ {
+ pParent->OnNotify(this,PNM_LBUTTONUP,0,PWL_MAKEDWORD(point.x,point.y));
+ }
- FX_BOOL bExit = FALSE;
- OnNotifySelChanged(FALSE,bExit, nFlag);
- if (bExit) return FALSE;
- }
- }
+ FX_BOOL bExit = FALSE;
+ OnNotifySelChanged(FALSE,bExit, nFlag);
+ if (bExit) return FALSE;
+ }
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag)
{
- if (!m_pList) return FALSE;
-
- switch (nChar)
- {
- default:
- return FALSE;
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Home:
- case FWL_VKEY_Left:
- case FWL_VKEY_End:
- case FWL_VKEY_Right:
- break;
- }
-
- switch (nChar)
- {
- case FWL_VKEY_Up:
- m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Down:
- m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Home:
- m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Left:
- m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_End:
- m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Right:
- m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Delete:
- break;
- }
-
- OnNotifySelChanged(TRUE,bExit, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag)
-{
- if (!m_pList) return FALSE;
-
- if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE;
-
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow())
- {
- pComboBox->SetSelectText();
- }
-
- OnNotifySelChanged(TRUE,bExit,nFlag);
-
- return TRUE;
+ if (!m_pList) return FALSE;
+
+ switch (nChar)
+ {
+ default:
+ return FALSE;
+ case FWL_VKEY_Up:
+ case FWL_VKEY_Down:
+ case FWL_VKEY_Home:
+ case FWL_VKEY_Left:
+ case FWL_VKEY_End:
+ case FWL_VKEY_Right:
+ break;
+ }
+
+ switch (nChar)
+ {
+ case FWL_VKEY_Up:
+ m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ break;
+ case FWL_VKEY_Down:
+ m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ break;
+ case FWL_VKEY_Home:
+ m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ break;
+ case FWL_VKEY_Left:
+ m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ break;
+ case FWL_VKEY_End:
+ m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ break;
+ case FWL_VKEY_Right:
+ m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ break;
+ case FWL_VKEY_Delete:
+ break;
+ }
+
+ OnNotifySelChanged(TRUE,bExit, nFlag);
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag)
+{
+ if (!m_pList) return FALSE;
+
+ if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE;
+
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow())
+ {
+ pComboBox->SetSelectText();
+ }
+
+ OnNotifySelChanged(TRUE,bExit,nFlag);
+
+ return TRUE;
}
/* ---------------------------- CPWL_CBButton ---------------------------- */
void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
- CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
+ CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CFX_ByteTextBuf sButton;
+ if (IsVisible() && !rectWnd.IsEmpty())
+ {
+ CFX_ByteTextBuf sButton;
- CPDF_Point ptCenter = GetCenterPoint();
+ CPDF_Point ptCenter = GetCenterPoint();
- CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIANGLE_HALFLEN * 2)
- &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_TRIANGLE_HALFLEN)
- )
- {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
+ if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIANGLE_HALFLEN * 2)
+ &&
+ IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_TRIANGLE_HALFLEN)
+ )
+ {
+ sButton << "0 g\n";
+ sButton << pt1.x << " " << pt1.y << " m\n";
+ sButton << pt2.x << " " << pt2.y << " l\n";
+ sButton << pt3.x << " " << pt3.y << " l\n";
+ sButton << pt1.x << " " << pt1.y << " l f\n";
- sAppStream << "q\n" << sButton << "Q\n";
- }
- }
+ sAppStream << "q\n" << sButton << "Q\n";
+ }
+ }
}
void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
{
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+ CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
- CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
+ CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CPDF_Point ptCenter = GetCenterPoint();
+ if (IsVisible() && !rectWnd.IsEmpty())
+ {
+ CPDF_Point ptCenter = GetCenterPoint();
- CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIANGLE_HALFLEN * 2)
- &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_TRIANGLE_HALFLEN)
- )
- {
- CFX_PathData path;
+ if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIANGLE_HALFLEN * 2)
+ &&
+ IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_TRIANGLE_HALFLEN)
+ )
+ {
+ CFX_PathData path;
- path.SetPointCount(4);
- path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
- path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
- path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
- path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
+ path.SetPointCount(4);
+ path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
+ path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
+ path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
+ path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
- pDevice->DrawPath(&path, pUser2Device, NULL,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,GetTransparency()),
- 0, FXFILL_ALTERNATE);
- }
- }
+ pDevice->DrawPath(&path, pUser2Device, NULL,
+ CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,GetTransparency()),
+ 0, FXFILL_ALTERNATE);
+ }
+ }
}
-FX_BOOL CPWL_CBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
+FX_BOOL CPWL_CBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
+ CPWL_Wnd::OnLButtonDown(point,nFlag);
- SetCapture();
+ SetCapture();
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this,PNM_LBUTTONDOWN,0,PWL_MAKEDWORD(point.x,point.y));
- }
+ if (CPWL_Wnd * pParent = GetParentWindow())
+ {
+ pParent->OnNotify(this,PNM_LBUTTONDOWN,0,PWL_MAKEDWORD(point.x,point.y));
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
+FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
{
- CPWL_Wnd::OnLButtonUp(point, nFlag);
+ CPWL_Wnd::OnLButtonUp(point, nFlag);
- ReleaseCapture();
+ ReleaseCapture();
- return TRUE;
+ return TRUE;
}
/* ---------------------------- CPWL_ComboBox ---------------------------- */
CPWL_ComboBox::CPWL_ComboBox() : m_pEdit(NULL),
- m_pButton(NULL),
- m_pList(NULL),
- m_bPopup(FALSE),
- m_nPopupWhere(0),
- m_nSelectItem(-1),
- m_pFillerNotify(NULL)
+ m_pButton(NULL),
+ m_pList(NULL),
+ m_bPopup(FALSE),
+ m_nPopupWhere(0),
+ m_nSelectItem(-1),
+ m_pFillerNotify(NULL)
{
}
CFX_ByteString CPWL_ComboBox::GetClassName() const
{
- return "CPWL_ComboBox";
+ return "CPWL_ComboBox";
}
void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM & cp)
{
- cp.dwFlags &= ~PWS_HSCROLL;
- cp.dwFlags &= ~PWS_VSCROLL;
+ cp.dwFlags &= ~PWS_HSCROLL;
+ cp.dwFlags &= ~PWS_VSCROLL;
}
void CPWL_ComboBox::SetFocus()
{
- if (m_pEdit)
- m_pEdit->SetFocus();
+ if (m_pEdit)
+ m_pEdit->SetFocus();
}
void CPWL_ComboBox::KillFocus()
{
- SetPopup(FALSE);
- CPWL_Wnd::KillFocus();
+ SetPopup(FALSE);
+ CPWL_Wnd::KillFocus();
}
CFX_WideString CPWL_ComboBox::GetText() const
{
- if (m_pEdit)
- {
- return m_pEdit->GetText();
- }
- return CFX_WideString();
+ if (m_pEdit)
+ {
+ return m_pEdit->GetText();
+ }
+ return CFX_WideString();
}
void CPWL_ComboBox::SetText(const FX_WCHAR* text)
{
- if (m_pEdit)
- m_pEdit->SetText(text);
+ if (m_pEdit)
+ m_pEdit->SetText(text);
}
void CPWL_ComboBox::AddString(const FX_WCHAR* string)
{
- if (m_pList)
- m_pList->AddString(string);
+ if (m_pList)
+ m_pList->AddString(string);
}
int32_t CPWL_ComboBox::GetSelect() const
{
- return m_nSelectItem;
+ return m_nSelectItem;
}
void CPWL_ComboBox::SetSelect(int32_t nItemIndex)
{
- if (m_pList)
- m_pList->Select(nItemIndex);
+ if (m_pList)
+ m_pList->Select(nItemIndex);
- m_pEdit->SetText(m_pList->GetText().c_str());
+ m_pEdit->SetText(m_pList->GetText().c_str());
- m_nSelectItem = nItemIndex;
+ m_nSelectItem = nItemIndex;
}
void CPWL_ComboBox::SetEditSel(int32_t nStartChar,int32_t nEndChar)
{
- if (m_pEdit)
- {
- m_pEdit->SetSel(nStartChar,nEndChar);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->SetSel(nStartChar,nEndChar);
+ }
}
void CPWL_ComboBox::GetEditSel(int32_t & nStartChar, int32_t & nEndChar) const
{
- nStartChar = -1;
- nEndChar = -1;
+ nStartChar = -1;
+ nEndChar = -1;
- if (m_pEdit)
- {
- m_pEdit->GetSel(nStartChar,nEndChar);
- }
+ if (m_pEdit)
+ {
+ m_pEdit->GetSel(nStartChar,nEndChar);
+ }
}
void CPWL_ComboBox::Clear()
{
- if (m_pEdit)
- {
- m_pEdit->Clear();
- }
+ if (m_pEdit)
+ {
+ m_pEdit->Clear();
+ }
}
void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM & cp)
{
- CreateEdit(cp);
- CreateButton(cp);
- CreateListBox(cp);
+ CreateEdit(cp);
+ CreateButton(cp);
+ CreateListBox(cp);
}
void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM & cp)
{
- if (!m_pEdit)
- {
- m_pEdit = new CPWL_CBEdit;
- m_pEdit->AttachFFLData(m_pFormFiller);
+ if (!m_pEdit)
+ {
+ m_pEdit = new CPWL_CBEdit;
+ m_pEdit->AttachFFLData(m_pFormFiller);
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER | PES_AUTOSCROLL | PES_UNDO;
+ PWL_CREATEPARAM ecp = cp;
+ ecp.pParentWnd = this;
+ ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER | PES_AUTOSCROLL | PES_UNDO;
- if (HasFlag(PWS_AUTOFONTSIZE))
- ecp.dwFlags |= PWS_AUTOFONTSIZE;
+ if (HasFlag(PWS_AUTOFONTSIZE))
+ ecp.dwFlags |= PWS_AUTOFONTSIZE;
- if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
- ecp.dwFlags |= PWS_READONLY;
+ if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ ecp.dwFlags |= PWS_READONLY;
- ecp.rcRectWnd = CPDF_Rect(0,0,0,0);
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
+ ecp.rcRectWnd = CPDF_Rect(0,0,0,0);
+ ecp.dwBorderWidth = 0;
+ ecp.nBorderStyle = PBS_SOLID;
- m_pEdit->Create(ecp);
- }
+ m_pEdit->Create(ecp);
+ }
}
void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM & cp)
{
- if (!m_pButton)
- {
- m_pButton = new CPWL_CBButton;
+ if (!m_pButton)
+ {
+ m_pButton = new CPWL_CBButton;
- PWL_CREATEPARAM bcp = cp;
- bcp.pParentWnd = this;
- bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND;
- bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR;
- bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
- bcp.dwBorderWidth = 2;
- bcp.nBorderStyle = PBS_BEVELED;
- bcp.eCursorType = FXCT_ARROW;
+ PWL_CREATEPARAM bcp = cp;
+ bcp.pParentWnd = this;
+ bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND;
+ bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR;
+ bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
+ bcp.dwBorderWidth = 2;
+ bcp.nBorderStyle = PBS_BEVELED;
+ bcp.eCursorType = FXCT_ARROW;
- m_pButton->Create(bcp);
- }
+ m_pButton->Create(bcp);
+ }
}
void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM & cp)
{
- if (!m_pList)
- {
- m_pList = new CPWL_CBListBox;
- m_pList->AttachFFLData(m_pFormFiller);
- PWL_CREATEPARAM lcp = cp;
- lcp.pParentWnd = this;
- lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL;
- lcp.nBorderStyle = PBS_SOLID;
- lcp.dwBorderWidth = 1;
- lcp.eCursorType = FXCT_ARROW;
- lcp.rcRectWnd = CPDF_Rect(0,0,0,0);
+ if (!m_pList)
+ {
+ m_pList = new CPWL_CBListBox;
+ m_pList->AttachFFLData(m_pFormFiller);
+ PWL_CREATEPARAM lcp = cp;
+ lcp.pParentWnd = this;
+ lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL;
+ lcp.nBorderStyle = PBS_SOLID;
+ lcp.dwBorderWidth = 1;
+ lcp.eCursorType = FXCT_ARROW;
+ lcp.rcRectWnd = CPDF_Rect(0,0,0,0);
- if (cp.dwFlags & PWS_AUTOFONTSIZE)
- lcp.fFontSize = PWLCB_DEFAULTFONTSIZE;
- else
- lcp.fFontSize = cp.fFontSize;
+ if (cp.dwFlags & PWS_AUTOFONTSIZE)
+ lcp.fFontSize = PWLCB_DEFAULTFONTSIZE;
+ else
+ lcp.fFontSize = cp.fFontSize;
- if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT)
- lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
+ if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT)
+ lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
- if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT)
- lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
+ if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT)
+ lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
- m_pList->Create(lcp);
- }
+ m_pList->Create(lcp);
+ }
}
void CPWL_ComboBox::RePosChildWnd()
{
- CPDF_Rect rcClient = GetClientRect();
+ CPDF_Rect rcClient = GetClientRect();
- if (m_bPopup)
- {
- CPDF_Rect rclient = GetClientRect();
- CPDF_Rect rcButton = rclient;
- CPDF_Rect rcEdit = rcClient;
- CPDF_Rect rcList = CPWL_Wnd::GetWindowRect();
+ if (m_bPopup)
+ {
+ CPDF_Rect rclient = GetClientRect();
+ CPDF_Rect rcButton = rclient;
+ CPDF_Rect rcEdit = rcClient;
+ CPDF_Rect rcList = CPWL_Wnd::GetWindowRect();
- FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height();
- FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2;
+ FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height();
+ FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2;
- switch (m_nPopupWhere)
- {
- case 0:
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
+ switch (m_nPopupWhere)
+ {
+ case 0:
+ rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
- if (rcButton.left < rclient.left)
- rcButton.left = rclient.left;
+ if (rcButton.left < rclient.left)
+ rcButton.left = rclient.left;
- rcButton.bottom = rcButton.top - fOldClientHeight;
+ rcButton.bottom = rcButton.top - fOldClientHeight;
- rcEdit.right = rcButton.left - 1.0f;
+ rcEdit.right = rcButton.left - 1.0f;
- if (rcEdit.left < rclient.left)
- rcEdit.left = rclient.left;
+ if (rcEdit.left < rclient.left)
+ rcEdit.left = rclient.left;
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
+ if (rcEdit.right < rcEdit.left)
+ rcEdit.right = rcEdit.left;
- rcEdit.bottom = rcEdit.top - fOldClientHeight;
+ rcEdit.bottom = rcEdit.top - fOldClientHeight;
- rcList.top -= fOldWindowHeight;
+ rcList.top -= fOldWindowHeight;
- break;
- case 1:
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
+ break;
+ case 1:
+ rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
- if (rcButton.left < rclient.left)
- rcButton.left = rclient.left;
+ if (rcButton.left < rclient.left)
+ rcButton.left = rclient.left;
- rcButton.top = rcButton.bottom + fOldClientHeight;
+ rcButton.top = rcButton.bottom + fOldClientHeight;
- rcEdit.right = rcButton.left - 1.0f;
+ rcEdit.right = rcButton.left - 1.0f;
- if (rcEdit.left < rclient.left)
- rcEdit.left = rclient.left;
+ if (rcEdit.left < rclient.left)
+ rcEdit.left = rclient.left;
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
+ if (rcEdit.right < rcEdit.left)
+ rcEdit.right = rcEdit.left;
- rcEdit.top = rcEdit.bottom + fOldClientHeight;
+ rcEdit.top = rcEdit.bottom + fOldClientHeight;
- rcList.bottom += fOldWindowHeight;
+ rcList.bottom += fOldWindowHeight;
- break;
- }
+ break;
+ }
- if (m_pButton)
- m_pButton->Move(rcButton,TRUE,FALSE);
+ if (m_pButton)
+ m_pButton->Move(rcButton,TRUE,FALSE);
- if (m_pEdit)
- m_pEdit->Move(rcEdit,TRUE,FALSE);
+ if (m_pEdit)
+ m_pEdit->Move(rcEdit,TRUE,FALSE);
- if (m_pList)
- {
- m_pList->SetVisible(TRUE);
- m_pList->Move(rcList,TRUE,FALSE);
- m_pList->ScrollToListItem(m_nSelectItem);
- }
- }
- else
- {
- CPDF_Rect rcButton = rcClient;
+ if (m_pList)
+ {
+ m_pList->SetVisible(TRUE);
+ m_pList->Move(rcList,TRUE,FALSE);
+ m_pList->ScrollToListItem(m_nSelectItem);
+ }
+ }
+ else
+ {
+ CPDF_Rect rcButton = rcClient;
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
+ rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
- if (rcButton.left < rcClient.left)
- rcButton.left = rcClient.left;
+ if (rcButton.left < rcClient.left)
+ rcButton.left = rcClient.left;
- if (m_pButton)
- m_pButton->Move(rcButton,TRUE,FALSE);
+ if (m_pButton)
+ m_pButton->Move(rcButton,TRUE,FALSE);
- CPDF_Rect rcEdit = rcClient;
- rcEdit.right = rcButton.left - 1.0f;
+ CPDF_Rect rcEdit = rcClient;
+ rcEdit.right = rcButton.left - 1.0f;
- if (rcEdit.left < rcClient.left)
- rcEdit.left = rcClient.left;
+ if (rcEdit.left < rcClient.left)
+ rcEdit.left = rcClient.left;
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
+ if (rcEdit.right < rcEdit.left)
+ rcEdit.right = rcEdit.left;
- if (m_pEdit)
- m_pEdit->Move(rcEdit,TRUE,FALSE);
+ if (m_pEdit)
+ m_pEdit->Move(rcEdit,TRUE,FALSE);
- if (m_pList)
- m_pList->SetVisible(FALSE);
- }
+ if (m_pList)
+ m_pList->SetVisible(FALSE);
+ }
}
void CPWL_ComboBox::SelectAll()
{
- if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT))
- m_pEdit->SelectAll();
+ if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ m_pEdit->SelectAll();
}
CPDF_Rect CPWL_ComboBox::GetFocusRect() const
{
- return CPDF_Rect();
+ return CPDF_Rect();
}
void CPWL_ComboBox::SetPopup(FX_BOOL bPopup)
{
- if (!m_pList) return;
- if (bPopup == m_bPopup) return;
- FX_FLOAT fListHeight = m_pList->GetContentRect().Height();
- if (!IsFloatBigger(fListHeight,0.0f)) return;
-
- if (bPopup)
- {
- if (m_pFillerNotify)
- {
- int32_t nWhere = 0;
- FX_FLOAT fPopupRet = 0.0f;
- FX_FLOAT fPopupMin = 0.0f;
- if (m_pList->GetCount() > 3)
- fPopupMin = m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2;
- FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2;
- m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin,fPopupMax,nWhere,fPopupRet);
-
- if (IsFloatBigger(fPopupRet,0.0f))
- {
- m_bPopup = bPopup;
-
- CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect();
- m_rcOldWindow = rcWindow;
- switch (nWhere)
- {
- default:
- case 0:
- rcWindow.bottom -= fPopupRet;
- break;
- case 1:
- rcWindow.top += fPopupRet;
- break;
- }
-
- m_nPopupWhere = nWhere;
- Move(rcWindow, TRUE, TRUE);
- }
- }
- }
- else
- {
- m_bPopup = bPopup;
- Move(m_rcOldWindow, TRUE, TRUE);
- }
+ if (!m_pList) return;
+ if (bPopup == m_bPopup) return;
+ FX_FLOAT fListHeight = m_pList->GetContentRect().Height();
+ if (!IsFloatBigger(fListHeight,0.0f)) return;
+
+ if (bPopup)
+ {
+ if (m_pFillerNotify)
+ {
+ int32_t nWhere = 0;
+ FX_FLOAT fPopupRet = 0.0f;
+ FX_FLOAT fPopupMin = 0.0f;
+ if (m_pList->GetCount() > 3)
+ fPopupMin = m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2;
+ FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2;
+ m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin,fPopupMax,nWhere,fPopupRet);
+
+ if (IsFloatBigger(fPopupRet,0.0f))
+ {
+ m_bPopup = bPopup;
+
+ CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect();
+ m_rcOldWindow = rcWindow;
+ switch (nWhere)
+ {
+ default:
+ case 0:
+ rcWindow.bottom -= fPopupRet;
+ break;
+ case 1:
+ rcWindow.top += fPopupRet;
+ break;
+ }
+
+ m_nPopupWhere = nWhere;
+ Move(rcWindow, TRUE, TRUE);
+ }
+ }
+ }
+ else
+ {
+ m_bPopup = bPopup;
+ Move(m_rcOldWindow, TRUE, TRUE);
+ }
}
FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
{
- if (!m_pList) return FALSE;
- if (!m_pEdit) return FALSE;
-
- m_nSelectItem = -1;
-
- switch (nChar)
- {
- case FWL_VKEY_Up:
- if (m_pList->GetCurSel() > 0)
- {
- FX_BOOL bExit = FALSE;
- if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
- {
- if (bExit) return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- case FWL_VKEY_Down:
- if (m_pList->GetCurSel() < m_pList->GetCount() - 1)
- {
- FX_BOOL bExit = FALSE;
- if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
- {
- if (bExit) return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- }
-
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- return m_pEdit->OnKeyDown(nChar,nFlag);
- else
- return FALSE;
+ if (!m_pList) return FALSE;
+ if (!m_pEdit) return FALSE;
+
+ m_nSelectItem = -1;
+
+ switch (nChar)
+ {
+ case FWL_VKEY_Up:
+ if (m_pList->GetCurSel() > 0)
+ {
+ FX_BOOL bExit = FALSE;
+ if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
+ {
+ if (bExit) return FALSE;
+ SetSelectText();
+ }
+ }
+ return TRUE;
+ case FWL_VKEY_Down:
+ if (m_pList->GetCurSel() < m_pList->GetCount() - 1)
+ {
+ FX_BOOL bExit = FALSE;
+ if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
+ {
+ if (bExit) return FALSE;
+ SetSelectText();
+ }
+ }
+ return TRUE;
+ }
+
+ if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ return m_pEdit->OnKeyDown(nChar,nFlag);
+
+ return FALSE;
}
FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag)
{
- if (!m_pList) return FALSE;
- if (!m_pEdit) return FALSE;
+ if (!m_pList)
+ return FALSE;
- m_nSelectItem = -1;
- FX_BOOL bExit = FALSE;
+ if (!m_pEdit)
+ return FALSE;
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- {
- return m_pEdit->OnChar(nChar,nFlag);
- }
- else
- {
- if (m_pList->OnCharWithExit(nChar,bExit,nFlag))
- {
- return bExit;
- }
- else
- return FALSE;
- }
+ m_nSelectItem = -1;
+ if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ return m_pEdit->OnChar(nChar,nFlag);
+
+ FX_BOOL bExit = FALSE;
+ return m_pList->OnCharWithExit(nChar,bExit,nFlag) ? bExit : FALSE;
}
void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
{
- switch (msg)
- {
- case PNM_LBUTTONDOWN:
- if (pWnd == m_pButton)
- {
- SetPopup(!m_bPopup);
- return;
- }
- break;
- case PNM_LBUTTONUP:
- if (m_pEdit && m_pList)
- {
- if (pWnd == m_pList)
- {
- SetSelectText();
- SelectAll();
- m_pEdit->SetFocus();
- SetPopup(FALSE);
- return;
- }
- }
- }
-
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
+ switch (msg)
+ {
+ case PNM_LBUTTONDOWN:
+ if (pWnd == m_pButton)
+ {
+ SetPopup(!m_bPopup);
+ return;
+ }
+ break;
+ case PNM_LBUTTONUP:
+ if (m_pEdit && m_pList)
+ {
+ if (pWnd == m_pList)
+ {
+ SetSelectText();
+ SelectAll();
+ m_pEdit->SetFocus();
+ SetPopup(FALSE);
+ return;
+ }
+ }
+ }
+
+ CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
}
FX_BOOL CPWL_ComboBox::IsPopup() const
{
- return m_bPopup;
+ return m_bPopup;
}
void CPWL_ComboBox::SetSelectText()
{
- CFX_WideString swText = m_pList->GetText();
- m_pEdit->SelectAll();
- m_pEdit->ReplaceSel(m_pList->GetText().c_str());
- m_pEdit->SelectAll();
+ CFX_WideString swText = m_pList->GetText();
+ m_pEdit->SelectAll();
+ m_pEdit->ReplaceSel(m_pList->GetText().c_str());
+ m_pEdit->SelectAll();
- m_nSelectItem = m_pList->GetCurSel();
+ m_nSelectItem = m_pList->GetCurSel();
}
FX_BOOL CPWL_ComboBox::IsModified() const
{
- return m_pEdit->IsModified();
+ return m_pEdit->IsModified();
}
void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify)
{
- m_pFillerNotify = pNotify;
+ m_pFillerNotify = pNotify;
- if (m_pEdit)
- m_pEdit->SetFillerNotify(pNotify);
+ if (m_pEdit)
+ m_pEdit->SetFillerNotify(pNotify);
- if (m_pList)
- m_pList->SetFillerNotify(pNotify);
+ if (m_pList)
+ m_pList->SetFillerNotify(pNotify);
}
-
diff --git a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
index f562076f1d..0d14587f66 100644
--- a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
@@ -12,558 +12,558 @@
#include "../../include/pdfwindow/PWL_Caret.h"
#include "../../include/pdfwindow/PWL_FontMap.h"
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
+#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
+#define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
/* ---------------------------- CPWL_EditCtrl ------------------------------ */
CPWL_EditCtrl::CPWL_EditCtrl() :
- m_pEdit(NULL),
- m_pEditCaret(NULL),
- m_bMouseDown(FALSE),
- m_pEditNotify(NULL),
- m_nCharSet(DEFAULT_CHARSET),
- m_nCodePage(0)
+ m_pEdit(NULL),
+ m_pEditCaret(NULL),
+ m_bMouseDown(FALSE),
+ m_pEditNotify(NULL),
+ m_nCharSet(DEFAULT_CHARSET),
+ m_nCodePage(0)
{
- m_pEdit = IFX_Edit::NewEdit();
- ASSERT(m_pEdit != NULL);
+ m_pEdit = IFX_Edit::NewEdit();
+ ASSERT(m_pEdit != NULL);
}
CPWL_EditCtrl::~CPWL_EditCtrl()
{
- IFX_Edit::DelEdit(m_pEdit);
+ IFX_Edit::DelEdit(m_pEdit);
}
-void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM & cp)
+void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp)
{
- cp.eCursorType = FXCT_VBEAM;
+ cp.eCursorType = FXCT_VBEAM;
}
void CPWL_EditCtrl::OnCreated()
{
- SetFontSize(GetCreationParam().fFontSize);
+ SetFontSize(GetCreationParam().fFontSize);
- m_pEdit->SetFontMap(GetFontMap());
- m_pEdit->SetNotify(this);
- m_pEdit->Initialize();
+ m_pEdit->SetFontMap(GetFontMap());
+ m_pEdit->SetNotify(this);
+ m_pEdit->Initialize();
}
FX_BOOL CPWL_EditCtrl::IsWndHorV()
{
- CPDF_Matrix mt = GetWindowMatrix();
- CPDF_Point point1(0,1);
- CPDF_Point point2(1,1);
+ CPDF_Matrix mt = GetWindowMatrix();
+ CPDF_Point point1(0,1);
+ CPDF_Point point2(1,1);
- mt.Transform(point1.x, point1.y);
- mt.Transform(point2.x, point2.y);
+ mt.Transform(point1.x, point1.y);
+ mt.Transform(point2.x, point2.y);
- return point2.y == point1.y;
+ return point2.y == point1.y;
}
void CPWL_EditCtrl::SetCursor()
{
- if (IsValid())
- {
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- {
- if (IsWndHorV())
- pSH->SetCursor(FXCT_VBEAM);
- else
- pSH->SetCursor(FXCT_HBEAM);
- }
- }
+ if (IsValid())
+ {
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ {
+ if (IsWndHorV())
+ pSH->SetCursor(FXCT_VBEAM);
+ else
+ pSH->SetCursor(FXCT_HBEAM);
+ }
+ }
}
void CPWL_EditCtrl::RePosChildWnd()
{
- m_pEdit->SetPlateRect(GetClientRect());
+ m_pEdit->SetPlateRect(GetClientRect());
}
void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
{
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
-
- switch (msg)
- {
- case PNM_SETSCROLLINFO:
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (CPWL_Wnd * pChild = GetVScrollBar())
- {
- pChild->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam);
- }
- break;
- }
- break;
- case PNM_SETSCROLLPOS:
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (CPWL_Wnd * pChild = GetVScrollBar())
- {
- pChild->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
- }
- break;
- }
- break;
- case PNM_SCROLLWINDOW:
- {
- FX_FLOAT fPos = *(FX_FLOAT*)lParam;
- switch (wParam)
- {
- case SBT_VSCROLL:
- m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x,fPos));
- break;
- }
- }
- break;
- case PNM_SETCARETINFO:
- {
- if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INFO *)wParam)
- {
- SetCaret(pCaretInfo->bVisible,
- pCaretInfo->ptHead,
- pCaretInfo->ptFoot);
- }
- }
- break;
- }
+ CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
+
+ switch (msg)
+ {
+ case PNM_SETSCROLLINFO:
+ switch (wParam)
+ {
+ case SBT_VSCROLL:
+ if (CPWL_Wnd * pChild = GetVScrollBar())
+ {
+ pChild->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam);
+ }
+ break;
+ }
+ break;
+ case PNM_SETSCROLLPOS:
+ switch (wParam)
+ {
+ case SBT_VSCROLL:
+ if (CPWL_Wnd * pChild = GetVScrollBar())
+ {
+ pChild->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
+ }
+ break;
+ }
+ break;
+ case PNM_SCROLLWINDOW:
+ {
+ FX_FLOAT fPos = *(FX_FLOAT*)lParam;
+ switch (wParam)
+ {
+ case SBT_VSCROLL:
+ m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x,fPos));
+ break;
+ }
+ }
+ break;
+ case PNM_SETCARETINFO:
+ {
+ if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INFO *)wParam)
+ {
+ SetCaret(pCaretInfo->bVisible,
+ pCaretInfo->ptHead,
+ pCaretInfo->ptFoot);
+ }
+ }
+ break;
+ }
}
void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM & cp)
{
- if (!IsReadOnly())
- CreateEditCaret(cp);
+ if (!IsReadOnly())
+ CreateEditCaret(cp);
}
void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM & cp)
{
- if (!m_pEditCaret)
- {
- m_pEditCaret = new CPWL_Caret;
- m_pEditCaret->SetInvalidRect(GetClientRect());
+ if (!m_pEditCaret)
+ {
+ m_pEditCaret = new CPWL_Caret;
+ m_pEditCaret->SetInvalidRect(GetClientRect());
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
- ecp.rcRectWnd = CPDF_Rect(0,0,0,0);
+ PWL_CREATEPARAM ecp = cp;
+ ecp.pParentWnd = this;
+ ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
+ ecp.dwBorderWidth = 0;
+ ecp.nBorderStyle = PBS_SOLID;
+ ecp.rcRectWnd = CPDF_Rect(0,0,0,0);
- m_pEditCaret->Create(ecp);
- }
+ m_pEditCaret->Create(ecp);
+ }
}
void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize)
{
- m_pEdit->SetFontSize(fFontSize);
+ m_pEdit->SetFontSize(fFontSize);
}
FX_FLOAT CPWL_EditCtrl::GetFontSize() const
{
- return m_pEdit->GetFontSize();
+ return m_pEdit->GetFontSize();
}
FX_BOOL CPWL_EditCtrl::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
{
- if (m_bMouseDown) return TRUE;
-
- FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar,nFlag);
-
- //FILTER
- switch (nChar)
- {
- default:
- return FALSE;
- case FWL_VKEY_Delete:
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Left:
- case FWL_VKEY_Right:
- case FWL_VKEY_Home:
- case FWL_VKEY_End:
- case FWL_VKEY_Insert:
- case 'C':
- case 'V':
- case 'X':
- case 'A':
- case 'Z':
- case 'c':
- case 'v':
- case 'x':
- case 'a':
- case 'z':
- break;
- }
-
- if (nChar == FWL_VKEY_Delete)
- {
- if (m_pEdit->IsSelected())
- nChar = FWL_VKEY_Unknown;
- }
-
- switch (nChar)
- {
- case FWL_VKEY_Delete:
- Delete();
- return TRUE;
- case FWL_VKEY_Insert:
- if (IsSHIFTpressed(nFlag))
- PasteText();
- return TRUE;
- case FWL_VKEY_Up:
- m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag),FALSE);
- return TRUE;
- case FWL_VKEY_Down:
- m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag),FALSE);
- return TRUE;
- case FWL_VKEY_Left:
- m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag),FALSE);
- return TRUE;
- case FWL_VKEY_Right:
- m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag),FALSE);
- return TRUE;
- case FWL_VKEY_Home:
- m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- return TRUE;
- case FWL_VKEY_End:
- m_pEdit->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- return TRUE;
- case FWL_VKEY_Unknown:
- if (!IsSHIFTpressed(nFlag))
- Clear();
- else
- CutText();
- return TRUE;
- default:
- break;
- }
-
- return bRet;
+ if (m_bMouseDown) return TRUE;
+
+ FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar,nFlag);
+
+ //FILTER
+ switch (nChar)
+ {
+ default:
+ return FALSE;
+ case FWL_VKEY_Delete:
+ case FWL_VKEY_Up:
+ case FWL_VKEY_Down:
+ case FWL_VKEY_Left:
+ case FWL_VKEY_Right:
+ case FWL_VKEY_Home:
+ case FWL_VKEY_End:
+ case FWL_VKEY_Insert:
+ case 'C':
+ case 'V':
+ case 'X':
+ case 'A':
+ case 'Z':
+ case 'c':
+ case 'v':
+ case 'x':
+ case 'a':
+ case 'z':
+ break;
+ }
+
+ if (nChar == FWL_VKEY_Delete)
+ {
+ if (m_pEdit->IsSelected())
+ nChar = FWL_VKEY_Unknown;
+ }
+
+ switch (nChar)
+ {
+ case FWL_VKEY_Delete:
+ Delete();
+ return TRUE;
+ case FWL_VKEY_Insert:
+ if (IsSHIFTpressed(nFlag))
+ PasteText();
+ return TRUE;
+ case FWL_VKEY_Up:
+ m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag),FALSE);
+ return TRUE;
+ case FWL_VKEY_Down:
+ m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag),FALSE);
+ return TRUE;
+ case FWL_VKEY_Left:
+ m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag),FALSE);
+ return TRUE;
+ case FWL_VKEY_Right:
+ m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag),FALSE);
+ return TRUE;
+ case FWL_VKEY_Home:
+ m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ return TRUE;
+ case FWL_VKEY_End:
+ m_pEdit->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ return TRUE;
+ case FWL_VKEY_Unknown:
+ if (!IsSHIFTpressed(nFlag))
+ Clear();
+ else
+ CutText();
+ return TRUE;
+ default:
+ break;
+ }
+
+ return bRet;
}
FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag)
{
- if (m_bMouseDown) return TRUE;
-
- CPWL_Wnd::OnChar(nChar,nFlag);
-
- //FILTER
- switch (nChar)
- {
- case 0x0A:
- case 0x1B:
- return FALSE;
- default:
- break;
- }
-
- FX_BOOL bCtrl = IsCTRLpressed(nFlag);
- FX_BOOL bAlt = IsALTpressed(nFlag);
- FX_BOOL bShift = IsSHIFTpressed(nFlag);
-
- FX_WORD word = nChar;
-
- if (bCtrl && !bAlt)
- {
- switch (nChar)
- {
- case 'C' - 'A' + 1:
- CopyText();
- return TRUE;
- case 'V' - 'A' + 1:
- PasteText();
- return TRUE;
- case 'X' - 'A' + 1:
- CutText();
- return TRUE;
- case 'A' - 'A' + 1:
- SelectAll();
- return TRUE;
- case 'Z' - 'A' + 1:
- if (bShift)
- Redo();
- else
- Undo();
- return TRUE;
- default:
- if (nChar < 32)
- return FALSE;
- }
- }
-
- if (IsReadOnly()) return TRUE;
-
- if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
- word = FWL_VKEY_Unknown;
-
- Clear();
-
- switch (word)
- {
- case FWL_VKEY_Back:
- Backspace();
- break;
- case FWL_VKEY_Return:
- InsertReturn();
- break;
- case FWL_VKEY_Unknown:
- break;
- default:
- if (IsINSERTpressed(nFlag))
- Delete();
- InsertWord(word, GetCharSet());
- break;
- }
-
- return TRUE;
+ if (m_bMouseDown) return TRUE;
+
+ CPWL_Wnd::OnChar(nChar,nFlag);
+
+ //FILTER
+ switch (nChar)
+ {
+ case 0x0A:
+ case 0x1B:
+ return FALSE;
+ default:
+ break;
+ }
+
+ FX_BOOL bCtrl = IsCTRLpressed(nFlag);
+ FX_BOOL bAlt = IsALTpressed(nFlag);
+ FX_BOOL bShift = IsSHIFTpressed(nFlag);
+
+ FX_WORD word = nChar;
+
+ if (bCtrl && !bAlt)
+ {
+ switch (nChar)
+ {
+ case 'C' - 'A' + 1:
+ CopyText();
+ return TRUE;
+ case 'V' - 'A' + 1:
+ PasteText();
+ return TRUE;
+ case 'X' - 'A' + 1:
+ CutText();
+ return TRUE;
+ case 'A' - 'A' + 1:
+ SelectAll();
+ return TRUE;
+ case 'Z' - 'A' + 1:
+ if (bShift)
+ Redo();
+ else
+ Undo();
+ return TRUE;
+ default:
+ if (nChar < 32)
+ return FALSE;
+ }
+ }
+
+ if (IsReadOnly()) return TRUE;
+
+ if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
+ word = FWL_VKEY_Unknown;
+
+ Clear();
+
+ switch (word)
+ {
+ case FWL_VKEY_Back:
+ Backspace();
+ break;
+ case FWL_VKEY_Return:
+ InsertReturn();
+ break;
+ case FWL_VKEY_Unknown:
+ break;
+ default:
+ if (IsINSERTpressed(nFlag))
+ Delete();
+ InsertWord(word, GetCharSet());
+ break;
+ }
+
+ return TRUE;
}
FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
+ CPWL_Wnd::OnLButtonDown(point,nFlag);
- if (ClientHitTest(point))
- {
- if (m_bMouseDown)
- InvalidateRect();
+ if (ClientHitTest(point))
+ {
+ if (m_bMouseDown)
+ InvalidateRect();
- m_bMouseDown = TRUE;
- SetCapture();
+ m_bMouseDown = TRUE;
+ SetCapture();
- m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- }
+ m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
+ CPWL_Wnd::OnLButtonUp(point,nFlag);
- if (m_bMouseDown)
- {
- //can receive keybord message
- if (ClientHitTest(point) && !IsFocused())
- SetFocus();
+ if (m_bMouseDown)
+ {
+ //can receive keybord message
+ if (ClientHitTest(point) && !IsFocused())
+ SetFocus();
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
+ }
- return TRUE;
+ return TRUE;
}
FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
{
- CPWL_Wnd::OnMouseMove(point,nFlag);
+ CPWL_Wnd::OnMouseMove(point,nFlag);
- if (m_bMouseDown)
- m_pEdit->OnMouseMove(point,FALSE,FALSE);
+ if (m_bMouseDown)
+ m_pEdit->OnMouseMove(point,FALSE,FALSE);
- return TRUE;
+ return TRUE;
}
CPDF_Rect CPWL_EditCtrl::GetContentRect() const
{
- return m_pEdit->GetContentRect();
+ return m_pEdit->GetContentRect();
}
void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible)
{
- CPDF_Point ptHead(0,0),ptFoot(0,0);
+ CPDF_Point ptHead(0,0),ptFoot(0,0);
- if (bVisible)
- {
- GetCaretInfo(ptHead,ptFoot);
- }
+ if (bVisible)
+ {
+ GetCaretInfo(ptHead,ptFoot);
+ }
- CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
- IOnSetCaret(bVisible,ptHead,ptFoot,wpTemp);
+ CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
+ IOnSetCaret(bVisible,ptHead,ptFoot,wpTemp);
}
void CPWL_EditCtrl::GetCaretInfo(CPDF_Point & ptHead, CPDF_Point & ptFoot) const
{
- if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
- {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- }
- else if (pIterator->GetLine(line))
- {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
+ if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
+ {
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word))
+ {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ }
+ else if (pIterator->GetLine(line))
+ {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
+ }
+ }
}
void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const
{
- CPDF_Point ptHead(0,0), ptFoot(0,0);
+ CPDF_Point ptHead(0,0), ptFoot(0,0);
- GetCaretInfo(ptHead,ptFoot);
+ GetCaretInfo(ptHead,ptFoot);
- PWLtoWnd(ptHead, x, y);
+ PWLtoWnd(ptHead, x, y);
}
void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot)
{
- if (m_pEditCaret)
- {
- if (!IsFocused() || m_pEdit->IsSelected())
- bVisible = FALSE;
+ if (m_pEditCaret)
+ {
+ if (!IsFocused() || m_pEdit->IsSelected())
+ bVisible = FALSE;
- m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
- }
+ m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
+ }
}
-FX_BOOL CPWL_EditCtrl::IsModified() const
+FX_BOOL CPWL_EditCtrl::IsModified() const
{
- return m_pEdit->IsModified();
+ return m_pEdit->IsModified();
}
CFX_WideString CPWL_EditCtrl::GetText() const
{
- return m_pEdit->GetText();
+ return m_pEdit->GetText();
}
void CPWL_EditCtrl::SetSel(int32_t nStartChar,int32_t nEndChar)
{
- m_pEdit->SetSel(nStartChar, nEndChar);
+ m_pEdit->SetSel(nStartChar, nEndChar);
}
void CPWL_EditCtrl::GetSel(int32_t & nStartChar, int32_t & nEndChar ) const
{
- m_pEdit->GetSel(nStartChar, nEndChar);
+ m_pEdit->GetSel(nStartChar, nEndChar);
}
void CPWL_EditCtrl::Clear()
{
- if (!IsReadOnly())
- m_pEdit->Clear();
+ if (!IsReadOnly())
+ m_pEdit->Clear();
}
void CPWL_EditCtrl::SelectAll()
{
- m_pEdit->SelectAll();
+ m_pEdit->SelectAll();
}
void CPWL_EditCtrl::Paint()
{
- if (m_pEdit)
- m_pEdit->Paint();
+ if (m_pEdit)
+ m_pEdit->Paint();
}
void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh)
{
- if (m_pEdit)
- m_pEdit->EnableRefresh(bRefresh);
+ if (m_pEdit)
+ m_pEdit->EnableRefresh(bRefresh);
}
int32_t CPWL_EditCtrl::GetCaret() const
{
- if (m_pEdit)
- return m_pEdit->GetCaret();
+ if (m_pEdit)
+ return m_pEdit->GetCaret();
- return -1;
+ return -1;
}
void CPWL_EditCtrl::SetCaret(int32_t nPos)
{
- if (m_pEdit)
- m_pEdit->SetCaret(nPos);
+ if (m_pEdit)
+ m_pEdit->SetCaret(nPos);
}
int32_t CPWL_EditCtrl::GetTotalWords() const
{
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
+ if (m_pEdit)
+ return m_pEdit->GetTotalWords();
- return 0;
+ return 0;
}
void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point)
{
- if (m_pEdit)
- m_pEdit->SetScrollPos(point);
+ if (m_pEdit)
+ m_pEdit->SetScrollPos(point);
}
CPDF_Point CPWL_EditCtrl::GetScrollPos() const
{
- if (m_pEdit)
- return m_pEdit->GetScrollPos();
+ if (m_pEdit)
+ return m_pEdit->GetScrollPos();
- return CPDF_Point(0.0f, 0.0f);
+ return CPDF_Point(0.0f, 0.0f);
}
CPDF_Font * CPWL_EditCtrl::GetCaretFont() const
{
- int32_t nFontIndex = 0;
-
- if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
- {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word))
- {
- nFontIndex = word.nFontIndex;
- }
- else if (HasFlag(PES_RICH))
- {
- if (pIterator->GetSection(section))
- {
- nFontIndex = section.WordProps.nFontIndex;
- }
- }
- }
-
- if (IFX_Edit_FontMap * pFontMap = GetFontMap())
- return pFontMap->GetPDFFont(nFontIndex);
- else
- return NULL;
+ int32_t nFontIndex = 0;
+
+ if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
+ {
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Section section;
+ if (pIterator->GetWord(word))
+ {
+ nFontIndex = word.nFontIndex;
+ }
+ else if (HasFlag(PES_RICH))
+ {
+ if (pIterator->GetSection(section))
+ {
+ nFontIndex = section.WordProps.nFontIndex;
+ }
+ }
+ }
+
+ if (IFX_Edit_FontMap* pFontMap = GetFontMap())
+ return pFontMap->GetPDFFont(nFontIndex);
+
+ return NULL;
}
FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const
{
- FX_FLOAT fFontSize = GetFontSize();
-
- if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
- {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word))
- {
- fFontSize = word.fFontSize;
- }
- else if (HasFlag(PES_RICH))
- {
- if (pIterator->GetSection(section))
- {
- fFontSize = section.WordProps.fFontSize;
- }
- }
- }
-
- return fFontSize;
+ FX_FLOAT fFontSize = GetFontSize();
+
+ if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
+ {
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Section section;
+ if (pIterator->GetWord(word))
+ {
+ fFontSize = word.fFontSize;
+ }
+ else if (HasFlag(PES_RICH))
+ {
+ if (pIterator->GetSection(section))
+ {
+ fFontSize = section.WordProps.fFontSize;
+ }
+ }
+ }
+
+ return fFontSize;
}
void CPWL_EditCtrl::SetText(const FX_WCHAR* csText)
{
- m_pEdit->SetText(csText);
+ m_pEdit->SetText(csText);
}
void CPWL_EditCtrl::CopyText()
@@ -584,79 +584,79 @@ void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow)
void CPWL_EditCtrl::InsertText(const FX_WCHAR* csText)
{
- if (!IsReadOnly())
- m_pEdit->InsertText(csText);
+ if (!IsReadOnly())
+ m_pEdit->InsertText(csText);
}
void CPWL_EditCtrl::InsertWord(FX_WORD word, int32_t nCharset)
{
- if (!IsReadOnly())
- m_pEdit->InsertWord(word, nCharset);
+ if (!IsReadOnly())
+ m_pEdit->InsertWord(word, nCharset);
}
void CPWL_EditCtrl::InsertReturn()
{
- if (!IsReadOnly())
- m_pEdit->InsertReturn();
+ if (!IsReadOnly())
+ m_pEdit->InsertReturn();
}
void CPWL_EditCtrl::Delete()
{
- if (!IsReadOnly())
- m_pEdit->Delete();
+ if (!IsReadOnly())
+ m_pEdit->Delete();
}
void CPWL_EditCtrl::Backspace()
{
- if (!IsReadOnly())
- m_pEdit->Backspace();
+ if (!IsReadOnly())
+ m_pEdit->Backspace();
}
-FX_BOOL CPWL_EditCtrl::CanUndo() const
+FX_BOOL CPWL_EditCtrl::CanUndo() const
{
- return !IsReadOnly() && m_pEdit->CanUndo();
+ return !IsReadOnly() && m_pEdit->CanUndo();
}
-FX_BOOL CPWL_EditCtrl::CanRedo() const
+FX_BOOL CPWL_EditCtrl::CanRedo() const
{
- return !IsReadOnly() && m_pEdit->CanRedo();
+ return !IsReadOnly() && m_pEdit->CanRedo();
}
void CPWL_EditCtrl::Redo()
{
- if (CanRedo())
- m_pEdit->Redo();
+ if (CanRedo())
+ m_pEdit->Redo();
}
void CPWL_EditCtrl::Undo()
{
- if (CanUndo())
- m_pEdit->Undo();
+ if (CanUndo())
+ m_pEdit->Undo();
}
void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax,
- FX_FLOAT fContentMin, FX_FLOAT fContentMax,
- FX_FLOAT fSmallStep, FX_FLOAT fBigStep)
+ FX_FLOAT fContentMin, FX_FLOAT fContentMax,
+ FX_FLOAT fSmallStep, FX_FLOAT fBigStep)
{
- PWL_SCROLL_INFO Info;
+ PWL_SCROLL_INFO Info;
- Info.fPlateWidth = fPlateMax - fPlateMin;
- Info.fContentMin = fContentMin;
- Info.fContentMax = fContentMax;
- Info.fSmallStep = fSmallStep;
- Info.fBigStep = fBigStep;
+ Info.fPlateWidth = fPlateMax - fPlateMin;
+ Info.fContentMin = fContentMin;
+ Info.fContentMax = fContentMax;
+ Info.fSmallStep = fSmallStep;
+ Info.fBigStep = fBigStep;
- OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info);
+ OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info);
- if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)
- || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin))
- {
- ShowVScrollBar(FALSE);
- }
- else
- {
- ShowVScrollBar(TRUE);
- }
+ if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)
+ || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin))
+ {
+ ShowVScrollBar(FALSE);
+ }
+ else
+ {
+ ShowVScrollBar(TRUE);
+ }
}
void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy)
@@ -666,12 +666,12 @@ void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy)
void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot, const CPVT_WordPlace& place)
{
- PWL_CARET_INFO cInfo;
- cInfo.bVisible = bVisible;
- cInfo.ptHead = ptHead;
- cInfo.ptFoot = ptFoot;
+ PWL_CARET_INFO cInfo;
+ cInfo.bVisible = bVisible;
+ cInfo.ptHead = ptHead;
+ cInfo.ptFoot = ptFoot;
- OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL);
+ OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL);
}
void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps)
@@ -680,13 +680,13 @@ void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_Wo
void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent)
{
- if (IsValid())
- {
- if (m_pEditNotify)
- {
- m_pEditNotify->OnContentChange(rcContent);
- }
- }
+ if (IsValid())
+ {
+ if (m_pEditNotify)
+ {
+ m_pEditNotify->OnContentChange(rcContent);
+ }
+ }
}
void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect)
@@ -701,22 +701,22 @@ int32_t CPWL_EditCtrl::GetCharSet() const
void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, int32_t & nStartChar, int32_t & nEndChar) const
{
- nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.left, rect.top)));
- nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.right, rect.bottom)));
+ nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.left, rect.top)));
+ nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.right, rect.bottom)));
}
CFX_WideString CPWL_EditCtrl::GetText(int32_t & nStartChar, int32_t & nEndChar) const
{
- CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar);
- CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
- return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
+ CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar);
+ CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
+ return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
}
-void CPWL_EditCtrl::SetReadyToInput()
+void CPWL_EditCtrl::SetReadyToInput()
{
- if (m_bMouseDown)
- {
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
+ if (m_bMouseDown)
+ {
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
+ }
}
diff --git a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
index 84b8c94363..50b321dfac 100644
--- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
@@ -8,15 +8,15 @@
#include "../../include/pdfwindow/PWL_Wnd.h"
#include "../../include/pdfwindow/PWL_FontMap.h"
-#define DEFAULT_FONT_NAME "Helvetica"
+#define DEFAULT_FONT_NAME "Helvetica"
/* ------------------------------ CPWL_FontMap ------------------------------ */
CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) :
- m_pPDFDoc(NULL),
- m_pSystemHandler(pSystemHandler)
+ m_pPDFDoc(NULL),
+ m_pSystemHandler(pSystemHandler)
{
- ASSERT(m_pSystemHandler != NULL);
+ ASSERT(m_pSystemHandler != NULL);
}
CPWL_FontMap::~CPWL_FontMap()
@@ -29,177 +29,167 @@ CPWL_FontMap::~CPWL_FontMap()
void CPWL_FontMap::SetSystemHandler(IFX_SystemHandler* pSystemHandler)
{
- m_pSystemHandler = pSystemHandler;
+ m_pSystemHandler = pSystemHandler;
}
CPDF_Document* CPWL_FontMap::GetDocument()
{
- if (!m_pPDFDoc)
- {
- if (CPDF_ModuleMgr::Get())
- {
- m_pPDFDoc = new CPDF_Document;
- m_pPDFDoc->CreateNewDoc();
- }
- }
+ if (!m_pPDFDoc)
+ {
+ if (CPDF_ModuleMgr::Get())
+ {
+ m_pPDFDoc = new CPDF_Document;
+ m_pPDFDoc->CreateNewDoc();
+ }
+ }
- return m_pPDFDoc;
+ return m_pPDFDoc;
}
CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex)
{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- return pData->pFont;
- }
- }
+ if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
+ {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
+ {
+ return pData->pFont;
+ }
+ }
- return NULL;
+ return NULL;
}
CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex)
{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- return pData->sFontName;
- }
- }
+ if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
+ {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
+ {
+ return pData->sFontName;
+ }
+ }
- return "";
+ return "";
}
FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word)
{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (m_aData.GetAt(nFontIndex))
- {
- return CharCodeFromUnicode(nFontIndex, word) >= 0;
- }
- }
+ if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
+ {
+ if (m_aData.GetAt(nFontIndex))
+ {
+ return CharCodeFromUnicode(nFontIndex, word) >= 0;
+ }
+ }
- return FALSE;
+ return FALSE;
}
int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t nFontIndex)
{
- if (nFontIndex > 0)
- {
- if (KnowWord(nFontIndex, word))
- return nFontIndex;
- }
- else
- {
- if (const CPWL_FontMap_Data* pData = GetFontMapData(0))
- {
- if (nCharset == DEFAULT_CHARSET ||
- pData->nCharset == SYMBOL_CHARSET ||
- nCharset == pData->nCharset)
- {
- if (KnowWord(0, word))
- {
- return 0;
- }
- }
- }
- }
-
- int32_t nNewFontIndex = -1;
-
- nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
- if (nNewFontIndex >= 0)
- {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
-
- nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
- if (nNewFontIndex >= 0)
- {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
-
- return -1;
+ if (nFontIndex > 0)
+ {
+ if (KnowWord(nFontIndex, word))
+ return nFontIndex;
+ }
+ else
+ {
+ if (const CPWL_FontMap_Data* pData = GetFontMapData(0))
+ {
+ if (nCharset == DEFAULT_CHARSET ||
+ pData->nCharset == SYMBOL_CHARSET ||
+ nCharset == pData->nCharset)
+ {
+ if (KnowWord(0, word))
+ return 0;
+ }
+ }
+ }
+
+ int32_t nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
+ if (nNewFontIndex >= 0)
+ {
+ if (KnowWord(nNewFontIndex, word))
+ return nNewFontIndex;
+ }
+ nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
+ if (nNewFontIndex >= 0)
+ {
+ if (KnowWord(nNewFontIndex, word))
+ return nNewFontIndex;
+ }
+ return -1;
}
int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word)
{
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- if (pData->pFont)
- {
- if (pData->pFont->IsUnicodeCompatible())
- {
- int nCharCode = pData->pFont->CharCodeFromUnicode(word);
- pData->pFont->GlyphFromCharCode(nCharCode);
- return nCharCode;
- }
- else
- {
- if (word < 0xFF)
- return word;
- }
- }
- }
-
- return -1;
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
+ {
+ if (pData->pFont)
+ {
+ if (pData->pFont->IsUnicodeCompatible())
+ {
+ int nCharCode = pData->pFont->CharCodeFromUnicode(word);
+ pData->pFont->GlyphFromCharCode(nCharCode);
+ return nCharCode;
+ }
+ if (word < 0xFF)
+ return word;
+ }
+ }
+ return -1;
}
CFX_ByteString CPWL_FontMap::GetNativeFontName(int32_t nCharset)
{
- //searching native font is slow, so we must save time
- for (int32_t i=0,sz=m_aNativeFont.GetSize(); i<sz; i++)
- {
- if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i))
- {
- if (pData->nCharset == nCharset)
- return pData->sFontName;
- }
- }
+ //searching native font is slow, so we must save time
+ for (int32_t i=0,sz=m_aNativeFont.GetSize(); i<sz; i++)
+ {
+ if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i))
+ {
+ if (pData->nCharset == nCharset)
+ return pData->sFontName;
+ }
+ }
- CFX_ByteString sNew = GetNativeFont(nCharset);
+ CFX_ByteString sNew = GetNativeFont(nCharset);
- if (!sNew.IsEmpty())
- {
- CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native;
- pNewData->nCharset = nCharset;
- pNewData->sFontName = sNew;
+ if (!sNew.IsEmpty())
+ {
+ CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native;
+ pNewData->nCharset = nCharset;
+ pNewData->sFontName = sNew;
- m_aNativeFont.Add(pNewData);
- }
+ m_aNativeFont.Add(pNewData);
+ }
- return sNew;
+ return sNew;
}
void CPWL_FontMap::Empty()
{
- {
- for (int32_t i=0, sz=m_aData.GetSize(); i<sz; i++)
- delete m_aData.GetAt(i);
+ {
+ for (int32_t i=0, sz=m_aData.GetSize(); i<sz; i++)
+ delete m_aData.GetAt(i);
- m_aData.RemoveAll();
- }
- {
- for (int32_t i=0, sz=m_aNativeFont.GetSize(); i<sz; i++)
- delete m_aNativeFont.GetAt(i);
+ m_aData.RemoveAll();
+ }
+ {
+ for (int32_t i=0, sz=m_aNativeFont.GetSize(); i<sz; i++)
+ delete m_aNativeFont.GetAt(i);
- m_aNativeFont.RemoveAll();
- }
+ m_aNativeFont.RemoveAll();
+ }
}
void CPWL_FontMap::Initial(const FX_CHAR* fontname)
{
- CFX_ByteString sFontName = fontname;
+ CFX_ByteString sFontName = fontname;
- if (sFontName.IsEmpty())
- sFontName = DEFAULT_FONT_NAME;
+ if (sFontName.IsEmpty())
+ sFontName = DEFAULT_FONT_NAME;
- GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
+ GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
}
@@ -212,122 +202,107 @@ Symbol, ZapfDingbats
*/
const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldOblique", "Courier-Oblique",
- "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Oblique",
- "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
- "Symbol", "ZapfDingbats"};
+ "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Oblique",
+ "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
+ "Symbol", "ZapfDingbats"};
-FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
+FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
{
- for (int32_t i=0; i<14; i++)
- {
- if (sFontName == g_sDEStandardFontName[i])
- return TRUE;
- }
+ for (int32_t i=0; i<14; i++)
+ {
+ if (sFontName == g_sDEStandardFontName[i])
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset)
{
- for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
- {
- if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset)
- {
- if (sFontName.IsEmpty() || pData->sFontName == sFontName)
- return i;
- }
- }
- }
+ for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
+ {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
+ {
+ if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset)
+ {
+ if (sFontName.IsEmpty() || pData->sFontName == sFontName)
+ return i;
+ }
+ }
+ }
- return -1;
+ return -1;
}
int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCharset, FX_BOOL bFind)
{
- int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
- if (nFontIndex >= 0) return nFontIndex;
+ int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
+ if (nFontIndex >= 0)
+ return nFontIndex;
-// nFontIndex = FindFont("", nCharset);
-// if (nFontIndex >= 0) return nFontIndex;
+ CFX_ByteString sAlias;
+ CPDF_Font* pFont = NULL;
+ if (bFind)
+ pFont = FindFontSameCharset(sAlias, nCharset);
- CFX_ByteString sAlias;
- CPDF_Font* pFont = NULL;
-
- if (bFind)
- pFont = FindFontSameCharset(sAlias, nCharset);
-
- if (!pFont)
- {
- CFX_ByteString sTemp = sFontName;
- pFont = AddFontToDocument(GetDocument(), sTemp, nCharset);
-
- /*
- if (FindFont(sAlias))
- {
- sAlias = EncodeFontAlias(sTemp, nCharset);
- }
- else
- */
- {
- sAlias = EncodeFontAlias(sTemp, nCharset);
- }
- }
-
- AddedFont(pFont, sAlias);
-
- return AddFontData(pFont, sAlias, nCharset);
+ if (!pFont)
+ {
+ CFX_ByteString sTemp = sFontName;
+ pFont = AddFontToDocument(GetDocument(), sTemp, nCharset);
+ sAlias = EncodeFontAlias(sTemp, nCharset);
+ }
+ AddedFont(pFont, sAlias);
+ return AddFontData(pFont, sAlias, nCharset);
}
int32_t CPWL_FontMap::GetPWLFontIndex(FX_WORD word, int32_t nCharset)
{
- int32_t nFind = -1;
+ int32_t nFind = -1;
- for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
- {
- if (pData->nCharset == nCharset)
- {
- nFind = i;
- break;
- }
- }
- }
+ for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
+ {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
+ {
+ if (pData->nCharset == nCharset)
+ {
+ nFind = i;
+ break;
+ }
+ }
+ }
- CPDF_Font* pNewFont = GetPDFFont(nFind);
+ CPDF_Font* pNewFont = GetPDFFont(nFind);
- if (!pNewFont) return -1;
+ if (!pNewFont) return -1;
- /*
- if (CPDF_Font* pFont = GetPDFFont(nFind))
- {
- PWLFont.AddWordToFontDict(pFontDict, word);
- }
- */
+ /*
+ if (CPDF_Font* pFont = GetPDFFont(nFind))
+ {
+ PWLFont.AddWordToFontDict(pFontDict, word);
+ }
+ */
- CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
- AddedFont(pNewFont, sAlias);
+ CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
+ AddedFont(pNewFont, sAlias);
- return AddFontData(pNewFont, sAlias, nCharset);
+ return AddFontData(pNewFont, sAlias, nCharset);
}
CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset)
{
- return NULL;
+ return NULL;
}
int32_t CPWL_FontMap::AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, int32_t nCharset)
{
- CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data;
- pNewData->pFont = pFont;
- pNewData->sFontName = sFontAlias;
- pNewData->nCharset = nCharset;
+ CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data;
+ pNewData->pFont = pFont;
+ pNewData->sFontName = sFontAlias;
+ pNewData->nCharset = nCharset;
- m_aData.Add(pNewData);
+ m_aData.Add(pNewData);
- return m_aData.GetSize() -1;
+ return m_aData.GetSize() -1;
}
void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias)
@@ -336,253 +311,250 @@ void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias)
CFX_ByteString CPWL_FontMap::GetFontName(int32_t nFontIndex)
{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- return pData->sFontName;
- }
- }
+ if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
+ {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
+ {
+ return pData->sFontName;
+ }
+ }
- return "";
+ return "";
}
CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset)
{
- CFX_ByteString sFontName;
-
- if (nCharset == DEFAULT_CHARSET)
- nCharset = GetNativeCharset();
- sFontName = GetDefaultFontByCharset(nCharset);
+ if (nCharset == DEFAULT_CHARSET)
+ nCharset = GetNativeCharset();
- if (m_pSystemHandler)
- {
- if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName))
- return sFontName;
+ CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset);
+ if (m_pSystemHandler)
+ {
+ if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName))
+ return sFontName;
- sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
- }
-
- return sFontName;
+ sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
+ }
+ return sFontName;
}
CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset)
{
- if (IsStandardFont(sFontName))
- return AddStandardFont(pDoc, sFontName);
- else
- return AddSystemFont(pDoc, sFontName, nCharset);
+ if (IsStandardFont(sFontName))
+ return AddStandardFont(pDoc, sFontName);
+
+ return AddSystemFont(pDoc, sFontName, nCharset);
}
CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName)
{
- if (!pDoc) return NULL;
+ if (!pDoc) return NULL;
- CPDF_Font* pFont = NULL;
+ CPDF_Font* pFont = NULL;
- if (sFontName == "ZapfDingbats")
- pFont = pDoc->AddStandardFont(sFontName, NULL);
- else
- {
- CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
- pFont = pDoc->AddStandardFont(sFontName, &fe);
- }
+ if (sFontName == "ZapfDingbats")
+ pFont = pDoc->AddStandardFont(sFontName, NULL);
+ else
+ {
+ CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
+ pFont = pDoc->AddStandardFont(sFontName, &fe);
+ }
- return pFont;
+ return pFont;
}
CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset)
{
- if (!pDoc) return NULL;
+ if (!pDoc) return NULL;
- if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset);
- if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset();
+ if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset);
+ if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset();
- if (m_pSystemHandler)
- return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, nCharset);
+ if (m_pSystemHandler)
+ return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, nCharset);
- return NULL;
+ return NULL;
}
CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName, int32_t nCharset)
{
- CFX_ByteString sPostfix;
- sPostfix.Format("_%02X", nCharset);
- return EncodeFontAlias(sFontName) + sPostfix;
+ CFX_ByteString sPostfix;
+ sPostfix.Format("_%02X", nCharset);
+ return EncodeFontAlias(sFontName) + sPostfix;
}
CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName)
{
- CFX_ByteString sRet = sFontName;
- sRet.Remove(' ');
- return sRet;
+ CFX_ByteString sRet = sFontName;
+ sRet.Remove(' ');
+ return sRet;
}
int32_t CPWL_FontMap::GetFontMapCount() const
{
- return m_aData.GetSize();
+ return m_aData.GetSize();
}
const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const
{
- if (nIndex >=0 && nIndex < m_aData.GetSize())
- {
- return m_aData.GetAt(nIndex);
- }
+ if (nIndex >=0 && nIndex < m_aData.GetSize())
+ {
+ return m_aData.GetAt(nIndex);
+ }
- return NULL;
+ return NULL;
}
int32_t CPWL_FontMap::GetNativeCharset()
{
- uint8_t nCharset = ANSI_CHARSET;
- int32_t iCodePage = FXSYS_GetACP();
- switch (iCodePage)
- {
- case 932://Japan
- nCharset = SHIFTJIS_CHARSET;
- break;
- case 936://Chinese (PRC, Singapore)
- nCharset = GB2312_CHARSET;
- break;
- case 950://Chinese (Taiwan; Hong Kong SAR, PRC)
- nCharset = GB2312_CHARSET;
- break;
- case 1252://Windows 3.1 Latin 1 (US, Western Europe)
- nCharset = ANSI_CHARSET;
- break;
- case 874://Thai
- nCharset = THAI_CHARSET;
- break;
- case 949://Korean
- nCharset = HANGUL_CHARSET;
- break;
- case 1200://Unicode (BMP of ISO 10646)
- nCharset = ANSI_CHARSET;
- break;
- case 1250://Windows 3.1 Eastern European
- nCharset = EASTEUROPE_CHARSET;
- break;
- case 1251://Windows 3.1 Cyrillic
- nCharset = RUSSIAN_CHARSET;
- break;
- case 1253://Windows 3.1 Greek
- nCharset = GREEK_CHARSET;
- break;
- case 1254://Windows 3.1 Turkish
- nCharset = TURKISH_CHARSET;
- break;
- case 1255://Hebrew
- nCharset = HEBREW_CHARSET;
- break;
- case 1256://Arabic
- nCharset = ARABIC_CHARSET;
- break;
- case 1257://Baltic
- nCharset = BALTIC_CHARSET;
- break;
- case 1258://Vietnamese
- nCharset = VIETNAMESE_CHARSET;
- break;
- case 1361://Korean(Johab)
- nCharset = JOHAB_CHARSET;
- break;
- }
- return nCharset;
+ uint8_t nCharset = ANSI_CHARSET;
+ int32_t iCodePage = FXSYS_GetACP();
+ switch (iCodePage)
+ {
+ case 932://Japan
+ nCharset = SHIFTJIS_CHARSET;
+ break;
+ case 936://Chinese (PRC, Singapore)
+ nCharset = GB2312_CHARSET;
+ break;
+ case 950://Chinese (Taiwan; Hong Kong SAR, PRC)
+ nCharset = GB2312_CHARSET;
+ break;
+ case 1252://Windows 3.1 Latin 1 (US, Western Europe)
+ nCharset = ANSI_CHARSET;
+ break;
+ case 874://Thai
+ nCharset = THAI_CHARSET;
+ break;
+ case 949://Korean
+ nCharset = HANGUL_CHARSET;
+ break;
+ case 1200://Unicode (BMP of ISO 10646)
+ nCharset = ANSI_CHARSET;
+ break;
+ case 1250://Windows 3.1 Eastern European
+ nCharset = EASTEUROPE_CHARSET;
+ break;
+ case 1251://Windows 3.1 Cyrillic
+ nCharset = RUSSIAN_CHARSET;
+ break;
+ case 1253://Windows 3.1 Greek
+ nCharset = GREEK_CHARSET;
+ break;
+ case 1254://Windows 3.1 Turkish
+ nCharset = TURKISH_CHARSET;
+ break;
+ case 1255://Hebrew
+ nCharset = HEBREW_CHARSET;
+ break;
+ case 1256://Arabic
+ nCharset = ARABIC_CHARSET;
+ break;
+ case 1257://Baltic
+ nCharset = BALTIC_CHARSET;
+ break;
+ case 1258://Vietnamese
+ nCharset = VIETNAMESE_CHARSET;
+ break;
+ case 1361://Korean(Johab)
+ nCharset = JOHAB_CHARSET;
+ break;
+ }
+ return nCharset;
}
const CPWL_FontMap::CharsetFontMap CPWL_FontMap::defaultTTFMap[] = {
- { ANSI_CHARSET, "Helvetica" },
- { GB2312_CHARSET, "SimSun" },
- { CHINESEBIG5_CHARSET, "MingLiU" },
- { SHIFTJIS_CHARSET, "MS Gothic" },
- { HANGUL_CHARSET, "Batang" },
- { RUSSIAN_CHARSET, "Arial" },
+ { ANSI_CHARSET, "Helvetica" },
+ { GB2312_CHARSET, "SimSun" },
+ { CHINESEBIG5_CHARSET, "MingLiU" },
+ { SHIFTJIS_CHARSET, "MS Gothic" },
+ { HANGUL_CHARSET, "Batang" },
+ { RUSSIAN_CHARSET, "Arial" },
#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- { EASTEUROPE_CHARSET, "Arial" },
+ { EASTEUROPE_CHARSET, "Arial" },
#else
- { EASTEUROPE_CHARSET, "Tahoma" },
+ { EASTEUROPE_CHARSET, "Tahoma" },
#endif
- { ARABIC_CHARSET, "Arial" },
- { -1, NULL }
+ { ARABIC_CHARSET, "Arial" },
+ { -1, NULL }
};
CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset)
{
- int i = 0;
- while (defaultTTFMap[i].charset != -1) {
- if (nCharset == defaultTTFMap[i].charset)
- return defaultTTFMap[i].fontname;
+ int i = 0;
+ while (defaultTTFMap[i].charset != -1) {
+ if (nCharset == defaultTTFMap[i].charset)
+ return defaultTTFMap[i].fontname;
++i;
- }
- return "";
+ }
+ return "";
}
int32_t CPWL_FontMap::CharSetFromUnicode(FX_WORD word, int32_t nOldCharset)
{
- if(m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
- return m_pSystemHandler->GetCharSet();
- //to avoid CJK Font to show ASCII
- if (word < 0x7F) return ANSI_CHARSET;
- //follow the old charset
- if (nOldCharset != DEFAULT_CHARSET) return nOldCharset;
+ if(m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
+ return m_pSystemHandler->GetCharSet();
+ //to avoid CJK Font to show ASCII
+ if (word < 0x7F) return ANSI_CHARSET;
+ //follow the old charset
+ if (nOldCharset != DEFAULT_CHARSET) return nOldCharset;
- //find new charset
- if ((word >= 0x4E00 && word <= 0x9FA5) ||
- (word >= 0xE7C7 && word <= 0xE7F3) ||
- (word >= 0x3000 && word <= 0x303F) ||
- (word >= 0x2000 && word <= 0x206F))
- {
- return GB2312_CHARSET;
- }
+ //find new charset
+ if ((word >= 0x4E00 && word <= 0x9FA5) ||
+ (word >= 0xE7C7 && word <= 0xE7F3) ||
+ (word >= 0x3000 && word <= 0x303F) ||
+ (word >= 0x2000 && word <= 0x206F))
+ {
+ return GB2312_CHARSET;
+ }
- if (((word >= 0x3040) && (word <= 0x309F)) ||
- ((word >= 0x30A0) && (word <= 0x30FF)) ||
- ((word >= 0x31F0) && (word <= 0x31FF)) ||
- ((word >= 0xFF00) && (word <= 0xFFEF)) )
- {
- return SHIFTJIS_CHARSET;
- }
+ if (((word >= 0x3040) && (word <= 0x309F)) ||
+ ((word >= 0x30A0) && (word <= 0x30FF)) ||
+ ((word >= 0x31F0) && (word <= 0x31FF)) ||
+ ((word >= 0xFF00) && (word <= 0xFFEF)) )
+ {
+ return SHIFTJIS_CHARSET;
+ }
- if (((word >= 0xAC00) && (word <= 0xD7AF)) ||
- ((word >= 0x1100) && (word <= 0x11FF)) ||
- ((word >= 0x3130) && (word <= 0x318F)))
- {
- return HANGUL_CHARSET;
- }
+ if (((word >= 0xAC00) && (word <= 0xD7AF)) ||
+ ((word >= 0x1100) && (word <= 0x11FF)) ||
+ ((word >= 0x3130) && (word <= 0x318F)))
+ {
+ return HANGUL_CHARSET;
+ }
- if (word >= 0x0E00 && word <= 0x0E7F)
- return THAI_CHARSET;
+ if (word >= 0x0E00 && word <= 0x0E7F)
+ return THAI_CHARSET;
- if ((word >= 0x0370 && word <= 0x03FF) ||
- (word >= 0x1F00 && word <= 0x1FFF))
- return GREEK_CHARSET;
+ if ((word >= 0x0370 && word <= 0x03FF) ||
+ (word >= 0x1F00 && word <= 0x1FFF))
+ return GREEK_CHARSET;
- if ((word >= 0x0600 && word <= 0x06FF) ||
- (word >= 0xFB50 && word <= 0xFEFC))
- return ARABIC_CHARSET;
+ if ((word >= 0x0600 && word <= 0x06FF) ||
+ (word >= 0xFB50 && word <= 0xFEFC))
+ return ARABIC_CHARSET;
- if (word >= 0x0590 && word <= 0x05FF)
- return HEBREW_CHARSET;
+ if (word >= 0x0590 && word <= 0x05FF)
+ return HEBREW_CHARSET;
- if (word >= 0x0400 && word <= 0x04FF)
- return RUSSIAN_CHARSET;
+ if (word >= 0x0400 && word <= 0x04FF)
+ return RUSSIAN_CHARSET;
- if (word >= 0x0100 && word <= 0x024F)
- return EASTEUROPE_CHARSET;
+ if (word >= 0x0100 && word <= 0x024F)
+ return EASTEUROPE_CHARSET;
- if (word >= 0x1E00 && word <= 0x1EFF)
- return VIETNAMESE_CHARSET;
+ if (word >= 0x1E00 && word <= 0x1EFF)
+ return VIETNAMESE_CHARSET;
- return ANSI_CHARSET;
+ return ANSI_CHARSET;
}
/* ------------------------ CPWL_DocFontMap ------------------------ */
CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, CPDF_Document* pAttachedDoc)
- : CPWL_FontMap(pSystemHandler),
- m_pAttachedDoc(pAttachedDoc)
+ : CPWL_FontMap(pSystemHandler),
+ m_pAttachedDoc(pAttachedDoc)
{
}
@@ -592,5 +564,5 @@ CPWL_DocFontMap::~CPWL_DocFontMap()
CPDF_Document* CPWL_DocFontMap::GetDocument()
{
- return m_pAttachedDoc;
+ return m_pAttachedDoc;
}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
index cf6e6a1709..433b3c6846 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
@@ -21,17 +21,17 @@ static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap()
}
CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) :
- m_nTimerID(0),
- m_pAttached(pAttached),
- m_pSystemHandler(pSystemHandler)
+ m_nTimerID(0),
+ m_pAttached(pAttached),
+ m_pSystemHandler(pSystemHandler)
{
- ASSERT(m_pAttached != NULL);
- ASSERT(m_pSystemHandler != NULL);
+ ASSERT(m_pAttached != NULL);
+ ASSERT(m_pSystemHandler != NULL);
}
CPWL_Timer::~CPWL_Timer()
{
- KillPWLTimer();
+ KillPWLTimer();
}
int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse)
@@ -78,17 +78,17 @@ CPWL_TimerHandler::~CPWL_TimerHandler()
void CPWL_TimerHandler::BeginTimer(int32_t nElapse)
{
- if (!m_pTimer)
- m_pTimer = new CPWL_Timer(this, GetSystemHandler());
+ if (!m_pTimer)
+ m_pTimer = new CPWL_Timer(this, GetSystemHandler());
- if (m_pTimer)
- m_pTimer->SetPWLTimer(nElapse);
+ if (m_pTimer)
+ m_pTimer->SetPWLTimer(nElapse);
}
void CPWL_TimerHandler::EndTimer()
{
- if (m_pTimer)
- m_pTimer->KillPWLTimer();
+ if (m_pTimer)
+ m_pTimer->KillPWLTimer();
}
void CPWL_TimerHandler::TimerProc()
@@ -99,181 +99,181 @@ void CPWL_TimerHandler::TimerProc()
class CPWL_MsgControl
{
- friend class CPWL_Wnd;
+ friend class CPWL_Wnd;
public:
- CPWL_MsgControl(CPWL_Wnd * pWnd)
- {
-// PWL_TRACE("new CPWL_MsgControl\n");
- m_pCreatedWnd = pWnd;
- Default();
- }
-
- ~CPWL_MsgControl()
- {
-// PWL_TRACE("~CPWL_MsgControl\n");
- Default();
- }
-
- void Default()
- {
- m_aMousePath.RemoveAll();
- m_aKeyboardPath.RemoveAll();
- m_pMainMouseWnd = NULL;
- m_pMainKeyboardWnd = NULL;
- }
-
- FX_BOOL IsWndCreated(const CPWL_Wnd * pWnd) const
- {
- return m_pCreatedWnd == pWnd;
- }
-
- FX_BOOL IsMainCaptureMouse(const CPWL_Wnd * pWnd) const
- {
- return pWnd == m_pMainMouseWnd;
- }
-
- FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const
- {
- if (pWnd)
- for( int32_t i=0,sz=m_aMousePath.GetSize(); i<sz; i++)
- if (m_aMousePath.GetAt(i) == pWnd)
- return TRUE;
-
- return FALSE;
- }
-
- FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd * pWnd) const
- {
- return pWnd == m_pMainKeyboardWnd;
- }
-
-
- FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
- {
- if (pWnd)
- for( int32_t i=0,sz=m_aKeyboardPath.GetSize(); i<sz; i++)
- if (m_aKeyboardPath.GetAt(i) == pWnd)
- return TRUE;
-
- return FALSE;
- }
-
- void SetFocus(CPWL_Wnd * pWnd)
- {
- m_aKeyboardPath.RemoveAll();
-
- if (pWnd)
- {
- m_pMainKeyboardWnd = pWnd;
-
- CPWL_Wnd * pParent = pWnd;
- while (pParent)
- {
- m_aKeyboardPath.Add(pParent);
- pParent = pParent->GetParentWindow();
- }
-
- pWnd->OnSetFocus();
- }
- }
-
- void KillFocus()
- {
- if (m_aKeyboardPath.GetSize() > 0)
- if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
- pWnd->OnKillFocus();
-
- m_pMainKeyboardWnd = NULL;
- m_aKeyboardPath.RemoveAll();
- }
-
- void SetCapture(CPWL_Wnd * pWnd)
- {
- m_aMousePath.RemoveAll();
-
- if (pWnd)
- {
- m_pMainMouseWnd = pWnd;
-
- CPWL_Wnd * pParent = pWnd;
- while (pParent)
- {
- m_aMousePath.Add(pParent);
- pParent = pParent->GetParentWindow();
- }
- }
- }
-
- void ReleaseCapture()
- {
- m_pMainMouseWnd = NULL;
- m_aMousePath.RemoveAll();
- }
+ CPWL_MsgControl(CPWL_Wnd * pWnd)
+ {
+// PWL_TRACE("new CPWL_MsgControl\n");
+ m_pCreatedWnd = pWnd;
+ Default();
+ }
+
+ ~CPWL_MsgControl()
+ {
+// PWL_TRACE("~CPWL_MsgControl\n");
+ Default();
+ }
+
+ void Default()
+ {
+ m_aMousePath.RemoveAll();
+ m_aKeyboardPath.RemoveAll();
+ m_pMainMouseWnd = NULL;
+ m_pMainKeyboardWnd = NULL;
+ }
+
+ FX_BOOL IsWndCreated(const CPWL_Wnd * pWnd) const
+ {
+ return m_pCreatedWnd == pWnd;
+ }
+
+ FX_BOOL IsMainCaptureMouse(const CPWL_Wnd * pWnd) const
+ {
+ return pWnd == m_pMainMouseWnd;
+ }
+
+ FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const
+ {
+ if (pWnd)
+ for( int32_t i=0,sz=m_aMousePath.GetSize(); i<sz; i++)
+ if (m_aMousePath.GetAt(i) == pWnd)
+ return TRUE;
+
+ return FALSE;
+ }
+
+ FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd * pWnd) const
+ {
+ return pWnd == m_pMainKeyboardWnd;
+ }
+
+
+ FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
+ {
+ if (pWnd)
+ for( int32_t i=0,sz=m_aKeyboardPath.GetSize(); i<sz; i++)
+ if (m_aKeyboardPath.GetAt(i) == pWnd)
+ return TRUE;
+
+ return FALSE;
+ }
+
+ void SetFocus(CPWL_Wnd * pWnd)
+ {
+ m_aKeyboardPath.RemoveAll();
+
+ if (pWnd)
+ {
+ m_pMainKeyboardWnd = pWnd;
+
+ CPWL_Wnd * pParent = pWnd;
+ while (pParent)
+ {
+ m_aKeyboardPath.Add(pParent);
+ pParent = pParent->GetParentWindow();
+ }
+
+ pWnd->OnSetFocus();
+ }
+ }
+
+ void KillFocus()
+ {
+ if (m_aKeyboardPath.GetSize() > 0)
+ if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
+ pWnd->OnKillFocus();
+
+ m_pMainKeyboardWnd = NULL;
+ m_aKeyboardPath.RemoveAll();
+ }
+
+ void SetCapture(CPWL_Wnd * pWnd)
+ {
+ m_aMousePath.RemoveAll();
+
+ if (pWnd)
+ {
+ m_pMainMouseWnd = pWnd;
+
+ CPWL_Wnd * pParent = pWnd;
+ while (pParent)
+ {
+ m_aMousePath.Add(pParent);
+ pParent = pParent->GetParentWindow();
+ }
+ }
+ }
+
+ void ReleaseCapture()
+ {
+ m_pMainMouseWnd = NULL;
+ m_aMousePath.RemoveAll();
+ }
private:
- CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
- CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
- CPWL_Wnd* m_pCreatedWnd;
- CPWL_Wnd* m_pMainMouseWnd;
- CPWL_Wnd* m_pMainKeyboardWnd;
+ CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
+ CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
+ CPWL_Wnd* m_pCreatedWnd;
+ CPWL_Wnd* m_pMainMouseWnd;
+ CPWL_Wnd* m_pMainKeyboardWnd;
};
/* --------------------------- CPWL_Wnd ---------------------------- */
CPWL_Wnd::CPWL_Wnd() :
- m_pVScrollBar(NULL),
- m_rcWindow(),
- m_rcClip(),
- m_bCreated(FALSE),
- m_bVisible(FALSE),
- m_bNotifying(FALSE),
- m_bEnabled(TRUE)
+ m_pVScrollBar(NULL),
+ m_rcWindow(),
+ m_rcClip(),
+ m_bCreated(FALSE),
+ m_bVisible(FALSE),
+ m_bNotifying(FALSE),
+ m_bEnabled(TRUE)
{
}
CPWL_Wnd::~CPWL_Wnd()
{
- ASSERT(m_bCreated == FALSE);
+ ASSERT(m_bCreated == FALSE);
}
CFX_ByteString CPWL_Wnd::GetClassName() const
{
- return "CPWL_Wnd";
+ return "CPWL_Wnd";
}
void CPWL_Wnd::Create(const PWL_CREATEPARAM & cp)
{
- if (!IsValid())
- {
- m_sPrivateParam = cp;
+ if (!IsValid())
+ {
+ m_sPrivateParam = cp;
- OnCreate(m_sPrivateParam);
+ OnCreate(m_sPrivateParam);
- m_sPrivateParam.rcRectWnd.Normalize();
- m_rcWindow = m_sPrivateParam.rcRectWnd;
- m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f);
+ m_sPrivateParam.rcRectWnd.Normalize();
+ m_rcWindow = m_sPrivateParam.rcRectWnd;
+ m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f);
- CreateMsgControl();
+ CreateMsgControl();
- if (m_sPrivateParam.pParentWnd)
- m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
+ if (m_sPrivateParam.pParentWnd)
+ m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
- PWL_CREATEPARAM ccp = m_sPrivateParam;
+ PWL_CREATEPARAM ccp = m_sPrivateParam;
- ccp.dwFlags &= 0xFFFF0000L; //remove sub styles
- ccp.mtChild = CPDF_Matrix(1,0,0,1,0,0);
+ ccp.dwFlags &= 0xFFFF0000L; //remove sub styles
+ ccp.mtChild = CPDF_Matrix(1,0,0,1,0,0);
- CreateScrollBar(ccp);
- CreateChildWnd(ccp);
+ CreateScrollBar(ccp);
+ CreateChildWnd(ccp);
- m_bVisible = HasFlag(PWS_VISIBLE);
+ m_bVisible = HasFlag(PWS_VISIBLE);
- OnCreated();
+ OnCreated();
- RePosChildWnd();
- m_bCreated = TRUE;
- }
+ RePosChildWnd();
+ m_bCreated = TRUE;
+ }
}
void CPWL_Wnd::OnCreate(PWL_CREATEPARAM & cp)
@@ -290,86 +290,86 @@ void CPWL_Wnd::OnDestroy()
void CPWL_Wnd::Destroy()
{
- KillFocus();
+ KillFocus();
- OnDestroy();
+ OnDestroy();
- if (m_bCreated)
- {
- for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
- {
- if (CPWL_Wnd * pChild = m_aChildren[i])
- {
- pChild->Destroy();
- delete pChild;
- pChild = NULL;
- }
- }
+ if (m_bCreated)
+ {
+ for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren[i])
+ {
+ pChild->Destroy();
+ delete pChild;
+ pChild = NULL;
+ }
+ }
- if (m_sPrivateParam.pParentWnd)
- m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
- m_bCreated = FALSE;
- }
+ if (m_sPrivateParam.pParentWnd)
+ m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
+ m_bCreated = FALSE;
+ }
- DestroyMsgControl();
+ DestroyMsgControl();
- FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
- m_aChildren.RemoveAll();
- m_pVScrollBar = NULL;
+ FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
+ m_aChildren.RemoveAll();
+ m_pVScrollBar = NULL;
}
void CPWL_Wnd::Move(const CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh)
{
- if (IsValid())
- {
- CPDF_Rect rcOld = GetWindowRect();
+ if (IsValid())
+ {
+ CPDF_Rect rcOld = GetWindowRect();
- m_rcWindow = rcNew;
- m_rcWindow.Normalize();
+ m_rcWindow = rcNew;
+ m_rcWindow.Normalize();
- if (rcOld.left != rcNew.left || rcOld.right != rcNew.right ||
- rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom)
- {
- if (bReset)
- {
- RePosChildWnd();
- }
+ if (rcOld.left != rcNew.left || rcOld.right != rcNew.right ||
+ rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom)
+ {
+ if (bReset)
+ {
+ RePosChildWnd();
+ }
- }
- if (bRefresh)
- {
- InvalidateRectMove(rcOld,rcNew);
- }
+ }
+ if (bRefresh)
+ {
+ InvalidateRectMove(rcOld,rcNew);
+ }
- m_sPrivateParam.rcRectWnd = m_rcWindow;
- }
+ m_sPrivateParam.rcRectWnd = m_rcWindow;
+ }
}
void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rcNew)
{
- CPDF_Rect rcUnion = rcOld;
- rcUnion.Union(rcNew);
+ CPDF_Rect rcUnion = rcOld;
+ rcUnion.Union(rcNew);
- InvalidateRect(&rcUnion);
+ InvalidateRect(&rcUnion);
}
void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream)
{
- if (IsValid())
- {
- CFX_ByteTextBuf sTextBuf;
- GetAppearanceStream(sTextBuf);
- sAppStream += sTextBuf.GetByteString();
- }
+ if (IsValid())
+ {
+ CFX_ByteTextBuf sTextBuf;
+ GetAppearanceStream(sTextBuf);
+ sAppStream += sTextBuf.GetByteString();
+ }
}
void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf & sAppStream)
{
- if (IsValid() && IsVisible())
- {
- GetThisAppearanceStream(sAppStream);
- GetChildAppearanceStream(sAppStream);
- }
+ if (IsValid() && IsVisible())
+ {
+ GetThisAppearanceStream(sAppStream);
+ GetChildAppearanceStream(sAppStream);
+ }
}
//if don't set,Get default apperance stream
@@ -399,158 +399,158 @@ void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream)
{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- pChild->GetAppearanceStream(sAppStream);
- }
- }
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
+ {
+ pChild->GetAppearanceStream(sAppStream);
+ }
+ }
}
void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
{
- if (IsValid() && IsVisible())
- {
- DrawThisAppearance(pDevice,pUser2Device);
- DrawChildAppearance(pDevice,pUser2Device);
- }
+ if (IsValid() && IsVisible())
+ {
+ DrawThisAppearance(pDevice,pUser2Device);
+ DrawChildAppearance(pDevice,pUser2Device);
+ }
}
void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
{
- CPDF_Rect rectWnd = GetWindowRect();
- if (!rectWnd.IsEmpty())
- {
- if (HasFlag(PWS_BACKGROUND))
- {
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
- CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient, GetBackgroundColor(), GetTransparency());
- }
-
- if (HasFlag(PWS_BORDER))
- CPWL_Utils::DrawBorder(pDevice,
- pUser2Device,
- rectWnd,
- (FX_FLOAT)GetBorderWidth(),
- GetBorderColor(),
- GetBorderLeftTopColor(GetBorderStyle()),
- GetBorderRightBottomColor(GetBorderStyle()),
- GetBorderStyle(),
- GetBorderDash(),
- GetTransparency());
- }
+ CPDF_Rect rectWnd = GetWindowRect();
+ if (!rectWnd.IsEmpty())
+ {
+ if (HasFlag(PWS_BACKGROUND))
+ {
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+ CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient, GetBackgroundColor(), GetTransparency());
+ }
+
+ if (HasFlag(PWS_BORDER))
+ CPWL_Utils::DrawBorder(pDevice,
+ pUser2Device,
+ rectWnd,
+ (FX_FLOAT)GetBorderWidth(),
+ GetBorderColor(),
+ GetBorderLeftTopColor(GetBorderStyle()),
+ GetBorderRightBottomColor(GetBorderStyle()),
+ GetBorderStyle(),
+ GetBorderDash(),
+ GetTransparency());
+ }
}
void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- CPDF_Matrix mt = pChild->GetChildMatrix();
- if (mt.IsIdentity())
- {
- pChild->DrawAppearance(pDevice,pUser2Device);
- }
- else
- {
- mt.Concat(*pUser2Device);
- pChild->DrawAppearance(pDevice,&mt);
- }
- }
- }
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
+ {
+ CPDF_Matrix mt = pChild->GetChildMatrix();
+ if (mt.IsIdentity())
+ {
+ pChild->DrawAppearance(pDevice,pUser2Device);
+ }
+ else
+ {
+ mt.Concat(*pUser2Device);
+ pChild->DrawAppearance(pDevice,&mt);
+ }
+ }
+ }
}
void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect)
{
- if (IsValid())
- {
- CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
-
- if (!HasFlag(PWS_NOREFRESHCLIP))
- {
- CPDF_Rect rcClip = GetClipRect();
- if (!rcClip.IsEmpty())
- {
- rcRefresh.Intersect(rcClip);
- }
- }
-
- FX_RECT rcWin = PWLtoWnd(rcRefresh);
- rcWin.left -= PWL_INVALIDATE_INFLATE;
- rcWin.top -= PWL_INVALIDATE_INFLATE;
- rcWin.right += PWL_INVALIDATE_INFLATE;
- rcWin.bottom += PWL_INVALIDATE_INFLATE;
-
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- {
- if (FX_HWND hWnd = GetAttachedHWnd())
- {
- pSH->InvalidateRect(hWnd, rcWin);
- }
- }
- }
+ if (IsValid())
+ {
+ CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
+
+ if (!HasFlag(PWS_NOREFRESHCLIP))
+ {
+ CPDF_Rect rcClip = GetClipRect();
+ if (!rcClip.IsEmpty())
+ {
+ rcRefresh.Intersect(rcClip);
+ }
+ }
+
+ FX_RECT rcWin = PWLtoWnd(rcRefresh);
+ rcWin.left -= PWL_INVALIDATE_INFLATE;
+ rcWin.top -= PWL_INVALIDATE_INFLATE;
+ rcWin.right += PWL_INVALIDATE_INFLATE;
+ rcWin.bottom += PWL_INVALIDATE_INFLATE;
+
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ {
+ if (FX_HWND hWnd = GetAttachedHWnd())
+ {
+ pSH->InvalidateRect(hWnd, rcWin);
+ }
+ }
+ }
}
#define PWL_IMPLEMENT_KEY_METHOD(key_method_name)\
FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag)\
{\
- if (IsValid() && IsVisible() && IsEnabled())\
- {\
- if (IsWndCaptureKeyboard(this))\
- {\
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
- {\
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
- {\
- if (IsWndCaptureKeyboard(pChild))\
- {\
- return pChild->key_method_name(nChar,nFlag);\
- }\
- }\
- }\
- }\
- }\
- return FALSE;\
+ if (IsValid() && IsVisible() && IsEnabled())\
+ {\
+ if (IsWndCaptureKeyboard(this))\
+ {\
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
+ {\
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
+ {\
+ if (IsWndCaptureKeyboard(pChild))\
+ {\
+ return pChild->key_method_name(nChar,nFlag);\
+ }\
+ }\
+ }\
+ }\
+ }\
+ return FALSE;\
}
#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)\
FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point & point, FX_DWORD nFlag)\
{\
- if (IsValid() && IsVisible() && IsEnabled())\
- {\
- if (IsWndCaptureMouse(this))\
- {\
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
- {\
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
- {\
- if (IsWndCaptureMouse(pChild))\
- {\
- return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
- }\
- }\
- }\
- SetCursor();\
- }\
- else\
- {\
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
- {\
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
- {\
- if (pChild->WndHitTest(pChild->ParentToChild(point)))\
- {\
- return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
- }\
- }\
- }\
- if (WndHitTest(point))\
- SetCursor();\
- }\
- }\
- return FALSE;\
+ if (IsValid() && IsVisible() && IsEnabled())\
+ {\
+ if (IsWndCaptureMouse(this))\
+ {\
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
+ {\
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
+ {\
+ if (IsWndCaptureMouse(pChild))\
+ {\
+ return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
+ }\
+ }\
+ }\
+ SetCursor();\
+ }\
+ else\
+ {\
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
+ {\
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
+ {\
+ if (pChild->WndHitTest(pChild->ParentToChild(point)))\
+ {\
+ return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
+ }\
+ }\
+ }\
+ if (WndHitTest(point))\
+ SetCursor();\
+ }\
+ }\
+ return FALSE;\
}
PWL_IMPLEMENT_KEY_METHOD(OnKeyDown)
@@ -567,300 +567,294 @@ PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown)
PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
-FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (IsValid() && IsVisible() && IsEnabled())
- {
- SetCursor();
- if (IsWndCaptureKeyboard(this))
- {
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- if (IsWndCaptureKeyboard(pChild))
- {
- return pChild->OnMouseWheel(zDelta,pChild->ParentToChild(point), nFlag);
- }
- }
- }
- }
- }
- return FALSE;
+FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
+{
+ if (IsValid() && IsVisible() && IsEnabled())
+ {
+ SetCursor();
+ if (IsWndCaptureKeyboard(this))
+ {
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
+ {
+ if (IsWndCaptureKeyboard(pChild))
+ {
+ return pChild->OnMouseWheel(zDelta,pChild->ParentToChild(point), nFlag);
+ }
+ }
+ }
+ }
+ }
+ return FALSE;
}
void CPWL_Wnd::AddChild(CPWL_Wnd * pWnd)
{
- m_aChildren.Add(pWnd);
+ m_aChildren.Add(pWnd);
}
void CPWL_Wnd::RemoveChild(CPWL_Wnd * pWnd)
{
- for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- if (pChild == pWnd)
- {
- m_aChildren.RemoveAt(i);
- break;
- }
- }
- }
+ for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
+ {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ {
+ if (pChild == pWnd)
+ {
+ m_aChildren.RemoveAt(i);
+ break;
+ }
+ }
+ }
}
void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
{
- switch (msg)
- {
- case PNM_ADDCHILD:
- AddChild(pWnd);
- break;
- case PNM_REMOVECHILD:
- RemoveChild(pWnd);
- break;
- default:
- break;
- }
+ switch (msg)
+ {
+ case PNM_ADDCHILD:
+ AddChild(pWnd);
+ break;
+ case PNM_REMOVECHILD:
+ RemoveChild(pWnd);
+ break;
+ default:
+ break;
+ }
}
FX_BOOL CPWL_Wnd::IsValid() const
{
- return m_bCreated;
+ return m_bCreated;
}
PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const
{
- return m_sPrivateParam;
+ return m_sPrivateParam;
}
CPWL_Wnd* CPWL_Wnd::GetParentWindow() const
{
- return m_sPrivateParam.pParentWnd;
+ return m_sPrivateParam.pParentWnd;
}
CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const
{
- return m_sPrivateParam.rcRectWnd;
+ return m_sPrivateParam.rcRectWnd;
}
CPDF_Rect CPWL_Wnd::GetWindowRect() const
{
- return m_rcWindow;
+ return m_rcWindow;
}
CPDF_Rect CPWL_Wnd::GetClientRect() const
{
- CPDF_Rect rcWindow = GetWindowRect();
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
-
- if (CPWL_ScrollBar * pVSB = GetVScrollBar())
- rcClient.right -= pVSB->GetScrollBarWidth();
+ CPDF_Rect rcWindow = GetWindowRect();
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+ if (CPWL_ScrollBar* pVSB = GetVScrollBar())
+ rcClient.right -= pVSB->GetScrollBarWidth();
- rcClient.Normalize();
-
- if (rcWindow.Contains(rcClient))
- return rcClient;
- else
- return CPDF_Rect();
+ rcClient.Normalize();
+ return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect();
}
CPDF_Point CPWL_Wnd::GetCenterPoint() const
{
- CPDF_Rect rcClient = GetClientRect();
-
- return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
+ CPDF_Rect rcClient = GetClientRect();
+ return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
+ (rcClient.top + rcClient.bottom) * 0.5f);
}
CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const
{
- return CPWL_Utils::GetCenterSquare(GetClientRect());
+ return CPWL_Utils::GetCenterSquare(GetClientRect());
}
CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const
{
- return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f));
+ return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f));
}
FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const
{
- return (m_sPrivateParam.dwFlags & dwFlags) != 0;
+ return (m_sPrivateParam.dwFlags & dwFlags) != 0;
}
void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags)
{
- m_sPrivateParam.dwFlags &= ~dwFlags;
+ m_sPrivateParam.dwFlags &= ~dwFlags;
}
void CPWL_Wnd::AddFlag(FX_DWORD dwFlags)
{
- m_sPrivateParam.dwFlags |= dwFlags;
+ m_sPrivateParam.dwFlags |= dwFlags;
}
CPWL_Color CPWL_Wnd::GetBackgroundColor() const
{
- return m_sPrivateParam.sBackgroundColor;
+ return m_sPrivateParam.sBackgroundColor;
}
void CPWL_Wnd::SetBackgroundColor(const CPWL_Color & color)
{
- m_sPrivateParam.sBackgroundColor = color;
+ m_sPrivateParam.sBackgroundColor = color;
}
void CPWL_Wnd::SetTextColor(const CPWL_Color & color)
{
- m_sPrivateParam.sTextColor = color;
+ m_sPrivateParam.sTextColor = color;
}
void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color & color)
{
- m_sPrivateParam.sTextStrokeColor = color;
+ m_sPrivateParam.sTextStrokeColor = color;
}
CPWL_Color CPWL_Wnd::GetTextColor() const
{
- return m_sPrivateParam.sTextColor;
+ return m_sPrivateParam.sTextColor;
}
CPWL_Color CPWL_Wnd::GetTextStrokeColor() const
{
- return m_sPrivateParam.sTextStrokeColor;
+ return m_sPrivateParam.sTextStrokeColor;
}
int32_t CPWL_Wnd::GetBorderStyle() const
{
- return m_sPrivateParam.nBorderStyle;
+ return m_sPrivateParam.nBorderStyle;
}
void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle)
{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.nBorderStyle = nBorderStyle;
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.nBorderStyle = nBorderStyle;
}
int32_t CPWL_Wnd::GetBorderWidth() const
{
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.dwBorderWidth;
+ if (HasFlag(PWS_BORDER))
+ return m_sPrivateParam.dwBorderWidth;
- return 0;
+ return 0;
}
int32_t CPWL_Wnd::GetInnerBorderWidth() const
{
- /*
- switch (GetBorderStyle())
- {
- case PBS_BEVELED:
- case PBS_INSET:
- return GetBorderWidth() / 2;
- }
- */
- return 0;
+ /*
+ switch (GetBorderStyle())
+ {
+ case PBS_BEVELED:
+ case PBS_INSET:
+ return GetBorderWidth() / 2;
+ }
+ */
+ return 0;
}
void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth)
{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.dwBorderWidth = nBorderWidth;
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.dwBorderWidth = nBorderWidth;
}
CPWL_Color CPWL_Wnd::GetBorderColor() const
{
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.sBorderColor;
+ if (HasFlag(PWS_BORDER))
+ return m_sPrivateParam.sBorderColor;
- return CPWL_Color();
+ return CPWL_Color();
}
void CPWL_Wnd::SetBorderColor(const CPWL_Color & color)
{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.sBorderColor = color;
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.sBorderColor = color;
}
CPWL_Dash CPWL_Wnd::GetBorderDash() const
{
- return m_sPrivateParam.sDash;
+ return m_sPrivateParam.sDash;
}
void* CPWL_Wnd::GetAttachedData() const
{
- return m_sPrivateParam.pAttachedData;
+ return m_sPrivateParam.pAttachedData;
}
void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash)
{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.sDash = sDash;
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.sDash = sDash;
}
CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const
{
- if (HasFlag(PWS_VSCROLL))
- return m_pVScrollBar;
+ if (HasFlag(PWS_VSCROLL))
+ return m_pVScrollBar;
- return NULL;
+ return NULL;
}
void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM & cp)
{
- CreateVScrollBar(cp);
+ CreateVScrollBar(cp);
}
void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM & cp)
{
- if (!m_pVScrollBar && HasFlag(PWS_VSCROLL))
- {
- PWL_CREATEPARAM scp = cp;
+ if (!m_pVScrollBar && HasFlag(PWS_VSCROLL))
+ {
+ PWL_CREATEPARAM scp = cp;
- //flags
- scp.dwFlags = PWS_CHILD| PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
+ //flags
+ scp.dwFlags = PWS_CHILD| PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
- scp.pParentWnd = this;
- scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
- scp.eCursorType = FXCT_ARROW;
- scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY;
+ scp.pParentWnd = this;
+ scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
+ scp.eCursorType = FXCT_ARROW;
+ scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY;
- if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL)))
- m_pVScrollBar->Create(scp);
- }
+ if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL)))
+ m_pVScrollBar->Create(scp);
+ }
}
void CPWL_Wnd::SetCapture()
{
- if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
- pMsgCtrl->SetCapture(this);
+ if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
+ pMsgCtrl->SetCapture(this);
}
void CPWL_Wnd::ReleaseCapture()
{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->ReleaseCapture();
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ pChild->ReleaseCapture();
- if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
- pMsgCtrl->ReleaseCapture();
+ if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
+ pMsgCtrl->ReleaseCapture();
}
void CPWL_Wnd::SetFocus()
{
- if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
- {
- if (!pMsgCtrl->IsMainCaptureKeyboard(this))
- pMsgCtrl->KillFocus();
- pMsgCtrl->SetFocus(this);
- }
+ if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
+ {
+ if (!pMsgCtrl->IsMainCaptureKeyboard(this))
+ pMsgCtrl->KillFocus();
+ pMsgCtrl->SetFocus(this);
+ }
}
void CPWL_Wnd::KillFocus()
{
- if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
- {
- if (pMsgCtrl->IsWndCaptureKeyboard(this))
- pMsgCtrl->KillFocus();
- }
+ if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
+ {
+ if (pMsgCtrl->IsWndCaptureKeyboard(this))
+ pMsgCtrl->KillFocus();
+ }
}
void CPWL_Wnd::OnSetFocus()
@@ -871,73 +865,73 @@ void CPWL_Wnd::OnKillFocus()
{
}
-FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const
+FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const
{
- return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y);
+ return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y);
}
FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & point) const
{
- return IsValid() && IsVisible() && GetClientRect().Contains(point.x,point.y);
+ return IsValid() && IsVisible() && GetClientRect().Contains(point.x,point.y);
}
-const CPWL_Wnd * CPWL_Wnd::GetRootWnd() const
+const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const
{
- if (m_sPrivateParam.pParentWnd)
- return m_sPrivateParam.pParentWnd->GetRootWnd();
- else
- return this;
+ if (m_sPrivateParam.pParentWnd)
+ return m_sPrivateParam.pParentWnd->GetRootWnd();
+
+ return this;
}
void CPWL_Wnd::SetVisible(FX_BOOL bVisible)
{
- if (IsValid())
- {
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->SetVisible(bVisible);
- }
- }
-
- if (bVisible != m_bVisible)
- {
- m_bVisible = bVisible;
- RePosChildWnd();
- InvalidateRect();
- }
- }
+ if (IsValid())
+ {
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ {
+ pChild->SetVisible(bVisible);
+ }
+ }
+
+ if (bVisible != m_bVisible)
+ {
+ m_bVisible = bVisible;
+ RePosChildWnd();
+ InvalidateRect();
+ }
+ }
}
void CPWL_Wnd::SetClipRect(const CPDF_Rect & rect)
{
- m_rcClip = rect;
- m_rcClip.Normalize();
+ m_rcClip = rect;
+ m_rcClip.Normalize();
}
CPDF_Rect CPWL_Wnd::GetClipRect() const
{
- return m_rcClip;
+ return m_rcClip;
}
-FX_BOOL CPWL_Wnd::IsReadOnly() const
+FX_BOOL CPWL_Wnd::IsReadOnly() const
{
- return HasFlag(PWS_READONLY);
+ return HasFlag(PWS_READONLY);
}
void CPWL_Wnd::RePosChildWnd()
{
- CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+ CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
- CPWL_ScrollBar * pVSB = GetVScrollBar();
+ CPWL_ScrollBar * pVSB = GetVScrollBar();
- CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH,
- rcContent.bottom,
- rcContent.right-1.0f,
- rcContent.top);
+ CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH,
+ rcContent.bottom,
+ rcContent.right-1.0f,
+ rcContent.top);
- if (pVSB) pVSB->Move(rcVScroll,TRUE,FALSE);
+ if (pVSB) pVSB->Move(rcVScroll,TRUE,FALSE);
}
void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM & cp)
@@ -946,317 +940,307 @@ void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM & cp)
void CPWL_Wnd::SetCursor()
{
- if (IsValid())
- {
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- {
- int32_t nCursorType = GetCreationParam().eCursorType;
- pSH->SetCursor(nCursorType);
- }
- }
+ if (IsValid())
+ {
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ {
+ int32_t nCursorType = GetCreationParam().eCursorType;
+ pSH->SetCursor(nCursorType);
+ }
+ }
}
void CPWL_Wnd::CreateMsgControl()
{
- if (!m_sPrivateParam.pMsgControl)
- m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
+ if (!m_sPrivateParam.pMsgControl)
+ m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
}
void CPWL_Wnd::DestroyMsgControl()
{
- if (CPWL_MsgControl* pMsgControl = GetMsgControl())
- if (pMsgControl->IsWndCreated(this))
- delete pMsgControl;
+ if (CPWL_MsgControl* pMsgControl = GetMsgControl())
+ if (pMsgControl->IsWndCreated(this))
+ delete pMsgControl;
}
CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const
{
- return m_sPrivateParam.pMsgControl;
+ return m_sPrivateParam.pMsgControl;
}
FX_BOOL CPWL_Wnd::IsCaptureMouse() const
{
- return IsWndCaptureMouse(this);
+ return IsWndCaptureMouse(this);
}
FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd * pWnd) const
{
- if (CPWL_MsgControl * pCtrl = GetMsgControl())
- return pCtrl->IsWndCaptureMouse(pWnd);
+ if (CPWL_MsgControl * pCtrl = GetMsgControl())
+ return pCtrl->IsWndCaptureMouse(pWnd);
- return FALSE;
+ return FALSE;
}
FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
{
- if (CPWL_MsgControl * pCtrl = GetMsgControl())
- return pCtrl->IsWndCaptureKeyboard(pWnd);
+ if (CPWL_MsgControl * pCtrl = GetMsgControl())
+ return pCtrl->IsWndCaptureKeyboard(pWnd);
- return FALSE;
+ return FALSE;
}
FX_BOOL CPWL_Wnd::IsFocused() const
{
- if (CPWL_MsgControl * pCtrl = GetMsgControl())
- return pCtrl->IsMainCaptureKeyboard(this);
+ if (CPWL_MsgControl * pCtrl = GetMsgControl())
+ return pCtrl->IsMainCaptureKeyboard(this);
- return FALSE;
+ return FALSE;
}
CPDF_Rect CPWL_Wnd::GetFocusRect() const
{
- return CPWL_Utils::InflateRect(GetWindowRect(),1);
+ return CPWL_Utils::InflateRect(GetWindowRect(),1);
}
FX_FLOAT CPWL_Wnd::GetFontSize() const
{
- return m_sPrivateParam.fFontSize;
+ return m_sPrivateParam.fFontSize;
}
void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize)
{
- m_sPrivateParam.fFontSize = fFontSize;
+ m_sPrivateParam.fFontSize = fFontSize;
}
IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const
{
- return m_sPrivateParam.pSystemHandler;
+ return m_sPrivateParam.pSystemHandler;
}
IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const
{
- return m_sPrivateParam.pFocusHandler;
+ return m_sPrivateParam.pFocusHandler;
}
IPWL_Provider* CPWL_Wnd::GetProvider() const
{
- return m_sPrivateParam.pProvider;
+ return m_sPrivateParam.pProvider;
}
IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const
{
- return m_sPrivateParam.pFontMap;
+ return m_sPrivateParam.pFontMap;
}
CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const
{
- CPWL_Color color;
-
- switch (nBorderStyle)
- {
- case PBS_SOLID:
- break;
- case PBS_DASH:
- break;
- case PBS_BEVELED:
- color = CPWL_Color(COLORTYPE_GRAY,1);
- break;
- case PBS_INSET:
- color = CPWL_Color(COLORTYPE_GRAY,0.5f);
- break;
- case PBS_UNDERLINED:
- break;
- }
+ CPWL_Color color;
+
+ switch (nBorderStyle)
+ {
+ case PBS_SOLID:
+ break;
+ case PBS_DASH:
+ break;
+ case PBS_BEVELED:
+ color = CPWL_Color(COLORTYPE_GRAY,1);
+ break;
+ case PBS_INSET:
+ color = CPWL_Color(COLORTYPE_GRAY,0.5f);
+ break;
+ case PBS_UNDERLINED:
+ break;
+ }
- return color;
+ return color;
}
CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const
{
- CPWL_Color color;
-
- switch (nBorderStyle)
- {
- case PBS_SOLID:
- break;
- case PBS_DASH:
- break;
- case PBS_BEVELED:
- color = CPWL_Utils::DevideColor(GetBackgroundColor(),2);
- break;
- case PBS_INSET:
- color = CPWL_Color(COLORTYPE_GRAY,0.75f);
- break;
- case PBS_UNDERLINED:
- break;
- }
+ CPWL_Color color;
+
+ switch (nBorderStyle)
+ {
+ case PBS_SOLID:
+ break;
+ case PBS_DASH:
+ break;
+ case PBS_BEVELED:
+ color = CPWL_Utils::DevideColor(GetBackgroundColor(),2);
+ break;
+ case PBS_INSET:
+ color = CPWL_Color(COLORTYPE_GRAY,0.75f);
+ break;
+ case PBS_UNDERLINED:
+ break;
+ }
- return color;
+ return color;
}
/* ----------------------------------------------------------------- */
int32_t CPWL_Wnd::GetTransparency()
{
- return m_sPrivateParam.nTransparency;
+ return m_sPrivateParam.nTransparency;
}
void CPWL_Wnd::SetTransparency(int32_t nTransparency)
{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->SetTransparency(nTransparency);
- }
- }
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ {
+ pChild->SetTransparency(nTransparency);
+ }
+ }
- m_sPrivateParam.nTransparency = nTransparency;
+ m_sPrivateParam.nTransparency = nTransparency;
}
-CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const
+CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const
{
- CPDF_Matrix mt = GetChildToRoot();
+ CPDF_Matrix mt = GetChildToRoot();
- if (IPWL_Provider* pProvider = GetProvider())
- {
- mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
- return mt;
- }
+ if (IPWL_Provider* pProvider = GetProvider())
+ {
+ mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
+ return mt;
+ }
- return mt;
+ return mt;
}
void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const
{
- CPDF_Matrix mt = GetWindowMatrix();
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- x = (int32_t)(pt.x+0.5);
- y = (int32_t)(pt.y+0.5);
+ CPDF_Matrix mt = GetWindowMatrix();
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
+ x = (int32_t)(pt.x+0.5);
+ y = (int32_t)(pt.y+0.5);
}
FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const
{
- CPDF_Rect rcTemp = rect;
- CPDF_Matrix mt = GetWindowMatrix();
- mt.TransformRect(rcTemp);
- return FX_RECT((int32_t)(rcTemp.left+0.5), (int32_t)(rcTemp.bottom+0.5), (int32_t)(rcTemp.right+0.5), (int32_t)(rcTemp.top+0.5));
+ CPDF_Rect rcTemp = rect;
+ CPDF_Matrix mt = GetWindowMatrix();
+ mt.TransformRect(rcTemp);
+ return FX_RECT((int32_t)(rcTemp.left+0.5), (int32_t)(rcTemp.bottom+0.5), (int32_t)(rcTemp.right+0.5), (int32_t)(rcTemp.top+0.5));
}
FX_HWND CPWL_Wnd::GetAttachedHWnd() const
{
- return m_sPrivateParam.hAttachedWnd;
+ return m_sPrivateParam.hAttachedWnd;
}
CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const
{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
- else
- {
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- return pt;
- }
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return point;
+
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
+ return pt;
}
CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const
{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return rect;
- else
- {
- CPDF_Rect rc = rect;
- mt.TransformRect(rc);
- return rc;
- }
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return rect;
+
+ CPDF_Rect rc = rect;
+ mt.TransformRect(rc);
+ return rc;
}
CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const
{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
- else
- {
- mt.SetReverse(mt);
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- return pt;
- }
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return point;
+
+ mt.SetReverse(mt);
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
+ return pt;
}
CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const
{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return rect;
- else
- {
- mt.SetReverse(mt);
- CPDF_Rect rc = rect;
- mt.TransformRect(rc);
- return rc;
- }
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return rect;
+
+ mt.SetReverse(mt);
+ CPDF_Rect rc = rect;
+ mt.TransformRect(rc);
+ return rc;
}
CPDF_Matrix CPWL_Wnd::GetChildToRoot() const
{
- CPDF_Matrix mt(1,0,0,1,0,0);
-
- if (HasFlag(PWS_CHILD))
- {
- const CPWL_Wnd* pParent = this;
- while (pParent)
- {
- mt.Concat(pParent->GetChildMatrix());
- pParent = pParent->GetParentWindow();
- }
- }
-
- return mt;
+ CPDF_Matrix mt(1, 0, 0, 1, 0, 0);
+ if (HasFlag(PWS_CHILD))
+ {
+ const CPWL_Wnd* pParent = this;
+ while (pParent)
+ {
+ mt.Concat(pParent->GetChildMatrix());
+ pParent = pParent->GetParentWindow();
+ }
+ }
+ return mt;
}
CPDF_Matrix CPWL_Wnd::GetChildMatrix() const
{
- if (HasFlag(PWS_CHILD))
- return m_sPrivateParam.mtChild;
+ if (HasFlag(PWS_CHILD))
+ return m_sPrivateParam.mtChild;
- return CPDF_Matrix(1,0,0,1,0,0);
+ return CPDF_Matrix(1,0,0,1,0,0);
}
void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt)
{
- m_sPrivateParam.mtChild = mt;
+ m_sPrivateParam.mtChild = mt;
}
-const CPWL_Wnd* CPWL_Wnd::GetFocused() const
+const CPWL_Wnd* CPWL_Wnd::GetFocused() const
{
- if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
- {
- return pMsgCtrl->m_pMainKeyboardWnd;
- }
+ if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
+ {
+ return pMsgCtrl->m_pMainKeyboardWnd;
+ }
- return NULL;
+ return NULL;
}
void CPWL_Wnd::EnableWindow(FX_BOOL bEnable)
{
- if (m_bEnabled != bEnable)
- {
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->EnableWindow(bEnable);
- }
- }
+ if (m_bEnabled != bEnable)
+ {
+ for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ {
+ pChild->EnableWindow(bEnable);
+ }
+ }
- m_bEnabled = bEnable;
+ m_bEnabled = bEnable;
- if (bEnable)
- OnEnabled();
- else
- OnDisabled();
- }
+ if (bEnable)
+ OnEnabled();
+ else
+ OnDisabled();
+ }
}
FX_BOOL CPWL_Wnd::IsEnabled()
{
- return m_bEnabled;
+ return m_bEnabled;
}
void CPWL_Wnd::OnEnabled()
@@ -1269,41 +1253,40 @@ void CPWL_Wnd::OnDisabled()
FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const
{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsCTRLKeyDown(nFlag);
- }
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
+ {
+ return pSystemHandler->IsCTRLKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const
+FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const
{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsSHIFTKeyDown(nFlag);
- }
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
+ {
+ return pSystemHandler->IsSHIFTKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const
+FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const
{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsALTKeyDown(nFlag);
- }
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
+ {
+ return pSystemHandler->IsALTKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const
+FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const
{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsINSERTKeyDown(nFlag);
- }
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
+ {
+ return pSystemHandler->IsINSERTKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-