示例#1
0
std::wstring RtfOle::RenderToOOXOnlyOle(RenderParameter oRenderParameter)
{
    std::wstring sResult;

	OOXWriter		* poOOXWriter	= static_cast<OOXWriter*>		(oRenderParameter.poWriter);
	OOXRelsWriter	* poRelsWriter	= static_cast<OOXRelsWriter*>	(oRenderParameter.poRels);
	RtfDocument		* poDocument	= static_cast<RtfDocument*>		(oRenderParameter.poDocument);

	sResult += L"<o:OLEObject";
	switch ( m_eOleType )
	{
		case ot_link:	sResult += L" Type=\"Link\"";	break;
		default: 		sResult += L" Type=\"Embed\"";	break;
	}
    sResult += L" ProgID=\"" + m_sOleClass + L"\"";
    sResult += L" ShapeID=\"_x0000_s" + std::to_wstring(poDocument->GetShapeId( oRenderParameter.nValue )) + L"\"";
	sResult += L" DrawAspect=\"Content\"";
    sResult += L" ObjectID=\"" + poDocument->m_oIdGenerator.Generate_OleId() + L"\"";

    std::wstring sExtension	= L"bin";
    std::wstring sMime		= L"application/vnd.openxmlformats-officedocument.oleObject";
	
    std::wstring sFilenameRels;
    sFilenameRels += L"oleObject" + std::to_wstring(poDocument->m_oIdGenerator.Generate_OleIndex()) + L".";
	sFilenameRels += sExtension;
	
    std::wstring sFilenameFull = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"embeddings";
	
    NSDirectory::CreateDirectory( sFilenameFull );
	
	sFilenameFull += FILE_SEPARATOR_STR + sFilenameRels;
	sFilenameRels = L"embeddings/" + sFilenameRels;

	Utils::CopyDirOrFile( m_sOleFilename, sFilenameFull );

	poOOXWriter->m_oContentTypes.AddExtension( sMime, sExtension);
    std::wstring srId = poRelsWriter->AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject", sFilenameRels);
    
	sResult += L" r:id=\"" + srId + L"\"";
	sResult += L"/>";
	return sResult;
}
示例#2
0
CString RtfOle::RenderToOOXOnlyOle(RenderParameter oRenderParameter)
{
	CString sResult;

	OOXWriter* poOOXWriter			= static_cast<OOXWriter*>(oRenderParameter.poWriter);
	OOXRelsWriter* poRelsWriter		= static_cast<OOXRelsWriter*>(oRenderParameter.poRels);
	RtfDocument* poDocument			= static_cast<RtfDocument*>(oRenderParameter.poDocument);

	sResult.Append( _T("<o:OLEObject") );
	switch ( m_eOleType )
	{
		case ot_link: sResult.Append( _T(" Type=\"Link\"") );break;
		default: sResult.Append( _T(" Type=\"Embed\"") );break;
	}
    sResult.AppendFormat( _T(" ProgID=\"%ls\""), m_sOleClass.GetBuffer() );
    sResult.AppendFormat( _T(" ShapeID=\"_x0000_s%d\""), poDocument->GetShapeId( oRenderParameter.nValue ) );
	sResult.Append( _T(" DrawAspect=\"Content\"") );
    sResult.AppendFormat( _T(" ObjectID=\"%ls\""), poDocument->m_oIdGenerator.Generate_OleId().GetBuffer() );

	CString sExtension = _T("bin");
	CString sMime = _T("application/vnd.openxmlformats-officedocument.oleObject");
	
	CString sFilenameRels;
    sFilenameRels.AppendFormat( _T("oleObject%d.%ls"), poDocument->m_oIdGenerator.Generate_OleIndex(), sExtension.GetBuffer());
	
	CString sFilenameFull = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("embeddings");
	
	FileSystem::Directory::CreateDirectory( sFilenameFull );
	
	sFilenameFull += FILE_SEPARATOR_STR + sFilenameRels;
	sFilenameRels = _T("embeddings/") + sFilenameRels;

	Utils::CopyDirOrFile( m_sOleFilename, sFilenameFull );

	poOOXWriter->m_oContentTypes.AddExtension( sMime, sExtension);
    CString srId = poRelsWriter->AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"), sFilenameRels);
    sResult.AppendFormat( _T(" r:id=\"%ls\""), srId.GetBuffer() );
	sResult.Append( _T("/>") );
	return sResult;
}