Browse Source

Merge branch 'master' of http://gitz.zhixinhuixue.net:18880/zxhx-client-tool/pdfproject

duanjianjun 2 years ago
parent
commit
401aa71c65

+ 26 - 4
MFCApplication1/AssignWords.cpp

@@ -57,6 +57,18 @@ void DivideEquallyStr(const char *buff, int len, char left[], char right[])
 {
 	std::string strtemp = buff;
 	std::size_t keyindex1 = std::string::npos, keyindex2 = std::string::npos, keyindex;
+	int i = 0;
+	for (i = 0; i < len / 2; i++)
+	{
+		if (!(buff[i] < 0x80 && buff[i] >= 0x0))
+		{
+			i++;
+		}
+	}
+	strncpy(left, buff, i);
+	strncpy(right, buff + i, len - i);
+	return;
+	/* 直接中间分开,不用特殊处理*/
 	std::string strKey1 = ";", strKey2 = " ";
 	std::size_t found = strtemp.find(strKey1);
 	bool flag1 = false, flag2 = false;
@@ -186,8 +198,18 @@ int AssignWordsFromTest(std::string pathName, std::vector<std::string> &twoList,
 	CString filepath = csFullPath.Left(nPos);
 	CString FilePath1 = filepath + L"\\config.ini";
 	CString FilePath2 = filepath + L"\\words.txt";
-	WCHAR wflagWord[10];
+	WCHAR wflagWord[10],wFourColScaleParam[10],wThreeColScaleParam[10],wTwoColScaleParam[10];
 	GetPrivateProfileString(L"USER", L"flagWord", L"1", wflagWord, 10, FilePath1);
+	GetPrivateProfileString(L"USER", L"TwoColScaleParam", L"6", wTwoColScaleParam, 10, FilePath1);
+	GetPrivateProfileString(L"USER", L"ThreeColScaleParam", L"9", wThreeColScaleParam, 10, FilePath1);
+	GetPrivateProfileString(L"USER", L"FourColScaleParam", L"16", wFourColScaleParam, 10, FilePath1);
+	int nFourColScaleParam = 0, nThreeColScaleParam = 0, nTwoColScaleParam = 0;
+	nFourColScaleParam = _wtoi(wFourColScaleParam);
+	nFourColScaleParam = nFourColScaleParam > 0 ? nFourColScaleParam : 16;
+	nThreeColScaleParam = _wtoi(wThreeColScaleParam);
+	nThreeColScaleParam = nThreeColScaleParam > 0 ? nThreeColScaleParam : 9;
+	nTwoColScaleParam = _wtoi(wTwoColScaleParam);
+	nTwoColScaleParam = nTwoColScaleParam > 0 ? nTwoColScaleParam : 6;
 	CString lpszflagWord(wflagWord);
 	std::vector<std::string> WordList;
 	WordList.push_back("vt.");
@@ -234,9 +256,9 @@ int AssignWordsFromTest(std::string pathName, std::vector<std::string> &twoList,
 	int cout = 0;
 	if (_access(pathName.c_str(), 00) != -1)
 	{
-		int maxTwoWith = main_wdith / 4 - chk_width;
-		int maxTreeWith = main_wdith*2/9 - chk_width;
-		int maxFourWith = main_wdith * 3 / 16 - chk_width;
+		int maxTwoWith = main_wdith / 2 - main_wdith / nTwoColScaleParam - chk_width;
+		int maxTreeWith = main_wdith / 3 - main_wdith / nThreeColScaleParam - chk_width;
+		int maxFourWith = main_wdith  / 4 - main_wdith/ nFourColScaleParam - chk_width;
 		std::ifstream fin(pathName.c_str(), std::ios::in);
 		char line[4096] = { 0 };
 		while (fin.getline(line, sizeof(line)))

+ 1 - 1
MFCApplication1/CvxText.cpp

@@ -529,7 +529,7 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 	std::string strJson = JsonToString(root);
 
 	CString strTemplatePath;
-	strTemplatePath.Format(L"%s/%d.json", dir, index);
+	strTemplatePath.Format(L"%s/json/%d.json", dir, index);
 	CFile zip;
 	zip.Open(strTemplatePath, CFile::modeCreate | CFile::modeWrite);
 	zip.Write((void*)strJson.c_str(), strJson.length());

BIN
MFCApplication1/MFCApplication1.aps


+ 18 - 4
MFCApplication1/MFCApplication1Dlg.cpp

@@ -111,7 +111,7 @@ DWORD WINAPI ProcessThread(void *param)
 			else
 			{
 				CString strPdfPath;
-				strPdfPath.Format(L"%s/%d.pdf", pWnd->m_strPdfDir, pageNum);
+				strPdfPath.Format(L"%s/pdf/%d.pdf", pWnd->m_strPdfDir, pageNum);
 				PdfNewFromImage({ strPage1, strPagePath }, TstringToGB2312(strPdfPath.GetBuffer()));
 				strPage1 = "";
 
@@ -125,7 +125,7 @@ DWORD WINAPI ProcessThread(void *param)
 		if (strPage1.length() > 0)
 		{
 			CString strPdfPath;
-			strPdfPath.Format(L"%s/%d.pdf", pWnd->m_strPdfDir, pageNum);
+			strPdfPath.Format(L"%s/pdf/%d.pdf", pWnd->m_strPdfDir, pageNum);
 			PdfNewFromImage({ strPage1 }, TstringToGB2312(strPdfPath.GetBuffer()));
 			CString strMsg = L"";
 			strMsg.Format(L"%s\r\n", strPdfPath);
@@ -284,19 +284,33 @@ void CMFCApplication1Dlg::OnBnClickedOk()
 	((CEdit*)GetDlgItem(IDC_EDIT_TXT))->GetWindowText(m_strTextPath);
 	((CEdit*)GetDlgItem(IDC_EDIT_PDF))->GetWindowText(m_strPdfDir);
 	
-	if (m_strPdfDir.GetLength() == 0)
+	if (m_strTextPath.GetLength() == 0)
 	{
 		AfxMessageBox(L"语料库文件未选择");
 		return;
 	}
 	if (m_strPdfDir.GetLength() == 0)
 	{
-		AfxMessageBox(L"PDF文件路径未选择");
+		AfxMessageBox(L"PDF文件未选择");
 		return;
 	}
 
 	GetDlgItem(IDOK)->EnableWindow(FALSE);
 	m_strMsg = "";
+
+	CString strJsonDir(m_strPdfDir);
+	strJsonDir.Append(L"\\json");
+	if (!PathIsDirectory(strJsonDir))
+	{
+		::CreateDirectory(strJsonDir, 0);
+	}
+
+	CString strPdfDir(m_strPdfDir);
+	strPdfDir.Append(L"\\pdf");
+	if (!PathIsDirectory(strPdfDir))
+	{
+		::CreateDirectory(strPdfDir, 0);
+	}
 	
 	SAFETY_EXIT_THREAD(_threadProcess, 100);
 	_threadProcess = CreateThread(NULL, 0, ProcessThread, NULL, 0, NULL);