void TestDocReader::TestExtractBodyTextOnly() { DocReader dr; dr.OpenFile(TEST_REALLY_COMPLEX_DOC); CStdStringW sDocText = dr.GetMainDocumentText(); assertTest(sDocText.Left(9) == L"Once upon"); assertTest(sDocText.Right(12) == L"ever after.\r"); assertMessage(sDocText.Find(L"Nested") != -1, _T("expected to get the nested table contents, but didnt")); assertMessage(sDocText.Find(L"Four") != -1, _T("expected to get the table contents, but didnt")); assertMessage(sDocText.Find(L"a comment") == -1, _T("didnt expect to get the comment contents, but did")); assertMessage(sDocText.Find(L"header") == -1, _T("didnt expect to get the header contents, but did")); assertMessage(sDocText.Find(L"footer") == -1, _T("didnt expect to get the footer contents, but did")); assertMessage(sDocText.Find(L"text box") == -1, _T("didnt expect to get the text box contents, but did")); assertMessage(sDocText.Find(L"MERGEFORMAT") == -1, _T("didnt expect to get the field code contents, but did")); assertMessage(sDocText.Find(L"allsorts") != -1, _T("expected to get the field result contents, but didny")); assertMessage(sDocText.Find(L"be footnote") == -1, _T("didnt expect to get the footnote, but did")); assertMessage(sDocText.Find(L"Line Break\013") != -1, _T("expected char 11 as line break")); assertMessage(sDocText.Find(L"Section Break\014") != -1, _T("expected char 12 as section break")); // assertMessage(sDocText.Find(L"Symbol Char\050") != -1, _T("expected char 40 as symbol char")); assertMessage(sDocText.Find(L"NonBreakSpace\240char") != -1, _T("expected char 160 as non breaking space")); //assertMessage(sDocText.Find(L"EnDash\226") != -1, _T("expected char 150 as En dash")); //assertMessage(sDocText.Find(L"EnDash\227") != -1, _T("expected char 150 as Em dash")); // assertMessage(sDocText.Find(L"the \025 document") != -1, _T("expected char 21 as field char")); assertMessage(sDocText.Find(L"One\007Two") != -1, _T("expected char 7 as cell char")); }
DWORD GetLongPathName (CStdStringW strShortPath, CStdStringW &strLongPath) { int iFound = strShortPath.ReverseFind (L'\\'); if (iFound > 1) { // recurse to peel off components // if (GetLongPathName(strShortPath.Left (iFound), strLongPath) > 0) { strLongPath += L'\\'; if (strShortPath.Right(1) != L"\\") { HANDLE hFind; if (g_bIsNT) { WIN32_FIND_DATAW findData; // append the long component name to the path // if (INVALID_HANDLE_VALUE != (hFind = ::FindFirstFileW (strShortPath, &findData))) { strLongPath += findData.cFileName; ::FindClose (hFind); } else { // if FindFirstFile fails, return the error code // strLongPath.Empty(); return 0; } } else { WIN32_FIND_DATAA findData; // append the long component name to the path // if (INVALID_HANDLE_VALUE != (hFind = ::FindFirstFileA (CStdStringA (strShortPath), &findData))) { strLongPath += findData.cFileName; ::FindClose (hFind); } else { // if FindFirstFile fails, return the error code // strLongPath.Empty(); return 0; } } } } } else { strLongPath = strShortPath; } return strLongPath.GetLength(); }