mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
DocFormat - embedded docx elements as docx (xml) parts
This commit is contained in:
committed by
Alexander Trofimov
parent
854b70ae81
commit
846caf6bcf
@ -27,6 +27,8 @@ namespace OpenXmlContentTypes
|
||||
static const TCHAR* OleObject = _T("application/vnd.openxmlformats-officedocument.oleObject");
|
||||
static const TCHAR* Vml = _T("application/vnd.openxmlformats-officedocument.vmlDrawing");
|
||||
static const TCHAR* Drawing = _T("application/vnd.openxmlformats-officedocument.drawing+xml");
|
||||
|
||||
static const TCHAR* MSWordDocx = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
|
||||
static const TCHAR* MSExcel = _T("application/vnd.ms-excel");
|
||||
static const TCHAR* MSWord = _T("application/msword");
|
||||
@ -124,6 +126,7 @@ namespace OpenXmlRelationshipTypes
|
||||
static const TCHAR* Image = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
|
||||
static const TCHAR* OleObject = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
|
||||
static const TCHAR* GlossaryDocument = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument");
|
||||
static const TCHAR* Package = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
|
||||
}
|
||||
|
||||
namespace MicrosoftWordRelationshipTypes
|
||||
|
||||
@ -35,7 +35,9 @@ namespace DocFileFormat
|
||||
//type
|
||||
if ( ole->fLinked )
|
||||
{
|
||||
int relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
|
||||
int relID = -1;
|
||||
|
||||
m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
|
||||
|
||||
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
|
||||
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Link" ) );
|
||||
@ -43,7 +45,11 @@ namespace DocFileFormat
|
||||
}
|
||||
else
|
||||
{
|
||||
int relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat);
|
||||
int relID = -1;
|
||||
if (ole->isEquation || ole->isEmbedded)
|
||||
relID = m_context->_docx->RegisterPackage(_caller, ole->ClipboardFormat);
|
||||
else
|
||||
relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat);
|
||||
|
||||
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
|
||||
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) );
|
||||
@ -86,7 +92,7 @@ namespace DocFileFormat
|
||||
{
|
||||
objectExt = _T( ".ppt" );
|
||||
}
|
||||
else if ( objectType == _T( "MSWordDocx" ) )//???
|
||||
else if ( objectType == _T( "MSWordDocx" ) )
|
||||
{
|
||||
objectExt = _T( ".docx" );
|
||||
}
|
||||
@ -113,7 +119,14 @@ namespace DocFileFormat
|
||||
{
|
||||
objectContentType = OpenXmlContentTypes::MSPowerpoint;
|
||||
}
|
||||
|
||||
else if ( objectType == _T( "MSWordDocx" ) )
|
||||
{
|
||||
objectContentType = OpenXmlContentTypes::MSWordDocx;
|
||||
}
|
||||
else if ( objectType == _T( "Equation" ) )
|
||||
{
|
||||
objectContentType = OpenXmlContentTypes::Xml;
|
||||
}
|
||||
return objectContentType;
|
||||
}
|
||||
|
||||
|
||||
@ -364,7 +364,14 @@ namespace DocFileFormat
|
||||
|
||||
return AddPart( mapping, _T( "word" ), fileName, OleObjectMapping::GetContentType( objectType ), OpenXmlRelationshipTypes::OleObject );
|
||||
}
|
||||
int OpenXmlPackage::RegisterPackage(const IMapping* mapping, const std::wstring& objectType)
|
||||
{
|
||||
std::wstring fileName = ( std::wstring( _T( "embeddings/oleObject" ) ) + FormatUtils::IntToWideString( ++_oleCounter ) + OleObjectMapping::GetTargetExt(objectType));
|
||||
|
||||
DocumentContentTypesFile._defaultTypes.insert( make_pair( OleObjectMapping::GetTargetExt( objectType ).erase( 0, 1 ), OleObjectMapping::GetContentType(objectType)));
|
||||
|
||||
return AddPart( mapping, _T( "word" ), fileName, OleObjectMapping::GetContentType( objectType ), OpenXmlRelationshipTypes::Package);
|
||||
}
|
||||
int OpenXmlPackage::RegisterExternalOLEObject(const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri)
|
||||
{
|
||||
std::wstring fullUri = std::wstring(_T("file:///")) + uri;
|
||||
@ -377,8 +384,12 @@ namespace DocFileFormat
|
||||
|
||||
int OpenXmlPackage::AddPart( const std::wstring& packageDir, const std::wstring& fileName, const std::wstring& contentType, const std::wstring& relationshipType, const std::wstring& targetMode )
|
||||
{
|
||||
if ( ( contentType != _T( "" ) ) && ( contentType != OpenXmlContentTypes::OleObject ) &&
|
||||
( contentType != OpenXmlContentTypes::MSExcel ) && ( contentType != OpenXmlContentTypes::MSWord ) &&
|
||||
if (( contentType != _T( "" ) ) &&
|
||||
( contentType != OpenXmlContentTypes::Xml ) &&
|
||||
( contentType != OpenXmlContentTypes::MSWordDocx ) &&
|
||||
( contentType != OpenXmlContentTypes::OleObject ) &&
|
||||
( contentType != OpenXmlContentTypes::MSExcel ) &&
|
||||
( contentType != OpenXmlContentTypes::MSWord ) &&
|
||||
( contentType != OpenXmlContentTypes::MSPowerpoint ) )
|
||||
{
|
||||
std::wstring partOverride;
|
||||
|
||||
@ -147,6 +147,7 @@ namespace DocFileFormat
|
||||
int RegisterComments();
|
||||
int RegisterImage( const IMapping* mapping, Global::BlipType blipType );
|
||||
int RegisterOLEObject( const IMapping* mapping, const wstring& objectType );
|
||||
int RegisterPackage(const IMapping* mapping, const std::wstring& objectType);
|
||||
int RegisterExternalOLEObject( const IMapping* mapping, const wstring& objectType, const wstring& uri );
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user