转换特殊属性

This commit is contained in:
gb 2023-01-29 16:05:31 +08:00
parent 4daf686fd8
commit 6f314d712c
1 changed files with 29 additions and 23 deletions

View File

@ -2,6 +2,8 @@
#include <Windows.h> #include <Windows.h>
#include <sane/sane_option_definitions.h> #include <sane/sane_option_definitions.h>
#include "../../sdk/include/lang/app_language.h"
namespace sane_opt_trans namespace sane_opt_trans
{ {
static struct static struct
@ -61,12 +63,12 @@ namespace sane_opt_trans
for (int i = 0; i < _countof(arr); ++i) \ for (int i = 0; i < _countof(arr); ++i) \
{ \ { \
if (arr[i].twain_id == val) \ if (arr[i].twain_id == val) \
return arr[i].opt_val; \ return from_default_language(arr[i].opt_val, NULL); \
} }
#define VALUE_TO_TWAIN(arr, val) \ #define VALUE_TO_TWAIN(arr, val) \
for (int i = 0; i < _countof(arr); ++i) \ for (int i = 0; i < _countof(arr); ++i) \
{ \ { \
if (strcmp(arr[i].opt_val, val) == 0) \ if (strcmp(from_default_language(arr[i].opt_val, NULL), val) == 0) \
return arr[i].twain_id; \ return arr[i].twain_id; \
} }
@ -103,7 +105,7 @@ namespace sane_opt_trans
for (int i = 0; i < _countof(g_filter_map); ++i) for (int i = 0; i < _countof(g_filter_map); ++i)
{ {
if (g_filter_map[i].twain_id == val) if (g_filter_map[i].twain_id == val)
return g_filter_map[i].opt_val; return from_default_language(g_filter_map[i].opt_val, NULL);
} }
} }
else else
@ -111,15 +113,16 @@ namespace sane_opt_trans
for (int i = 0; i < _countof(g_enhance_map); ++i) for (int i = 0; i < _countof(g_enhance_map); ++i)
{ {
if (g_enhance_map[i].twain_id == val) if (g_enhance_map[i].twain_id == val)
return g_enhance_map[i].opt_val; return from_default_language(g_enhance_map[i].opt_val, NULL);
} }
} }
return OPTION_VALUE_HDHHBTX_CSYZQ_BCS; return from_default_language(OPTION_VALUE_HDHHBTX_CSYZQ_BCS, NULL);
} }
int filter_enhance_value_to_twain(const char* val, bool* is_filter) int filter_enhance_value_to_twain(const char* val, bool* is_filter)
{ {
bool type = false; bool type = false;
const char* hz = to_default_language(val, NULL);
if (!is_filter) if (!is_filter)
is_filter = &type; is_filter = &type;
@ -127,13 +130,13 @@ namespace sane_opt_trans
*is_filter = true; *is_filter = true;
for (int i = 0; i < _countof(g_filter_map); ++i) for (int i = 0; i < _countof(g_filter_map); ++i)
{ {
if (strcmp(g_filter_map[i].opt_val, val) == 0) if (strcmp(g_filter_map[i].opt_val, hz) == 0)
return g_filter_map[i].twain_id; return g_filter_map[i].twain_id;
} }
*is_filter = false; *is_filter = false;
for (int i = 0; i < _countof(g_enhance_map); ++i) for (int i = 0; i < _countof(g_enhance_map); ++i)
{ {
if (strcmp(g_enhance_map[i].opt_val, val) == 0) if (strcmp(g_enhance_map[i].opt_val, hz) == 0)
return g_enhance_map[i].twain_id; return g_enhance_map[i].twain_id;
} }
@ -148,25 +151,26 @@ namespace sane_opt_trans
val -= 360.0f; val -= 360.0f;
if (60.0f < val && val < 120.0f) if (60.0f < val && val < 120.0f)
return OPTION_VALUE_WGFX_90; return from_default_language(OPTION_VALUE_WGFX_90, NULL);
else if (150.0f < val && val < 210.0f) else if (150.0f < val && val < 210.0f)
return OPTION_VALUE_WGFX_180; return from_default_language(OPTION_VALUE_WGFX_180, NULL);
else if (240.0f < val && val < 300.0f) else if (240.0f < val && val < 300.0f)
return OPTION_VALUE_WGFX__90; return from_default_language(OPTION_VALUE_WGFX__90, NULL);
else if (330.0f < val || val < 30.0f) else if (330.0f < val || val < 30.0f)
return OPTION_VALUE_WGFX_0; return from_default_language(OPTION_VALUE_WGFX_0, NULL);
else else
return OPTION_VALUE_WGFX_ZDWBFXSB; return from_default_language(OPTION_VALUE_WGFX_ZDWBFXSB, NULL);
} }
float text_direction_to_twain(const char* val) float text_direction_to_twain(const char* val)
{ {
if (strcmp(val, OPTION_VALUE_WGFX_90) == 0) const char* hz = to_default_language(val, NULL);
if (strcmp(hz, OPTION_VALUE_WGFX_90) == 0)
return 90.0f; return 90.0f;
else if (strcmp(val, OPTION_VALUE_WGFX_180) == 0) else if (strcmp(hz, OPTION_VALUE_WGFX_180) == 0)
return 180.0f; return 180.0f;
else if (strcmp(val, OPTION_VALUE_WGFX__90) == 0) else if (strcmp(hz, OPTION_VALUE_WGFX__90) == 0)
return 270.0f; return 270.0f;
else if (strcmp(val, OPTION_VALUE_WGFX_0) == 0) else if (strcmp(hz, OPTION_VALUE_WGFX_0) == 0)
return .0f; return .0f;
else else
return AUTO_MATIC_ROTATE; return AUTO_MATIC_ROTATE;
@ -200,21 +204,23 @@ namespace sane_opt_trans
} }
const char* switch_paper_lateral(const char* val) const char* switch_paper_lateral(const char* val)
{ {
const char* hz = to_default_language(val, NULL);
for (int i = 0; i < _countof(g_lateral_map); ++i) for (int i = 0; i < _countof(g_lateral_map); ++i)
{ {
if (strcmp(g_lateral_map[i].normal, val) == 0) if (strcmp(g_lateral_map[i].normal, hz) == 0)
return g_lateral_map[i].lateral; return from_default_language(g_lateral_map[i].lateral, NULL);
else if (strcmp(g_lateral_map[i].lateral, val) == 0) else if (strcmp(g_lateral_map[i].lateral, hz) == 0)
return g_lateral_map[i].normal; return from_default_language(g_lateral_map[i].normal, NULL);
} }
return NULL; return NULL;
} }
bool is_paper_lateral(const char* val) bool is_paper_lateral(const char* val)
{ {
const char* hz = to_default_language(val, NULL);
for (int i = 0; i < _countof(g_lateral_map); ++i) for (int i = 0; i < _countof(g_lateral_map); ++i)
{ {
if (strcmp(g_lateral_map[i].lateral, val) == 0) if (strcmp(g_lateral_map[i].lateral, hz) == 0)
return true; return true;
} }
@ -225,7 +231,7 @@ namespace sane_opt_trans
{ {
VALUE_FROM_TWAIN(g_color_mode_map, val); VALUE_FROM_TWAIN(g_color_mode_map, val);
return OPTION_VALUE_YSMS_24WCS; return from_default_language(OPTION_VALUE_YSMS_24WCS, NULL);
} }
int auto_color_type_to_twain(const char* val) int auto_color_type_to_twain(const char* val)
{ {
@ -238,7 +244,7 @@ namespace sane_opt_trans
{ {
VALUE_FROM_TWAIN(g_sharpen_map, val); VALUE_FROM_TWAIN(g_sharpen_map, val);
return OPTION_VALUE_RHYMH_W; return from_default_language(OPTION_VALUE_RHYMH_W, NULL);
} }
int sharpen_to_twain(const char* val) int sharpen_to_twain(const char* val)
{ {