_UINT32 CPPTXFile::OpenDirectoryToPPTY(std::wstring bsInput, std::wstring bsOutput)
{
	OOX::CPath pathInputDirectory = bsInput;

	RELEASEOBJECT(m_pPptxDocument);
	m_pPptxDocument = new PPTX::Document();

	if (!m_pPptxDocument->isValid(pathInputDirectory.GetPath())) // true ???
	{
		RELEASEOBJECT(m_pPptxDocument);
		return AVS_FILEUTILS_ERROR_CONVERT;
	}

	m_pPptxDocument->read(pathInputDirectory.GetPath() + FILE_SEPARATOR_STR, (PPTX::IPPTXEvent*)this);
	if(GetPercent() < 1000000)
	{
		RELEASEOBJECT(m_pPptxDocument);
		return AVS_FILEUTILS_ERROR_CONVERT;
	}
	smart_ptr<PPTX::Presentation> presentation = m_pPptxDocument->Get(OOX::Presentation::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
	if (!presentation.is_init())
	{
        NSDirectory::DeleteDirectory(m_strTempDir, false);
		return AVS_FILEUTILS_ERROR_CONVERT;
	}

	m_strDirectory = pathInputDirectory.GetDirectory();

	NSBinPptxRW::CBinaryFileWriter oBinaryWriter;
	oBinaryWriter.m_pCommon->CheckFontPicker();
	oBinaryWriter.m_pCommon->m_pNativePicker->Init(m_strFontDirectory);

	OOX::CPath pathDstFileOutput = bsOutput;
	
	OOX::CPath pathMedia = pathDstFileOutput.GetDirectory() + FILE_SEPARATOR_STR + _T("media");

	m_strMediaDirectory = pathMedia.GetPath();
	oBinaryWriter.m_strMainFolder = pathDstFileOutput.GetDirectory();

 	oBinaryWriter.m_pCommon->m_pMediaManager->m_strDstMedia = m_strMediaDirectory;
	oBinaryWriter.m_pCommon->m_pMediaManager->SetFontManager(oBinaryWriter.m_pCommon->m_pNativePicker->m_pFontManager);

    NSDirectory::CreateDirectory(m_strMediaDirectory);

    if (!m_strEmbeddedFontsDirectory.empty())
	{
        NSDirectory::CreateDirectory(m_strEmbeddedFontsDirectory);

		if (NULL != oBinaryWriter.m_pCommon->m_pFontPicker)
		{
            oBinaryWriter.m_pCommon->m_pNativePicker->m_bIsEmbeddedFonts = true;
			oBinaryWriter.m_pCommon->m_pNativePicker->m_oEmbeddedFonts.m_strEmbeddedFontsFolder = m_strEmbeddedFontsDirectory;
		}
	}

	PPTX2EditorAdvanced::Convert(oBinaryWriter, *m_pPptxDocument, m_strDirectory, pathDstFileOutput.GetPath(), m_bIsNoBase64);

	return S_OK;
}
Beispiel #2
0
	long Document::CountFiles(const OOX::CPath& path)
	{
		return OOX::CSystemUtility::GetFilesCount(path.GetDirectory(), true);
	}