Esempio n. 1
0
void DocXDocumentStore::GetDocumentTexts(const CStdString& sFileName, std::vector<std::string>& vDocumentTexts) const
{
	vDocumentTexts.clear();

	CZipArchive zipArchive;
	zipArchive.Open(sFileName, CZipArchive::zipOpenReadOnly);
	if( !zipArchive.IsClosed() )
	{
		CZipWordArray ar;
		zipArchive.FindMatches( L"word\\\\*.xml", ar );
		for( int uIndex = 0; uIndex < ar.GetSize(); uIndex++ )
		{
			CZipFileHeader fhInfo;
			if( zipArchive.GetFileInfo( fhInfo, ar[uIndex] ) )
			{
				const CZipString fileName( fhInfo.GetFileName() );
				if( fileName.find_first_of( '\\' ) == fileName.find_last_of( '\\' ) )
				{
					C2007DocFile mf;
					zipArchive.ExtractFile( ar[uIndex], mf );			
					const CStdStringA sDocText = mf.GetWTInnerText();
					if( sDocText.size() > 0 )
						vDocumentTexts.push_back( sDocText );
				}
			}
		}
		zipArchive.Flush();
		zipArchive.Close();
	}
}
Esempio n. 2
0
CStdStringA RomanIndexFormatter::FormatDigit(int iValue, CStdStringA sDigits)
{
	if ((x64_int_cast)sDigits.size() != 3)
		throw std::exception("Invalid digits collection in roman numeral formatting");

	if ((iValue < 0) || (iValue > 9))
		throw std::exception("digit out of range in roman numeral formatting");

	char cUnit = sDigits[2];
	char cFive = sDigits[1];
	char cTen = sDigits[0];

	CStdStringA sResult;
	switch (iValue)
	{
	case 9:
	case 4:
		sResult += cUnit;
		sResult += (iValue == 9) ? cTen : cFive;
		break;
	case 8:
	case 3:
		sResult += cUnit;
	case 7:
	case 2:
		sResult += cUnit;
	case 6:
	case 1:
		sResult += cUnit;
	case 5:
		if (iValue>4)
			sResult = cFive + sResult;
		break;
	}

	return sResult;
}