2022-05-03 03:56:07 +00:00
|
|
|
|
#include "common_setting.h"
|
|
|
|
|
|
|
|
|
|
static struct _fixed_option
|
|
|
|
|
{
|
|
|
|
|
std::string str;
|
|
|
|
|
int enum_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_color_mode[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(COLOR_MODE_BLACK_WHITE),
|
|
|
|
|
MAKE_STR_AND_ENUM(COLOR_MODE_256_GRAY),
|
|
|
|
|
MAKE_STR_AND_ENUM(COLOR_MODE_24_BITS),
|
|
|
|
|
MAKE_STR_AND_ENUM(COLOR_MODE_AUTO_MATCH)
|
|
|
|
|
},
|
|
|
|
|
g_multi_out[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(MULTI_OUT_NOT),
|
|
|
|
|
MAKE_STR_AND_ENUM(MULTI_OUT_ALL),
|
|
|
|
|
MAKE_STR_AND_ENUM(MULTI_COLOR_ADN_GRAY),
|
|
|
|
|
MAKE_STR_AND_ENUM(MULTI_COLOR_ADN_BW),
|
|
|
|
|
MAKE_STR_AND_ENUM(MULTI_GRAY_ADN_BW)
|
|
|
|
|
},
|
|
|
|
|
g_rid_color[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_NONE),
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_RID_RED),
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_RID_GREEN),
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_RID_BLUE),
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_ENHANCE_RED),
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_ENHANCE_GREEN),
|
|
|
|
|
MAKE_STR_AND_ENUM(RID_COLOR_ENHANCE_BLUE)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_paper[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A3),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A4),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A5),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A6),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_B4),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_B5),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_B6),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_8K),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_16K),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_LETTER),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A4_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A5_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_A6_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_B5_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_B6_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_16K_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_LETTER_LATERAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_DOUBLE_LETTER),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_LEGAL),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_AUTO_MATCH),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_MAX_SIZE),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_MAX_SIZE_CLIP),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAPER_TRIGEMINY)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_page[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(PAGE_SINGLE),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAGE_DOUBLE),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAGE_OMIT_EMPTY),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAGE_OMIT_EMPTY_RECEIPT),
|
|
|
|
|
MAKE_STR_AND_ENUM(PAGE_FOLIO)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_sharpen[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(SHARPEN_NONE),
|
|
|
|
|
MAKE_STR_AND_ENUM(SHARPEN_SHARPEN),
|
|
|
|
|
MAKE_STR_AND_ENUM(SHARPEN_SHARPEN_MORE),
|
|
|
|
|
MAKE_STR_AND_ENUM(SHARPEN_HAZY),
|
|
|
|
|
MAKE_STR_AND_ENUM(SHARPEN_HAZY_MORE)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_fill_bkg[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(FILL_BKG_CONVEX_POLYGON),
|
|
|
|
|
MAKE_STR_AND_ENUM(FILL_BKG_CONCAVE_POLYGON)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_scan_mode[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(SCAN_MODE_CONTINUOUS),
|
|
|
|
|
MAKE_STR_AND_ENUM(SCAN_MODE_GIVEN_COUNT)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_text_direction[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(TEXT_DIRECTION_0),
|
|
|
|
|
MAKE_STR_AND_ENUM(TEXT_DIRECTION_90),
|
|
|
|
|
MAKE_STR_AND_ENUM(TEXT_DIRECTION_180),
|
|
|
|
|
MAKE_STR_AND_ENUM(TEXT_DIRECTION_270),
|
|
|
|
|
MAKE_STR_AND_ENUM(TEXT_DIRECTION_AUTO)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
g_permeate_lv[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(PERMAEATE_WEAKER),
|
|
|
|
|
MAKE_STR_AND_ENUM(PERMAEATE_WEAK),
|
|
|
|
|
MAKE_STR_AND_ENUM(PERMAEATE_ORDINARY),
|
|
|
|
|
MAKE_STR_AND_ENUM(PERMAEATE_STRONG),
|
|
|
|
|
MAKE_STR_AND_ENUM(PERMAEATE_STRONGER)
|
2022-05-09 07:02:00 +00:00
|
|
|
|
},
|
|
|
|
|
g_img_quality[] =
|
|
|
|
|
{
|
|
|
|
|
MAKE_STR_AND_ENUM(IMG_NONE),
|
|
|
|
|
MAKE_STR_AND_ENUM(IMG_SPEED),
|
|
|
|
|
MAKE_STR_AND_ENUM(IMG_QUALITY)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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(ind, val, def) \
|
|
|
|
|
if(ind == -1) \
|
|
|
|
|
{ \
|
|
|
|
|
ind = def; \
|
|
|
|
|
val = STR_SETTING(def); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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(ind, val, COLOR_MODE_24_BITS);
|
|
|
|
|
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(ind, val, MULTI_OUT_NOT);
|
|
|
|
|
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(ind, val, RID_COLOR_NONE);
|
|
|
|
|
if (exact)
|
|
|
|
|
*exact = yes;
|
|
|
|
|
|
|
|
|
|
return ind;
|
|
|
|
|
}
|
|
|
|
|
int match_best_paper(std::string& val, bool* exact)
|
|
|
|
|
{
|
|
|
|
|
bool yes = true;
|
|
|
|
|
int ind = INVOKE_MATCH(g_paper, val, yes);
|
|
|
|
|
|
|
|
|
|
SET_DEFAULT_ON_FAIL(ind, val, PAPER_A4);
|
|
|
|
|
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(ind, val, PAGE_DOUBLE);
|
|
|
|
|
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(ind, val, SHARPEN_NONE);
|
|
|
|
|
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(ind, val, FILL_BKG_CONVEX_POLYGON);
|
|
|
|
|
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(ind, val, SCAN_MODE_CONTINUOUS);
|
|
|
|
|
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(ind, val, TEXT_DIRECTION_0);
|
|
|
|
|
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(ind, val, TEXT_DIRECTION_0);
|
|
|
|
|
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(ind, val, IMG_SPEED);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
return INVOKE_STR(g_img_quality, is_quakuty, 0);
|
|
|
|
|
}
|