void StringSplit(std::vector<CTString>& vecOutput, CTString strInput, ULONG ulColumnWidth) { CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort(); ULONG ulWidth = 0; #if defined(G_RUSSIA) ulWidth = UTIL_HELP()->GetNoFixedWidth(_pfdDefaultFont, strInput.str_String); #else // defined(G_RUSSIA) ulWidth = pDrawPort->GetTextWidth2(strInput); #endif // defined(G_RUSSIA) if (ulWidth <= ulColumnWidth) { strInput.TrimSpacesLeft(); strInput.TrimSpacesRight(); vecOutput.push_back(strInput); return; } char szTemp[4]; int len = strInput.Length(), pos = 0; ulWidth = 0; for (int i = 0, j = 0; i < len; j = 0) { if (IsDBCSLeadByte(strInput[i])) szTemp[j++] = strInput[i++]; szTemp[j++] = strInput[i++]; szTemp[j] = 0; ULONG ulTempWidth = 0; #if defined(G_RUSSIA) ulTempWidth = UTIL_HELP()->GetNoFixedWidth(_pfdDefaultFont, szTemp); #else // defined(G_RUSSIA) ulTempWidth = pDrawPort->GetTextWidth2(szTemp); #endif // defined(G_RUSSIA) if (ulWidth + ulTempWidth > ulColumnWidth && !(j == 1 && (szTemp[0] == '.' || szTemp[0] == ',' || szTemp[0] == ' '))) break; pos = i; ulWidth += ulTempWidth; if( strInput[pos] == '\n' || strInput[pos] == '\r' ) { pos++; break; } } CTString strLeft, strRight; strInput.Split(pos, strLeft, strRight); strLeft.TrimSpacesLeft(); strLeft.TrimSpacesRight(); vecOutput.push_back(strLeft); if (strRight.Length() > 0) StringSplit(vecOutput, strRight, ulColumnWidth); }
// load a filelist static BOOL LoadFileList(CDynamicStackArray<CTFileName> &afnm, const CTFileName &fnmList) { afnm.PopAll(); try { CTFileStream strm; strm.Open_t(fnmList); while(!strm.AtEOF()) { CTString strLine; strm.GetLine_t(strLine); strLine.TrimSpacesLeft(); strLine.TrimSpacesRight(); if (strLine!="") { afnm.Push() = strLine; } } return TRUE; } catch(char *strError) { CPrintF("%s\n", strError); return FALSE; } }