code_device/hgdriver/hgdev/common_setting.cpp

562 lines
18 KiB
C++
Raw Normal View History

2022-05-03 03:56:07 +00:00
#include "common_setting.h"
#include "sane/sane_option_definitions.h"
#include "hg_log.h"
2023-01-19 07:43:59 +00:00
#define MAKE_ID_AND_STR(id) id, hg_log::lang_load(id)
2022-05-03 03:56:07 +00:00
static struct _fixed_option
{
2023-01-19 07:43:59 +00:00
int str_id;
2022-05-03 03:56:07 +00:00
std::string str;
int enum_val;
}
g_color_mode[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_YSMS_HB), COLOR_MODE_BLACK_WHITE },
{MAKE_ID_AND_STR(ID_OPTION_VALUE_YSMS_256JHD), COLOR_MODE_256_GRAY},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_YSMS_24WCS), COLOR_MODE_24_BITS},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_YSMS_YSZDSB), COLOR_MODE_AUTO_MATCH}
2022-05-03 03:56:07 +00:00
},
g_multi_out[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_DLSCLX_CS_HD_HB), MULTI_OUT_ALL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_DLSCLX_CS_HD), MULTI_COLOR_AND_GRAY},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_DLSCLX_CS_HB), MULTI_COLOR_AND_BW},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_DLSCLX_HD_HB), MULTI_GRAY_AND_BW}
2022-05-03 03:56:07 +00:00
},
g_rid_color[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_BCS), RID_COLOR_NONE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_CHS), RID_COLOR_RID_RED},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_CLS), RID_COLOR_RID_GREEN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_CHULANSE), RID_COLOR_RID_BLUE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_HSZQ), RID_COLOR_ENHANCE_RED},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_LSZQ), RID_COLOR_ENHANCE_GREEN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HDHHBTX_CSYZQ_LANSEZENGQIANG), RID_COLOR_ENHANCE_BLUE}
2022-05-03 03:56:07 +00:00
},
g_paper[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A3), PAPER_A3},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A4), PAPER_A4},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A5), PAPER_A5},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A6), PAPER_A6},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_B4), PAPER_B4},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_B5), PAPER_B5},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_B6), PAPER_B6},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_8K), PAPER_8K},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_16K), PAPER_16K},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_Letter), PAPER_LETTER},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A4HX), PAPER_A4_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A5HX), PAPER_A5_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_A6HX), PAPER_A6_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_B5HX), PAPER_B5_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_B6HX), PAPER_B6_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_16KHX), PAPER_16K_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_LetterHX), PAPER_LETTER_LATERAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_DoubleLetter), PAPER_DOUBLE_LETTER},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_LEGAL), PAPER_LEGAL},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_PPYSCC), PAPER_AUTO_MATCH},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_ZDSMCC), PAPER_MAX_SIZE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_ZDSMCCZDCQ), PAPER_MAX_SIZE_CLIP},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZZCC_SLSJ), PAPER_TRIGEMINY}
2022-05-03 03:56:07 +00:00
},
g_page[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMYM_DM), PAGE_SINGLE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMYM_SM), PAGE_DOUBLE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMYM_TGKBYTY), PAGE_OMIT_EMPTY},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMYM_TGKBYFPZ), PAGE_OMIT_EMPTY_RECEIPT},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMYM_DZ), PAGE_FOLIO}
2022-05-03 03:56:07 +00:00
},
g_sharpen[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_RHYMH_W), SHARPEN_NONE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_RHYMH_RH), SHARPEN_SHARPEN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_RHYMH_JYBRH), SHARPEN_SHARPEN_MORE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_RHYMH_MH), SHARPEN_HAZY},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_RHYMH_JYBMH), SHARPEN_HAZY_MORE}
2022-05-03 03:56:07 +00:00
},
g_fill_bkg[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_BJTCFS_TDBX), FILL_BKG_CONVEX_POLYGON},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_BJTCFS_ADBX), FILL_BKG_CONCAVE_POLYGON}
2022-05-03 03:56:07 +00:00
},
g_scan_mode[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMZS_LXSM), SCAN_MODE_CONTINUOUS},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SMZS_SMZDZS), SCAN_MODE_GIVEN_COUNT}
2022-05-03 03:56:07 +00:00
},
g_text_direction[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_WGFX_0), TEXT_DIRECTION_0},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_WGFX_90), TEXT_DIRECTION_90},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_WGFX_180), TEXT_DIRECTION_180},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_WGFX__90), TEXT_DIRECTION_270},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_WGFX_ZDWBFXSB), TEXT_DIRECTION_AUTO}
2022-05-03 03:56:07 +00:00
},
g_permeate_lv[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_JR), PERMAEATE_WEAKER},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_R), PERMAEATE_WEAK},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_YB), PERMAEATE_ORDINARY},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_Q), PERMAEATE_STRONG},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_JQ), PERMAEATE_STRONGER}
2022-05-09 07:02:00 +00:00
},
g_img_quality[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HZ_W), IMG_NONE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HZ_SDYX), IMG_SPEED},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_HZ_HZYX), IMG_QUALITY}
2022-08-08 10:15:51 +00:00
},
g_paper_strenght[]=
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZQD_R),PAPER_WEAK},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZQD_YB),PAPER_AVERAGE},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZQD_Q),PAPER_STRONG}
2022-08-08 10:15:51 +00:00
},
g_sleep_time[]=
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_BXM),SLEEP_TIME_0MIN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_WFZ),SLEEP_TIME_5MIN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_SFZ),SLEEP_TIME_10MIN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_BXS),SLEEP_TIME_30MIN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_YXS),SLEEP_TIME_60MIN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_LXS),SLEEP_TIME_120MIN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_XMSJ_SXS),SLEEP_TIME_240MIN},
},
g_fold_type[] =
{
2023-01-19 07:43:59 +00:00
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZYDZ),FOLD_TYPE_LEFT_RIGHT},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_SXDZ),FOLD_TYPE_UP_DOWN},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_ZDDZ),FOLD_TYPE_AUTO}
};
2022-05-03 03:56:07 +00:00
static struct paper_size
{
int paper;
SIZE size;
}g_paper_size[] =
{
{PAPER_A3, {297, 420}},
{PAPER_A4, {210, 297}},
{PAPER_A5, {148, 210}},
{PAPER_A6, {105, 148}},
{PAPER_B4, {257, 364}},
{PAPER_B5, {176, 250}}, // {PAPER_B5, {182, 257}},
{PAPER_B6, {125, 176}},
{PAPER_8K, {297, 420}},
{PAPER_16K, {210, 285}}, // {PAPER_16K, {185, 260}}
{PAPER_A4_LATERAL, {297, 210}},
{PAPER_A5_LATERAL, {210, 148}},
{PAPER_A6_LATERAL, {148, 105}},
{PAPER_B5_LATERAL, {250, 176}}, // {PAPER_B5, {182, 257}},
{PAPER_B6_LATERAL, {176, 125}}
};
2022-06-15 03:05:36 +00:00
// Custom 纸张的大小由用户定义.
// Letter Letter 纸216 毫米 × 279 毫米).
// Legal Legal 纸216 毫米 × 356 毫米).
// A4 A4 纸210 毫米 × 297 毫米).
// CSheet C 纸432 毫米 × 559 毫米).
// DSheet D 纸559 毫米 × 864 毫米).
// ESheet E 纸864 毫米 × 1118 毫米).
// LetterSmall Letter small 纸216 毫米 × 279 毫米).
// Tabloid Tabloid 纸279 毫米 × 432 毫米).
// Ledger Ledger 纸432 毫米 × 279 毫米).
// Statement Statement 纸140 毫米 × 216 毫米).
// Executive Executive 纸184 毫米 × 267 毫米).
// A3 A3 纸297 毫米 × 420 毫米).
// A4Small A4 small 纸210 毫米 × 297 毫米).
// A5 A5 纸148 毫米 × 210 毫米).
// B4 B4 纸250 × 353 毫米).
// B5 B5 纸176 毫米 × 250 毫米).
// Folio Folio 纸216 毫米 × 330 毫米).
// Quarto Quarto 纸215 毫米 × 275 毫米).
// Standard10x14 Standard 纸254 毫米 × 356 毫米).
// Standard11x17 Standard 纸279 毫米 × 432 毫米).
// Note Note 纸216 毫米 × 279 毫米).
// Number9Envelope #9 envelope98 毫米 × 225 毫米).
// Number10Envelope #10 envelope105 毫米 × 241 毫米).
// Number11Envelope #11 envelope114 毫米 × 263 毫米).
// Number12Envelope #12 envelope120 毫米 × 279 毫米).
// Number14Envelope #14 envelope127 毫米 × 292 毫米).
// DLEnvelope DL 信封110 毫米 × 220 毫米).
// C5Envelope C5 信封162 毫米 × 229 毫米).
// C3Envelope C3 信封324 毫米 × 458 毫米).
// C4Envelope C4 信封229 毫米 × 324 毫米).
// C6Envelope C6 信封114 毫米 × 162 毫米).
// C65Envelope C65 信封114 毫米 × 229 毫米).
// B4Envelope B4 信封250 × 353 毫米).
// B5Envelope B5 信封176 毫米 × 250 毫米).
// B6Envelope B6 信封176 毫米 × 125 毫米).
// ItalyEnvelope Italy envelope110 毫米 × 230 毫米).
// MonarchEnvelope Monarch envelope98 毫米 × 191 毫米).
// PersonalEnvelope 6 3 / 4 envelope92 毫米 × 165 毫米).
// USStandardFanfold US standard fanfold378 毫米 × 279 毫米).
// GermanStandardFanfold German standard fanfold216 毫米 × 305 毫米).
// GermanLegalFanfold German legal fanfold216 毫米 × 330 毫米).
// IsoB4 ISO B4250 毫米 × 353 毫米).
// JapanesePostcard Japanese postcard100 毫米 × 148 毫米).
// Standard9x11 Standard 纸229 毫米 × 279 毫米).
// Standard10x11 Standard 纸254 毫米 × 279 毫米).
// Standard15x11 Standard 纸381 毫米 × 279 毫米).
// InviteEnvelope 邀请函信封220 毫米 × 220 毫米).
// LetterExtra Letter extra 纸236 毫米 × 305 毫米).该值特定于 PostScript 驱动程序, 仅供 Linotronic 打印机使用以节省纸张.
// LegalExtra Legal extra 纸236 毫米 × 381 毫米).该值特定于 PostScript 驱动程序, 仅供 Linotronic 打印机使用以节省纸张.
// TabloidExtra Tabloid extra 纸297 毫米 × 457 毫米).该值特定于 PostScript 驱动程序, 仅供 Linotronic 打印机使用以节省纸张.
// A4Extra A4 extra 纸236 毫米 × 322 毫米).该值是针对 PostScript 驱动程序的, 仅供 Linotronic 打印机使用以节省纸张.
// LetterTransverse Letter transverse 纸210 毫米 × 279 毫米).
// A4Transverse A4 transverse 纸210 毫米 × 297 毫米).
// LetterExtraTransverse Letter extra transverse 纸236 毫米 × 305 毫米).
// APlus SuperA / SuperA / A4 纸227 毫米 × 356 毫米).
// BPlus SuperB / SuperB / A3 纸305 毫米 × 487 毫米).
// LetterPlus Letter plus 纸216 毫米 × 322 毫米).
// A4Plus A4 plus 纸210 毫米 × 330 毫米).
// A5Transverse A5 transverse 纸148 毫米 × 210 毫米).
// B5Transverse JIS B5 transverse 纸182 毫米 × 257 毫米).
// A3Extra A3 extra 纸322 毫米 × 445 毫米).
// A5Extra A5 extra 纸174 毫米 × 235 毫米).
// B5Extra ISO B5 extra 纸201 毫米 × 276 毫米).
// A2 A2 纸420 毫米 × 594 毫米).
// A3Transverse A3 transverse 纸297 毫米 × 420 毫米).
// A3ExtraTransverse A3 extra transverse 纸322 毫米 × 445 毫米).
2022-05-09 07:02:00 +00:00
2022-05-03 03:56:07 +00:00
static int match_best(struct _fixed_option* arr, size_t num, std::string& val, bool& exact)
{
exact = true;
for (size_t i = 0; i < num; ++i)
{
if (arr[i].str == val)
return arr[i].enum_val;
}
exact = false;
return -1;
}
static std::string get_str(struct _fixed_option* arr, int num, int enm, int default_v = 0)
{
if (enm >= 0 && enm < num)
return arr[enm].str;
else
return arr[default_v].str;
}
2023-01-19 07:43:59 +00:00
static void reload_string(struct _fixed_option* arr, int num)
{
for (int i = 0; i < num; ++i)
arr[i].str = hg_log::lang_load(arr[i].str_id);
}
2022-05-03 03:56:07 +00:00
2023-01-19 07:43:59 +00:00
#define RELOAD_STRING(arr) reload_string(arr, ARRAY_SIZE(arr))
2022-05-03 03:56:07 +00:00
#define INVOKE_MATCH(arr, val, yes) match_best(arr, ARRAY_SIZE(arr), val, yes)
#define INVOKE_STR(arr, val, def) get_str(arr, ARRAY_SIZE(arr), val, def)
#define SET_DEFAULT_ON_FAIL(map_array, ind, val, def) \
if(ind == -1) \
{ \
ind = def; \
val = INVOKE_STR(map_array, def, def); \
2022-05-03 03:56:07 +00:00
}
int match_best_color_mode(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_color_mode, val, yes);
SET_DEFAULT_ON_FAIL(g_color_mode, ind, val, COLOR_MODE_24_BITS);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_multi_out(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_multi_out, val, yes);
SET_DEFAULT_ON_FAIL(g_multi_out, ind, val, MULTI_OUT_ALL);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_rid_color(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_rid_color, val, yes);
SET_DEFAULT_ON_FAIL(g_rid_color, ind, val, RID_COLOR_NONE);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
SIZE paper_size(int paper)
{
for (size_t i = 0; i < ARRAY_SIZE(g_paper_size); ++i)
{
if (g_paper_size[i].paper == paper)
return g_paper_size[i].size;
}
//return SIZE{ 2338, 3307 };
return SIZE{ 297, 420 }; // A3
}
2022-05-03 03:56:07 +00:00
int match_best_paper(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_paper, val, yes);
SET_DEFAULT_ON_FAIL(g_paper, ind, val, PAPER_A4);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_page(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_page, val, yes);
SET_DEFAULT_ON_FAIL(g_page, ind, val, PAGE_DOUBLE);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_sharpen(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_sharpen, val, yes);
SET_DEFAULT_ON_FAIL(g_sharpen, ind, val, SHARPEN_NONE);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_fill_background(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_fill_bkg, val, yes);
SET_DEFAULT_ON_FAIL(g_fill_bkg, ind, val, FILL_BKG_CONVEX_POLYGON);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_scan_mode(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_scan_mode, val, yes);
SET_DEFAULT_ON_FAIL(g_scan_mode, ind, val, SCAN_MODE_CONTINUOUS);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_text_direction(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_text_direction, val, yes);
SET_DEFAULT_ON_FAIL(g_text_direction, ind, val, TEXT_DIRECTION_0);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
int match_best_permaeate_lv(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_permeate_lv, val, yes);
SET_DEFAULT_ON_FAIL(g_permeate_lv, ind, val, TEXT_DIRECTION_0);
2022-05-03 03:56:07 +00:00
if (exact)
*exact = yes;
return ind;
}
2022-05-09 07:02:00 +00:00
int match_best_img_quality(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_img_quality, val, yes);
SET_DEFAULT_ON_FAIL(g_img_quality, ind, val, IMG_SPEED);
2022-05-09 07:02:00 +00:00
if (exact)
*exact = yes;
return ind;
}
2022-08-08 10:15:51 +00:00
int match_best_paper_strength(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_paper_strenght, val, yes);
2022-05-03 03:56:07 +00:00
2022-08-08 10:15:51 +00:00
SET_DEFAULT_ON_FAIL(g_paper_strenght, ind, val, PAPER_WEAK);
if (exact)
*exact = yes;
return ind;
}
int match_best_sleep_time(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_sleep_time, val, yes);
SET_DEFAULT_ON_FAIL(g_sleep_time, ind, val, SLEEP_TIME_0MIN);
if (exact)
*exact = yes;
return ind;
}
int match_best_fold_type(std::string& val, bool* exact)
{
bool yes = true;
int ind = INVOKE_MATCH(g_fold_type, val, yes);
SET_DEFAULT_ON_FAIL(g_fold_type, ind, val, FOLD_TYPE_AUTO);
if (exact)
*exact = yes;
return ind;
}
2022-05-03 03:56:07 +00:00
std::string color_mode_string(int clr_mode)
{
return INVOKE_STR(g_color_mode, clr_mode, 0);
}
std::string multi_out_string(int multi_out)
{
return INVOKE_STR(g_multi_out, multi_out, 0);
}
std::string rid_color_string(int rid_color)
{
return INVOKE_STR(g_rid_color, rid_color, 0);
}
std::string paper_string(int paper)
{
return INVOKE_STR(g_paper, paper, 1);
}
bool is_lateral(int paper)
{
return paper == PAPER_A4_LATERAL
|| paper == PAPER_A5_LATERAL
|| paper == PAPER_A6_LATERAL
|| paper == PAPER_B5_LATERAL
|| paper == PAPER_B6_LATERAL
|| paper == PAPER_16K_LATERAL
|| paper == PAPER_LETTER_LATERAL;
}
std::string page_string(int page)
{
return INVOKE_STR(g_page, page, 1);
}
std::string sharpen_string(int sharpen)
{
return INVOKE_STR(g_sharpen, sharpen, 0);
}
std::string fill_background_string(int fill)
{
return INVOKE_STR(g_fill_bkg, fill, 0);
}
std::string scan_mode_string(int mode)
{
return INVOKE_STR(g_scan_mode, mode, 0);
}
std::string text_direction_string(int text_dir)
{
return INVOKE_STR(g_text_direction, text_dir, 0);
}
std::string is_permaeate_string(int permaeate_lv)
{
return INVOKE_STR(g_permeate_lv, permaeate_lv, 0);
}
2022-05-09 07:02:00 +00:00
std::string is_img_quality(int is_quakuty)
{
2022-08-02 03:14:58 +00:00
return INVOKE_STR(g_img_quality, is_quakuty + 1/*start from -1*/, 0);
}
2022-08-08 10:15:51 +00:00
std::string is_paper_strength(int strength)
{
return INVOKE_STR(g_paper_strenght, strength, 0);
}
std::string is_sleep_time(int sleep_time)
{
return INVOKE_STR(g_sleep_time, sleep_time, 0);
}
std::string is_fold_type(int fold_type)
{
return INVOKE_STR(g_fold_type, fold_type, 0);
2022-08-08 10:15:51 +00:00
}
int double_paper_flag_from_option_value(std::string& opt_val, bool* exact)
{
if (exact)
*exact = true;
if (opt_val == hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_SCTXBJXSM))
return DOUBLE_PAPER_CONTINUE | DOUBLE_PAPER_SAVE_IMG;
else if (opt_val == hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_SCTXBTZSM))
return DOUBLE_PAPER_SAVE_IMG;
else if (opt_val == hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_DQTXBJXSM))
return DOUBLE_PAPER_CONTINUE;
else
{
if (exact)
*exact = opt_val == hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_DQTXBTZSM);
}
return 0;
}
2022-08-08 10:15:51 +00:00
std::string double_paper_flag_to_option_value(int flag)
{
if (is_continue_when_double_paper(flag))
{
if (is_save_img_when_double_paper(flag))
return hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_SCTXBJXSM);
else
return hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_DQTXBJXSM);
}
else if (is_save_img_when_double_paper(flag))
return hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_SCTXBTZSM);
else
return hg_log::lang_load(ID_OPTION_VALUE_SZTPCL_DQTXBTZSM);
}
bool is_continue_when_double_paper(int flag)
{
return flag & DOUBLE_PAPER_CONTINUE;
}
bool is_save_img_when_double_paper(int flag)
{
return flag& DOUBLE_PAPER_SAVE_IMG;
}
2023-01-19 07:43:59 +00:00
void reload_setting_string_from_pak(int cp, void* param)
{
RELOAD_STRING(g_color_mode);
RELOAD_STRING(g_multi_out);
RELOAD_STRING(g_rid_color);
RELOAD_STRING(g_paper);
RELOAD_STRING(g_page);
RELOAD_STRING(g_sharpen);
RELOAD_STRING(g_fill_bkg);
RELOAD_STRING(g_scan_mode);
RELOAD_STRING(g_text_direction);
RELOAD_STRING(g_permeate_lv);
RELOAD_STRING(g_img_quality);
RELOAD_STRING(g_paper_strenght);
RELOAD_STRING(g_sleep_time);
RELOAD_STRING(g_fold_type);
}