Esempio n. 1
0
int _tmain(int argc, _TCHAR* argv[])
{
	if (argc < 3) return 3;

	std::wstring sSrcPpt	= argv[1];
    std::wstring sDstPptx	= argv[2];

	std::wstring outputDir		= FileSystem::Directory::GetFolderPath(sDstPptx);
	std::wstring dstTempPath	= FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);

	std::wstring tempPath	= FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
	// Ppt->Pptx
		COfficePPTFile pptFile;
		
		pptFile.put_TempDirectory(tempPath);

		HRESULT hRes = pptFile.LoadFromFile(sSrcPpt, dstTempPath);
	
	if (hRes != S_OK)return 2;
	
	COfficeUtils oCOfficeUtils(NULL);
	if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), sDstPptx, -1))
        return 1;
	
	FileSystem::Directory::DeleteDirectory(dstTempPath);
	FileSystem::Directory::DeleteDirectory(tempPath);
	return 0;
}
Esempio n. 2
0
HRESULT convert_single(std::wstring srcFileName)
{
	//COfficeFileFormatChecker checker;

	//if (false == checker.isOfficeFile(srcFileName)) return S_FALSE;	
	//
	//if (AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT != checker.nFileType) return S_FALSE;
	
	HRESULT hr = S_OK;

	std::wstring outputDir		= NSDirectory::GetFolderPath(srcFileName);	
	std::wstring dstTempPath	= NSDirectory::CreateDirectoryWithUniqueName(outputDir);
	std::wstring dstPath;

	std::wstring tempPath	= NSDirectory::CreateDirectoryWithUniqueName(outputDir);

	COfficePPTFile pptFile;
	
	pptFile.put_TempDirectory(tempPath);

	bool bMacros = true;
	
	HRESULT hRes = pptFile.LoadFromFile(srcFileName, dstTempPath, L"password", bMacros);
	
	if (bMacros)
	{
		dstPath = srcFileName + L"-my.pptm";
	}
	else
	{
		dstPath = srcFileName + L"-my.pptx";

	}
	if (hRes == S_OK)
	{
		COfficeUtils oCOfficeUtils(NULL);
		hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath, true);
	}
	
	NSDirectory::DeleteDirectory(dstTempPath);
	NSDirectory::DeleteDirectory(tempPath);

	return hRes;
}