自动更换属性名称
This commit is contained in:
parent
2fd3dc61eb
commit
d4b1238773
Binary file not shown.
|
@ -46,6 +46,33 @@ namespace coding
|
|||
|
||||
return inter_module_data::SET_RESULT_CONTINUE;
|
||||
}
|
||||
typedef struct _clp_d
|
||||
{
|
||||
bool file;
|
||||
std::wstring cont;
|
||||
}CLPD, *LPCLPD;
|
||||
INTER_MODULE_CALLBACK(get_clipboard_content)
|
||||
{
|
||||
LPCLPD pclpd = (LPCLPD)param;
|
||||
|
||||
if (total == CF_TEXT)
|
||||
{
|
||||
coding_util::ansi_2_unicode(data, get_wstring, &pclpd->cont);
|
||||
pclpd->file = false;
|
||||
}
|
||||
else if (total == CF_UNICODETEXT)
|
||||
{
|
||||
pclpd->cont = std::wstring((const wchar_t*)data, len / 2);
|
||||
pclpd->file = false;
|
||||
}
|
||||
else if (total == CF_HDROP)
|
||||
{
|
||||
pclpd->cont = std::wstring((const wchar_t*)data, len / 2);
|
||||
pclpd->file = true;
|
||||
}
|
||||
|
||||
return inter_module_data::SET_RESULT_STOP;
|
||||
}
|
||||
|
||||
int string_need_bytes(const wchar_t* str)
|
||||
{
|
||||
|
@ -5758,7 +5785,7 @@ struct
|
|||
, {SANE_STD_OPT_NAME_COLOR_MODE , OPTION_TITLE_YSMS}
|
||||
, {SANE_STD_OPT_NAME_BINARY_THRESHOLD , OPTION_TITLE_HBTXYZ}
|
||||
, {SANE_STD_OPT_NAME_REVERSE_01 , OPTION_TITLE_HBTXFSSC}
|
||||
, {SANE_STD_OPT_NAME_FILTER , OPTION_TITLE_HDHHBTX_CS}
|
||||
, {SANE_STD_OPT_NAME_FILTER , OPTION_TITLE_HDHHBTX_CSYZQ}
|
||||
, {SANE_STD_OPT_NAME_RID_MULTIOUT_RED , OPTION_TITLE_24WCSTX_DLSCCH}
|
||||
, {SANE_STD_OPT_NAME_RID_ANSWER_SHEET_RED , OPTION_TITLE_24WCSTX_DTKCH}
|
||||
, {SANE_STD_OPT_NAME_ERASE_BACKGROUND , OPTION_TITLE_BJYC}
|
||||
|
@ -5818,17 +5845,41 @@ struct
|
|||
, {SANE_STD_OPT_NAME_IS_CHECK_ASKEW , OPTION_TITLE_WXJC}
|
||||
, {SANE_STD_OPT_NAME_ASKEW_RANGE , OPTION_TITLE_WXRRD}
|
||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH , OPTION_TITLE_FZQD}
|
||||
, {SANE_STD_OPT_NAME_IS_AUTO_FEED_STRENGTH , OPTION_TITLE_ZDCZQD}
|
||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH_VALUE , OPTION_TITLE_CZYZ}
|
||||
, {SANE_STD_OPT_NAME_IS_AUTO_FEED_STRENGTH , OPTION_TITLE_ZDFZQD}
|
||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH_VALUE , OPTION_TITLE_JZSBL}
|
||||
, {SANE_STD_OPT_NAME_WAIT_TO_SCAN , OPTION_TITLE_DZSM}
|
||||
},
|
||||
g_discard[] = { {SANE_STD_OPT_NAME_REVERSE_01 , "\351\273\221\347\231\275\345\233\276\345\203\217\345\217\215\350\211\262\350\276\223\345\207\272\357\274\210\346\255\243\345\270\270\351\242\234\350\211\262\344\270\272\357\274\2320-\351\273\221\350\211\262\357\274\2331-\347\231\275\350\211\262\357\274\211"} // 黑白图像反色输出(正常颜色为:0-黑色;1-白色)
|
||||
, {SANE_STD_OPT_NAME_FILTER , "\347\201\260\345\272\246\346\210\226\351\273\221\347\231\275\345\233\276\345\203\217 - \351\231\244\350\211\262"} // 灰度或黑白图像 - 除色
|
||||
, {SANE_STD_OPT_NAME_IS_AUTO_FEED_STRENGTH , "\350\207\252\345\212\250\346\220\223\347\272\270\345\274\272\345\272\246"} // 自动搓纸强度
|
||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH_VALUE , "\346\220\223\347\272\270\351\230\210\345\200\274"} // " 搓纸阈值"
|
||||
};
|
||||
|
||||
static IMPLEMENT_OPTION_STRING_COMPARE(compare_title);
|
||||
static const char* title_to_name(const char* title)
|
||||
static const char* title_to_name(std::wstring& title)
|
||||
{
|
||||
std::string utf8(coding::u2utf8(title.c_str()));
|
||||
|
||||
for (size_t i = 0; i < _countof(g_discard); ++i)
|
||||
{
|
||||
if (compare_title(g_discard[i].title, utf8.c_str()))
|
||||
{
|
||||
for (size_t j = 0; j < _countof(g_opts); ++j)
|
||||
{
|
||||
if (strcmp(g_opts[j].name, g_discard[i].name) == 0)
|
||||
{
|
||||
title = coding::utf82u(g_opts[j].title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return g_discard[i].name;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _countof(g_opts); ++i)
|
||||
{
|
||||
if (compare_title(g_opts[i].title, title))
|
||||
if (compare_title(g_opts[i].title, utf8.c_str()))
|
||||
return g_opts[i].name;
|
||||
}
|
||||
|
||||
|
@ -5866,6 +5917,7 @@ void ChgjsonDlg::DoDataExchange(CDataExchange* pDX)
|
|||
BEGIN_MESSAGE_MAP(ChgjsonDlg, CDialogEx)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_QUERYDRAGICON()
|
||||
// ON_WM_PASTE()
|
||||
ON_COMMAND(ID_TREE_ADDGROUP, &ChgjsonDlg::OnTreeAddGroup)
|
||||
ON_COMMAND(ID_TREE_ADDITEM, &ChgjsonDlg::OnTreeAddItem)
|
||||
ON_COMMAND(ID_TREE_DELITEM, &ChgjsonDlg::OnTreeDelItem)
|
||||
|
@ -5897,6 +5949,7 @@ BEGIN_MESSAGE_MAP(ChgjsonDlg, CDialogEx)
|
|||
ON_COMMAND(ID_LISTMENU_TOOLTIPS, &ChgjsonDlg::OnListmenuTooltips)
|
||||
ON_COMMAND(ID_TREE_EXPORTCHAR, &ChgjsonDlg::OnTreeExportCharConstants)
|
||||
ON_BN_CLICKED(IDC_TO_FILE, &ChgjsonDlg::OnBnClickedToFile)
|
||||
ON_COMMAND(ID_TREE_LOADCLIPBOARD, &ChgjsonDlg::OnTreeLoadClipboard)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
@ -6345,7 +6398,7 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h)
|
|||
known_file_util::IJsonW* jsn = known_file_util::create_jsonW();
|
||||
wchar_t buf[128] = { 0 };
|
||||
int prefer_size = 0;
|
||||
const char* opt_name = title_to_name(coding::u2utf8(hg_items_[item].title.c_str()).c_str());
|
||||
const char* opt_name = title_to_name(hg_items_[item].title);
|
||||
|
||||
jsn->set_value(L"category", hg_items_[item].advanced ? L"advanced" : L"base");
|
||||
if (opt_name)
|
||||
|
@ -6755,13 +6808,34 @@ void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent)
|
|||
|
||||
hg_items_.push_back(item);
|
||||
}
|
||||
bool ChgjsonDlg::load_from_json_text(const wchar_t* txt)
|
||||
bool ChgjsonDlg::load_from_json_text(const wchar_t* txt, std::wstring* err_msg)
|
||||
{
|
||||
int pos = 0;
|
||||
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(txt, &pos), * child = NULL;
|
||||
|
||||
if (!jsn)
|
||||
{
|
||||
int ep = 10, len = 10;
|
||||
if (lstrlenW(txt + pos) < 10)
|
||||
len = lstrlenW(txt + pos);
|
||||
if (pos < 10)
|
||||
{
|
||||
ep = pos;
|
||||
pos = 10;
|
||||
}
|
||||
pos -= 10;
|
||||
|
||||
std::wstring info(txt + pos, len + ep + 1);
|
||||
wchar_t msg[80] = { 0 };
|
||||
|
||||
swprintf_s(msg, L"Error at position %d of char '%c'!\r\n\r\n", ep, info[ep]);
|
||||
if (err_msg)
|
||||
*err_msg = msg + info;
|
||||
else
|
||||
::MessageBoxW(m_hWnd, (msg + info).c_str(), L"Load Error", MB_OK);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hg_items_.clear();
|
||||
tree_.DeleteAllItems();
|
||||
|
@ -6921,6 +6995,81 @@ HCURSOR ChgjsonDlg::OnQueryDragIcon()
|
|||
return static_cast<HCURSOR>(m_hIcon);
|
||||
}
|
||||
|
||||
void ChgjsonDlg::OnPaste()
|
||||
{
|
||||
coding::CLPD clpb;
|
||||
|
||||
file_util::get_clipboard(coding::get_clipboard_content, &clpb);
|
||||
if (clpb.cont.empty())
|
||||
{
|
||||
MessageBox(TEXT("clipboard is empty."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clpb.file)
|
||||
{
|
||||
size_t pos = clpb.cont.find(L"\r\n");
|
||||
bool loaded = false;
|
||||
|
||||
while (!loaded && pos != std::wstring::npos)
|
||||
{
|
||||
loaded = load_from_file(clpb.cont.substr(0, pos).c_str());
|
||||
clpb.cont.erase(0, pos + 2);
|
||||
pos = clpb.cont.find(L"\r\n");
|
||||
}
|
||||
if (!loaded && file_util::is_file_existing(clpb.cont.c_str()))
|
||||
load_from_file(clpb.cont.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring err(L"");
|
||||
if (load_from_json_text(clpb.cont.c_str(), &err))
|
||||
return;
|
||||
|
||||
// we assum the content from codes ...
|
||||
std::wstring jsn(L"");
|
||||
size_t pos = clpb.cont.find(L" std::string");
|
||||
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
clpb.cont.erase(0, pos);
|
||||
pos = clpb.cont.find(L"\"");
|
||||
if (pos == std::wstring::npos)
|
||||
break;
|
||||
clpb.cont.erase(0, pos + 1);
|
||||
pos = clpb.cont.find(L"\");");
|
||||
if (pos == std::wstring::npos)
|
||||
{
|
||||
jsn += clpb.cont;
|
||||
break;
|
||||
}
|
||||
else
|
||||
jsn += clpb.cont.substr(0, pos);
|
||||
clpb.cont.erase(0, pos);
|
||||
pos = clpb.cont.find(L" std::string");
|
||||
}
|
||||
|
||||
if (jsn.length())
|
||||
{
|
||||
pos = jsn.find(L"\\\\");
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
jsn.erase(pos++, 1);
|
||||
pos = jsn.find(L"\\\\", pos);
|
||||
}
|
||||
pos = jsn.find(L"\\\"");
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
jsn.erase(pos++, 1);
|
||||
pos = jsn.find(L"\\\"", pos);
|
||||
}
|
||||
|
||||
load_from_json_text(jsn.c_str());
|
||||
}
|
||||
else
|
||||
::MessageBoxW(m_hWnd, err.c_str(), L"Load Error", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ChgjsonDlg::OnTreeAddProduct()
|
||||
|
@ -7055,16 +7204,22 @@ void ChgjsonDlg::OnBnClickedButton2()
|
|||
}
|
||||
|
||||
// divide into multi-lines with 16KB per line ...
|
||||
int lines = 1;
|
||||
int lines = 1;
|
||||
char var[80] = { 0 };
|
||||
|
||||
pos = txt.length();
|
||||
while (pos > 16 * 1024)
|
||||
{
|
||||
pos -= 12 * 1024;
|
||||
while (txt[pos - 1] == '\\')
|
||||
pos++;
|
||||
txt.insert(pos, "\r\n");
|
||||
lines++;
|
||||
sprintf_s(var, _countof(var) - 1, "\");\r\nstatic std::string jsontext%d(\"", lines);
|
||||
txt.insert(pos, var);
|
||||
}
|
||||
txt.insert(0, "static std::string jsontext1(\"");
|
||||
txt += "\");\r\n";
|
||||
|
||||
file_util::set_clipboard(txt.c_str(), txt.length());
|
||||
|
||||
TCHAR msg[128] = { 0 };
|
||||
|
@ -7641,6 +7796,12 @@ void ChgjsonDlg::OnTreeLoadfile()
|
|||
}
|
||||
}
|
||||
|
||||
void ChgjsonDlg::OnTreeLoadClipboard()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
OnPaste();
|
||||
}
|
||||
|
||||
|
||||
void ChgjsonDlg::OnLvnKeydownListValues(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
|
@ -7837,3 +7998,4 @@ void ChgjsonDlg::OnBnClickedToFile()
|
|||
if (save_scanner_setting(ansi.c_str(), txt) == 0)
|
||||
file_util::display_file_in_explorer(name.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ protected:
|
|||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnPaint();
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
afx_msg void OnPaste();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
static void to_define_header(std::vector<DEFH>& defs, const wchar_t* str, const wchar_t* parent = NULL);
|
||||
|
@ -116,7 +117,7 @@ protected:
|
|||
void* create_json(int item, std::vector<DEFH> *def_h = NULL);
|
||||
std::string to_json_text(bool for_const = false, std::wstring *dev = NULL);
|
||||
void add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent);
|
||||
bool load_from_json_text(const wchar_t* txt);
|
||||
bool load_from_json_text(const wchar_t* txt, std::wstring* err_msg = NULL);
|
||||
bool load_from_file(const wchar_t* path_file);
|
||||
void get_all_names(HTREEITEM root, std::vector<std::wstring>& names, DWORD mask = 0);
|
||||
void on_config_name_changed(const wchar_t* prev, const wchar_t* now);
|
||||
|
@ -162,6 +163,7 @@ public:
|
|||
afx_msg void OnListmenuTooltips();
|
||||
afx_msg void OnTreeExportCharConstants();
|
||||
afx_msg void OnBnClickedToFile();
|
||||
afx_msg void OnTreeLoadClipboard();
|
||||
};
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue