Commit 846caf6b authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

DocFormat - embedded docx elements as docx (xml) parts

parent 854b70ae
...@@ -28,6 +28,8 @@ namespace OpenXmlContentTypes ...@@ -28,6 +28,8 @@ namespace OpenXmlContentTypes
static const TCHAR* Vml = _T("application/vnd.openxmlformats-officedocument.vmlDrawing"); static const TCHAR* Vml = _T("application/vnd.openxmlformats-officedocument.vmlDrawing");
static const TCHAR* Drawing = _T("application/vnd.openxmlformats-officedocument.drawing+xml"); 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* MSExcel = _T("application/vnd.ms-excel");
static const TCHAR* MSWord = _T("application/msword"); static const TCHAR* MSWord = _T("application/msword");
static const TCHAR* MSPowerpoint = _T("application/vnd.ms-powerpoint"); static const TCHAR* MSPowerpoint = _T("application/vnd.ms-powerpoint");
...@@ -124,6 +126,7 @@ namespace OpenXmlRelationshipTypes ...@@ -124,6 +126,7 @@ namespace OpenXmlRelationshipTypes
static const TCHAR* Image = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"); 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* 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* 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 namespace MicrosoftWordRelationshipTypes
......
...@@ -35,7 +35,9 @@ namespace DocFileFormat ...@@ -35,7 +35,9 @@ namespace DocFileFormat
//type //type
if ( ole->fLinked ) 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( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Link" ) ); m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Link" ) );
...@@ -43,7 +45,11 @@ namespace DocFileFormat ...@@ -43,7 +45,11 @@ namespace DocFileFormat
} }
else 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( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) ); m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) );
...@@ -86,7 +92,7 @@ namespace DocFileFormat ...@@ -86,7 +92,7 @@ namespace DocFileFormat
{ {
objectExt = _T( ".ppt" ); objectExt = _T( ".ppt" );
} }
else if ( objectType == _T( "MSWordDocx" ) )//??? else if ( objectType == _T( "MSWordDocx" ) )
{ {
objectExt = _T( ".docx" ); objectExt = _T( ".docx" );
} }
...@@ -113,7 +119,14 @@ namespace DocFileFormat ...@@ -113,7 +119,14 @@ namespace DocFileFormat
{ {
objectContentType = OpenXmlContentTypes::MSPowerpoint; objectContentType = OpenXmlContentTypes::MSPowerpoint;
} }
else if ( objectType == _T( "MSWordDocx" ) )
{
objectContentType = OpenXmlContentTypes::MSWordDocx;
}
else if ( objectType == _T( "Equation" ) )
{
objectContentType = OpenXmlContentTypes::Xml;
}
return objectContentType; return objectContentType;
} }
......
...@@ -364,7 +364,14 @@ namespace DocFileFormat ...@@ -364,7 +364,14 @@ namespace DocFileFormat
return AddPart( mapping, _T( "word" ), fileName, OleObjectMapping::GetContentType( objectType ), OpenXmlRelationshipTypes::OleObject ); 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) int OpenXmlPackage::RegisterExternalOLEObject(const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri)
{ {
std::wstring fullUri = std::wstring(_T("file:///")) + uri; std::wstring fullUri = std::wstring(_T("file:///")) + uri;
...@@ -377,8 +384,12 @@ namespace DocFileFormat ...@@ -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 ) 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 ) && if (( contentType != _T( "" ) ) &&
( contentType != OpenXmlContentTypes::MSExcel ) && ( contentType != OpenXmlContentTypes::MSWord ) && ( contentType != OpenXmlContentTypes::Xml ) &&
( contentType != OpenXmlContentTypes::MSWordDocx ) &&
( contentType != OpenXmlContentTypes::OleObject ) &&
( contentType != OpenXmlContentTypes::MSExcel ) &&
( contentType != OpenXmlContentTypes::MSWord ) &&
( contentType != OpenXmlContentTypes::MSPowerpoint ) ) ( contentType != OpenXmlContentTypes::MSPowerpoint ) )
{ {
std::wstring partOverride; std::wstring partOverride;
......
...@@ -147,6 +147,7 @@ namespace DocFileFormat ...@@ -147,6 +147,7 @@ namespace DocFileFormat
int RegisterComments(); int RegisterComments();
int RegisterImage( const IMapping* mapping, Global::BlipType blipType ); int RegisterImage( const IMapping* mapping, Global::BlipType blipType );
int RegisterOLEObject( const IMapping* mapping, const wstring& objectType ); 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 ); int RegisterExternalOLEObject( const IMapping* mapping, const wstring& objectType, const wstring& uri );
}; };
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment