Commit 8f373ca6 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

ole обьекты копируются при открытии и сохранении в неизменном виде.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62642 954022d7-b5bf-4e40-9824-e11837661b57
parent c5657cec
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace Writers namespace Writers
{ {
static CString g_string_ct_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">"); static CString g_string_ct_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
static CString g_string_ct_Ext = _T("<Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/>"); static CString g_string_ct_Ext = _T("<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\"/><Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/>");
static CString g_string_ct_Override = _T("<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>"); static CString g_string_ct_Override = _T("<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>");
static CString g_string_ct_End = _T("</Types>"); static CString g_string_ct_End = _T("</Types>");
......
...@@ -54,10 +54,11 @@ bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const CString& sSrcFileName, ...@@ -54,10 +54,11 @@ bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const CString& sSrcFileName,
{ {
CString sMediaPath; CString sMediaPath;
CString sThemePath; CString sThemePath;
CString sEmbedPath;
CreateDocxFolders(std_string2string(strDirDst), sThemePath, sMediaPath); CreateDocxFolders(std_string2string(strDirDst), sThemePath, sMediaPath, sEmbedPath);
if(loadFromFile(sEditorBin, std_string2string(strDirDst), sXMLOptions, sThemePath, sMediaPath)) if(loadFromFile(sEditorBin, std_string2string(strDirDst), sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{ {
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1)) if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1))
return true; return true;
...@@ -137,7 +138,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C ...@@ -137,7 +138,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
RELEASEOBJECT(pFontPicker); RELEASEOBJECT(pFontPicker);
return true; return true;
} }
void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString& sThemePath, CString& sMediaPath) void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString& sThemePath, CString& sMediaPath, CString& sEmbedPath)
{ {
// rels // rels
OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels"); OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels");
...@@ -153,8 +154,14 @@ void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString ...@@ -153,8 +154,14 @@ void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString
//media //media
OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T("media"); OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T("media");
FileSystem::Directory::CreateDirectory(pathMedia.GetPath());
sMediaPath = pathMedia.GetPath(); sMediaPath = pathMedia.GetPath();
//embeddings
OOX::CPath pathEmbeddings = pathWord + FILE_SEPARATOR_STR + _T("embeddings");
FileSystem::Directory::CreateDirectory(pathEmbeddings.GetPath());
sEmbedPath = pathEmbeddings.GetPath();
// theme // theme
OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme"); OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme");
FileSystem::Directory::CreateDirectory(pathTheme.GetPath()); FileSystem::Directory::CreateDirectory(pathTheme.GetPath());
...@@ -165,7 +172,7 @@ void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString ...@@ -165,7 +172,7 @@ void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString
pathTheme = pathTheme + FILE_SEPARATOR_STR + _T("theme1.xml"); pathTheme = pathTheme + FILE_SEPARATOR_STR + _T("theme1.xml");
sThemePath = pathTheme.GetPath(); sThemePath = pathTheme.GetPath();
} }
bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sThemePath, const CString& sMediaPath) bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sThemePath, const CString& sMediaPath, const CString& sEmbedPath)
{ {
bool bResultOk = false; bool bResultOk = false;
...@@ -240,6 +247,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const ...@@ -240,6 +247,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
} }
oDrawingConverter.SetMainDocument(this); oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetMediaDstPath(sMediaPath); oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath); m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//папка с картинками //папка с картинками
......
...@@ -34,10 +34,10 @@ namespace BinDocxRW ...@@ -34,10 +34,10 @@ namespace BinDocxRW
bool ConvertDocxToDoct(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions); bool ConvertDocxToDoct(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions);
bool ConvertDoctToDocx(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions); bool ConvertDoctToDocx(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions);
bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sThemePath, const CString& sMediaPath); bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sThemePath, const CString& sMediaPath, const CString& sEmbedPath);
bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions); bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions);
void CreateDocxFolders(CString strDirectory, CString& sThemePath, CString& sMediaPath); void CreateDocxFolders(CString strDirectory, CString& sThemePath, CString& sMediaPath, CString& sEmbedPath);
bool getXmlContent(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sOutputXml); bool getXmlContent(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sOutputXml);
bool getBinaryContent(const CString& bsTxContent, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize); bool getBinaryContent(const CString& bsTxContent, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
......
...@@ -20,9 +20,10 @@ namespace BinXlsxRW{ ...@@ -20,9 +20,10 @@ namespace BinXlsxRW{
{ {
} }
void CXlsxSerializer::CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath) void CXlsxSerializer::CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath, CString& sEmbedPath)
{ {
OOX::CPath pathMediaDir = sDstPath + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("media"); OOX::CPath pathMediaDir = sDstPath + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("media");
OOX::CPath pathEmbedDir = sDstPath + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("embeddings");
// File Type ( , , ReadFile , ) // File Type ( , , ReadFile , )
BYTE fileType; BYTE fileType;
...@@ -45,6 +46,7 @@ namespace BinXlsxRW{ ...@@ -45,6 +46,7 @@ namespace BinXlsxRW{
NSDirectory::CreateDirectory(string2std_string(pathThemeDir.GetPath())); NSDirectory::CreateDirectory(string2std_string(pathThemeDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathThemeThemeRelsDir.GetPath())); NSDirectory::CreateDirectory(string2std_string(pathThemeThemeRelsDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathMediaDir.GetPath())); NSDirectory::CreateDirectory(string2std_string(pathMediaDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathEmbedDir.GetPath()));
//Create Default Theme //Create Default Theme
{ {
...@@ -54,11 +56,13 @@ namespace BinXlsxRW{ ...@@ -54,11 +56,13 @@ namespace BinXlsxRW{
} }
sMediaPath = pathMediaDir.GetPath(); sMediaPath = pathMediaDir.GetPath();
sEmbedPath = pathEmbedDir.GetPath();
} }
bool CXlsxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, CString& sMediaDir) bool CXlsxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sMediaDir, const CString& sEmbedDir)
{ {
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter; NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter;
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir); oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir);
// //
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName)); std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName));
......
...@@ -26,9 +26,9 @@ namespace BinXlsxRW { ...@@ -26,9 +26,9 @@ namespace BinXlsxRW {
CXlsxSerializer(); CXlsxSerializer();
~CXlsxSerializer(); ~CXlsxSerializer();
void CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath); void CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath, CString& sEmbedPath);
bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, CString& sMediaDir); bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sMediaDir, const CString& sEmbedPath);
bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, CString& sXMLOptions); bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, CString& sXMLOptions);
bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize); bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
......
...@@ -134,9 +134,10 @@ public: ...@@ -134,9 +134,10 @@ public:
CString sDirectoryOut = bstrDirectoryOut; CString sDirectoryOut = bstrDirectoryOut;
CString sThemePath; CString sThemePath;
CString sMediaPath; CString sMediaPath;
CString sEmbedPath;
m_oCDocxSerializer.CreateDocxFolders(sDirectoryOut, sThemePath, sMediaPath); m_oCDocxSerializer.CreateDocxFolders(sDirectoryOut, sThemePath, sMediaPath, sEmbedPath);
bool bRes = m_oCDocxSerializer.loadFromFile(CString(bstrFileIn), CString(bstrDirectoryOut), CString(_T("")), CString(sThemePath.GetString()), CString(sMediaPath.GetString())); bool bRes = m_oCDocxSerializer.loadFromFile(CString(bstrFileIn), CString(bstrDirectoryOut), CString(_T("")), CString(sThemePath.GetString()), CString(sMediaPath.GetString()), sEmbedPath);
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
......
...@@ -60,10 +60,11 @@ public: ...@@ -60,10 +60,11 @@ public:
{ {
CString sDstPath = bstrDstPath; CString sDstPath = bstrDstPath;
CString sMediaPath; CString sMediaPath;
CString sEmbedPath;
m_oXlsxSerializer.CreateXlsxFolders(CString(bstrXMLOptions), sDstPath, sMediaPath); m_oXlsxSerializer.CreateXlsxFolders(CString(bstrXMLOptions), sDstPath, sMediaPath, sEmbedPath);
bool bRes = m_oXlsxSerializer.loadFromFile(CString(sSrcFileName), sDstPath, CString(bstrXMLOptions), sMediaPath); bool bRes = m_oXlsxSerializer.loadFromFile(CString(sSrcFileName), sDstPath, CString(bstrXMLOptions), sMediaPath, sEmbedPath);
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
STDMETHOD(SaveToFile)(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions) STDMETHOD(SaveToFile)(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions)
......
...@@ -854,6 +854,17 @@ HRESULT CDrawingConverter::SetMediaDstPath(const CString& bsMediaPath) ...@@ -854,6 +854,17 @@ HRESULT CDrawingConverter::SetMediaDstPath(const CString& bsMediaPath)
#endif #endif
return S_OK; return S_OK;
} }
HRESULT CDrawingConverter::SetEmbedDstPath(const CString& bsEmbedPath)
{
m_pImageManager->SetDstEmbed(bsEmbedPath);
#if defined(_WIN32) || defined (_WIN64)
CreateDirectory(bsEmbedPath, NULL);
#else
FileSystem::Directory::CreateDirectory(bsEmbedPath);
#endif
return S_OK;
}
HRESULT CDrawingConverter::AddShapeType(const CString& bsXml) HRESULT CDrawingConverter::AddShapeType(const CString& bsXml)
{ {
CString strXml = _T("<main "); CString strXml = _T("<main ");
...@@ -1180,7 +1191,8 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt ...@@ -1180,7 +1191,8 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
{ {
LONG lChildsCount = oChilds.GetCount(); LONG lChildsCount = oChilds.GetCount();
bool bIsFound = false; bool bIsFound = false;
PPTX::Logic::SpTreeElem* pElem = NULL;
OOX::VmlOffice::COLEObject* pOle = NULL;
for (LONG k = 0; k < lChildsCount; k++) for (LONG k = 0; k < lChildsCount; k++)
{ {
XmlUtils::CXmlNode oNodeP; XmlUtils::CXmlNode oNodeP;
...@@ -1194,32 +1206,38 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt ...@@ -1194,32 +1206,38 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
_T("roundrect") == strNameP || _T("roundrect") == strNameP ||
_T("polyline") == strNameP) _T("polyline") == strNameP)
{ {
PPTX::Logic::SpTreeElem oElem = doc_LoadShape(oNodeP, pMainProps, true); if(NULL == pElem)
m_pBinaryWriter->WriteRecord1(1, oElem); {
pElem = new PPTX::Logic::SpTreeElem;
bIsFound = true; *pElem = doc_LoadShape(oNodeP, pMainProps, true);
#ifdef AVS_OFFICE_DRAWING_DUMP_XML_TEST #ifdef AVS_OFFICE_DRAWING_DUMP_XML_TEST
NSBinPptxRW::CXmlWriter oXmlW; NSBinPptxRW::CXmlWriter oXmlW;
oElem.toXmlWriter(&oXmlW); pElem->toXmlWriter(&oXmlW);
oXmlW.m_lDocType = XMLWRITER_DOC_TYPE_DOCX; oXmlW.m_lDocType = XMLWRITER_DOC_TYPE_DOCX;
CString strXmlTemp = oXmlW.GetXmlString(); CString strXmlTemp = oXmlW.GetXmlString();
#endif #endif
} }
}
else if (_T("OLEObject") == strNameP)
{
pOle = new OOX::VmlOffice::COLEObject( oNodeP );
}
else if (_T("group") == strNameP) else if (_T("group") == strNameP)
{ {
PPTX::Logic::SpTreeElem oElem = doc_LoadGroup(oNodeP, pMainProps, true); if(NULL == pElem)
m_pBinaryWriter->WriteRecord1(1, oElem); {
pElem = new PPTX::Logic::SpTreeElem;
bIsFound = true; *pElem = doc_LoadGroup(oNodeP, pMainProps, true);
#ifdef AVS_OFFICE_DRAWING_DUMP_XML_TEST #ifdef AVS_OFFICE_DRAWING_DUMP_XML_TEST
NSBinPptxRW::CXmlWriter oXmlW; NSBinPptxRW::CXmlWriter oXmlW;
oXmlW.m_lDocType = XMLWRITER_DOC_TYPE_DOCX; oXmlW.m_lDocType = XMLWRITER_DOC_TYPE_DOCX;
oElem.toXmlWriter(&oXmlW); pElem->toXmlWriter(&oXmlW);
CString strXmlTemp = oXmlW.GetXmlString(); CString strXmlTemp = oXmlW.GetXmlString();
#endif #endif
} }
}
else if (_T("shapetype") == strNameP) else if (_T("shapetype") == strNameP)
{ {
AddShapeType(oNodeP.GetXml()); AddShapeType(oNodeP.GetXml());
...@@ -1232,6 +1250,33 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt ...@@ -1232,6 +1250,33 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
if (bIsFound) if (bIsFound)
break; break;
} }
if(NULL != pElem)
{
if(NULL != pOle && pOle->m_oId.IsInit() && pOle->m_sProgId.IsInit())
{
PPTX::Logic::Shape* pShape = dynamic_cast<PPTX::Logic::Shape*>(pElem->GetElem().operator ->());
if(NULL != pShape && pShape->spPr.Fill.Fill.IsInit())
{
const PPTX::Logic::BlipFill& oBlipFill = pShape->spPr.Fill.Fill.as<PPTX::Logic::BlipFill>();
if(oBlipFill.blip.IsInit())
{
int dxaOrig = 0;
int dyaOrig = 0;
if(strName == _T("object"))
{
dxaOrig = oParseNode.ReadAttributeInt(_T("w:dxaOrig"));
dyaOrig = oParseNode.ReadAttributeInt(_T("w:dyaOrig"));
}
oBlipFill.blip->oleInfo.Init();
oBlipFill.blip->oleInfo->m_sOleProperty.Format(_T("%d|%d|%s"), dxaOrig, dyaOrig, pOle->m_sProgId.get());
oBlipFill.blip->oleInfo->m_sRid = pOle->m_oId->GetValue();
}
}
}
m_pBinaryWriter->WriteRecord1(1, *pElem);
}
RELEASEOBJECT(pElem)
RELEASEOBJECT(pOle)
} }
break; break;
...@@ -3310,11 +3355,24 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString& ...@@ -3310,11 +3355,24 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString&
m_pReader->m_lDocumentType = XMLWRITER_DOC_TYPE_DOCX; m_pReader->m_lDocumentType = XMLWRITER_DOC_TYPE_DOCX;
oElem.fromPPTY(m_pReader); oElem.fromPPTY(m_pReader);
bool bOle = false;
if (oElem.is<PPTX::Logic::Shape>())
{
PPTX::Logic::Shape& oShape = oElem.as<PPTX::Logic::Shape>();
if(oShape.spPr.Fill.Fill.is<PPTX::Logic::BlipFill>())
{
PPTX::Logic::BlipFill& oBlipFill = oShape.spPr.Fill.Fill.as<PPTX::Logic::BlipFill>();
if(oBlipFill.blip.IsInit() && oBlipFill.blip->oleInfo.IsInit())
bOle = true;
}
}
m_pReader->m_lDocumentType = XMLWRITER_DOC_TYPE_PPTX; m_pReader->m_lDocumentType = XMLWRITER_DOC_TYPE_PPTX;
NSBinPptxRW::CXmlWriter oXmlWriter; NSBinPptxRW::CXmlWriter oXmlWriter;
oXmlWriter.m_lObjectIdVML = m_pXmlWriter->m_lObjectIdVML;
oXmlWriter.m_lObjectIdOle = m_pXmlWriter->m_lObjectIdOle;
oXmlWriter.m_lDocType = XMLWRITER_DOC_TYPE_DOCX; oXmlWriter.m_lDocType = XMLWRITER_DOC_TYPE_DOCX;
oXmlWriter.m_bIsUseOffice2007 = m_bIsUseConvertion2007; oXmlWriter.m_bIsUseOffice2007 = m_bIsUseConvertion2007;
...@@ -3325,9 +3383,18 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString& ...@@ -3325,9 +3383,18 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString&
m_pOOXToVMLRenderer = new COOXToVMLGeometry(); m_pOOXToVMLRenderer = new COOXToVMLGeometry();
oXmlWriter.m_pOOXToVMLRenderer = m_pOOXToVMLRenderer; oXmlWriter.m_pOOXToVMLRenderer = m_pOOXToVMLRenderer;
#endif #endif
if(bOle)
{
if (oElem.is<PPTX::Logic::Shape>())
{
ConvertShapeVML(oElem, bsMainProps, oXmlWriter);
}
}
else
{
bool bIsNeedConvert2007 = false; bool bIsNeedConvert2007 = false;
#ifdef BUILD_CONFIG_FULL_VERSION #ifdef BUILD_CONFIG_FULL_VERSION
if (m_bIsUseConvertion2007) if (m_bIsUseConvertion2007)
{ {
if (oElem.is<PPTX::Logic::SpTree>()) if (oElem.is<PPTX::Logic::SpTree>())
...@@ -3341,7 +3408,7 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString& ...@@ -3341,7 +3408,7 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString&
bIsNeedConvert2007 = true; bIsNeedConvert2007 = true;
} }
} }
#endif #endif
oXmlWriter.WriteString(_T("<w:drawing>")); oXmlWriter.WriteString(_T("<w:drawing>"));
oXmlWriter.WriteString(strMainProps); oXmlWriter.WriteString(strMainProps);
...@@ -3349,21 +3416,21 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString& ...@@ -3349,21 +3416,21 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString&
if (oElem.is<PPTX::Logic::SpTree>()) if (oElem.is<PPTX::Logic::SpTree>())
{ {
oXmlWriter.WriteString(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\ oXmlWriter.WriteString(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\">")); <a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\">"));
} }
else if (oElem.is<PPTX::Logic::Pic>()) else if (oElem.is<PPTX::Logic::Pic>())
{ {
oXmlWriter.WriteString(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\ oXmlWriter.WriteString(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">")); <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"));
} }
else else
{ {
oXmlWriter.WriteString(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\ oXmlWriter.WriteString(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">")); <a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">"));
} }
oElem.toXmlWriter(&oXmlWriter); oElem.toXmlWriter(&oXmlWriter);
oXmlWriter.WriteString(_T("</a:graphicData>\ oXmlWriter.WriteString(_T("</a:graphicData>\
</a:graphic>")); </a:graphic>"));
oXmlWriter.WriteString(bIsInline ? _T("</wp:inline>") : _T("</wp:anchor>")); oXmlWriter.WriteString(bIsInline ? _T("</wp:inline>") : _T("</wp:anchor>"));
oXmlWriter.WriteString(_T("</w:drawing>")); oXmlWriter.WriteString(_T("</w:drawing>"));
...@@ -3383,9 +3450,12 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString& ...@@ -3383,9 +3450,12 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString&
oXmlWriter.WriteString(_T("</w:pict></mc:Fallback></mc:AlternateContent>")); oXmlWriter.WriteString(_T("</w:pict></mc:Fallback></mc:AlternateContent>"));
} }
}
--m_nCurrentIndexObject; --m_nCurrentIndexObject;
m_pXmlWriter->m_lObjectIdVML = oXmlWriter.m_lObjectIdVML;
m_pXmlWriter->m_lObjectIdOle = oXmlWriter.m_lObjectIdOle;
CString ret = oXmlWriter.GetXmlString(); CString ret = oXmlWriter.GetXmlString();
*bsXml = new CString(); *bsXml = new CString();
**bsXml = ret; **bsXml = ret;
...@@ -3428,6 +3498,8 @@ HRESULT CDrawingConverter::SaveObjectEx(LONG lStart, LONG lLength, const CString ...@@ -3428,6 +3498,8 @@ HRESULT CDrawingConverter::SaveObjectEx(LONG lStart, LONG lLength, const CString
m_pReader->m_lDocumentType = XMLWRITER_DOC_TYPE_PPTX; m_pReader->m_lDocumentType = XMLWRITER_DOC_TYPE_PPTX;
NSBinPptxRW::CXmlWriter oXmlWriter; NSBinPptxRW::CXmlWriter oXmlWriter;
oXmlWriter.m_lObjectIdVML = m_pXmlWriter->m_lObjectIdVML;
oXmlWriter.m_lObjectIdOle = m_pXmlWriter->m_lObjectIdOle;
oXmlWriter.m_lDocType = (BYTE)lDocType; oXmlWriter.m_lDocType = (BYTE)lDocType;
oXmlWriter.m_bIsUseOffice2007 = false; oXmlWriter.m_bIsUseOffice2007 = false;
...@@ -3437,6 +3509,9 @@ HRESULT CDrawingConverter::SaveObjectEx(LONG lStart, LONG lLength, const CString ...@@ -3437,6 +3509,9 @@ HRESULT CDrawingConverter::SaveObjectEx(LONG lStart, LONG lLength, const CString
--m_nCurrentIndexObject; --m_nCurrentIndexObject;
m_pXmlWriter->m_lObjectIdVML = oXmlWriter.m_lObjectIdVML;
m_pXmlWriter->m_lObjectIdOle = oXmlWriter.m_lObjectIdOle;
CString ret = oXmlWriter.GetXmlString(); CString ret = oXmlWriter.GetXmlString();
*bsXml = new CString(); *bsXml = new CString();
**bsXml = ret; **bsXml = ret;
......
...@@ -184,6 +184,7 @@ namespace NSBinPptxRW ...@@ -184,6 +184,7 @@ namespace NSBinPptxRW
HRESULT SetRelsPath (const CString& bsRelsPath); HRESULT SetRelsPath (const CString& bsRelsPath);
CString GetRelsPath(); CString GetRelsPath();
HRESULT SetMediaDstPath (const CString& bsMediaPath); HRESULT SetMediaDstPath (const CString& bsMediaPath);
HRESULT SetEmbedDstPath (const CString& bsEmbedPath);
HRESULT AddShapeType(const CString& bsXml); HRESULT AddShapeType(const CString& bsXml);
HRESULT AddObject(const CString& bsXml, CString** pMainProps); HRESULT AddObject(const CString& bsXml, CString** pMainProps);
......
...@@ -50,7 +50,25 @@ namespace NSBinPptxRW ...@@ -50,7 +50,25 @@ namespace NSBinPptxRW
class CStringWriter; class CStringWriter;
class CCommonWriter; class CCommonWriter;
class CSeekTableEntry; class CSeekTableEntry;
class CImageManager2Info
{
public:
CString m_sImagePath;
CString m_sOlePath;
CString m_sOleProperty;
};
class CRelsGeneratorInfo
{
public:
int m_nImageRId;
int m_nOleRId;
CString m_sOleProperty;
CRelsGeneratorInfo()
{
m_nImageRId = -1;
m_nOleRId = -1;
}
};
class CMasterSlideInfo class CMasterSlideInfo
{ {
public: public:
...@@ -97,10 +115,11 @@ namespace NSBinPptxRW ...@@ -97,10 +115,11 @@ namespace NSBinPptxRW
class CImageManager2 class CImageManager2
{ {
private: private:
std::map<CString, CString> m_mapImages; std::map<CString, CImageManager2Info> m_mapImages;
_INT32 m_lIndexNextImage; _INT32 m_lIndexNextImage;
_INT32 m_lIndexNextOle;
CString m_strDstMedia; CString m_strDstMedia;
CString m_strDstEmbed;
public: public:
bool m_bIsWord; bool m_bIsWord;
...@@ -110,6 +129,9 @@ namespace NSBinPptxRW ...@@ -110,6 +129,9 @@ namespace NSBinPptxRW
void Clear(); void Clear();
void SetDstMedia(const CString& strDst); void SetDstMedia(const CString& strDst);
CString GetDstMedia(); CString GetDstMedia();
void SetDstEmbed(const CString& strDst);
CString GetDstEmbed();
int IsDisplayedImage(const CString& strInput);
public: public:
template <typename T> template <typename T>
...@@ -117,16 +139,17 @@ namespace NSBinPptxRW ...@@ -117,16 +139,17 @@ namespace NSBinPptxRW
{ {
pWriter->WriteBYTE(m_bIsWord ? 1 : 0); pWriter->WriteBYTE(m_bIsWord ? 1 : 0);
pWriter->WriteINT(m_lIndexNextImage); pWriter->WriteINT(m_lIndexNextImage);
pWriter->WriteINT(m_lIndexNextOle);
pWriter->WriteString(m_strDstMedia); pWriter->WriteString(m_strDstMedia);
int lCount = (int)m_mapImages.size(); int lCount = (int)m_mapImages.size();
pWriter->WriteINT(lCount); pWriter->WriteINT(lCount);
for (std::map<CString, CString>::const_iterator pPair = m_mapImages.begin(); pPair != m_mapImages.end(); ++pPair) //for (std::map<CString, CString>::const_iterator pPair = m_mapImages.begin(); pPair != m_mapImages.end(); ++pPair)
{ //{
pWriter->WriteString(pPair->first); // pWriter->WriteString(pPair->first);
pWriter->WriteString(pPair->second); // pWriter->WriteString(pPair->second);
} //}
} }
template <typename T> template <typename T>
...@@ -134,29 +157,32 @@ namespace NSBinPptxRW ...@@ -134,29 +157,32 @@ namespace NSBinPptxRW
{ {
m_bIsWord = ((true == pReader->GetBool()) ? true : false); m_bIsWord = ((true == pReader->GetBool()) ? true : false);
m_lIndexNextImage = pReader->GetLong(); m_lIndexNextImage = pReader->GetLong();
m_lIndexNextOle = pReader->GetLong();
m_strDstMedia = pReader->GetString2(); m_strDstMedia = pReader->GetString2();
m_mapImages.clear(); m_mapImages.clear();
_INT32 lCount = pReader->GetLong(); _INT32 lCount = pReader->GetLong();
for (_INT32 i = 0; i < lCount; ++i) //for (_INT32 i = 0; i < lCount; ++i)
{ //{
CString s1 = pReader->GetString2(); // CString s1 = pReader->GetString2();
CString s2 = pReader->GetString2(); // CString s2 = pReader->GetString2();
m_mapImages [s1] = s2; // m_mapImages [s1] = s2;
} //}
} }
public: public:
CString GenerateImage(const CString& strInput, CString strBase64Image = _T("")); CImageManager2Info GenerateImage(const CString& strInput, CString strBase64Image = _T(""));
CImageManager2Info GenerateImageExec(const CString& strInput, const CString& strExts, const CString& strOleImage, const CString& strOleImageProperty);
void SaveImageAsPng(const CString& strFileSrc, const CString& strFileDst); void SaveImageAsPng(const CString& strFileSrc, const CString& strFileDst);
void SaveImageAsJPG(const CString& strFileSrc, const CString& strFileDst); void SaveImageAsJPG(const CString& strFileSrc, const CString& strFileDst);
bool IsNeedDownload(const CString& strFile); bool IsNeedDownload(const CString& strFile);
CString DownloadImage(const CString& strFile); CImageManager2Info DownloadImage(const CString& strFile);
CString DownloadImageExec(const CString& strFile);
}; };
class CBinaryFileWriter class CBinaryFileWriter
...@@ -355,7 +381,7 @@ namespace NSBinPptxRW ...@@ -355,7 +381,7 @@ namespace NSBinPptxRW
private: private:
CStringWriter* m_pWriter; CStringWriter* m_pWriter;
int m_lNextRelsID; int m_lNextRelsID;
std::map<CString, int> m_mapImages; std::map<CString, CRelsGeneratorInfo> m_mapImages;
std::map<CString, int> m_mapLinks; std::map<CString, int> m_mapLinks;
...@@ -385,7 +411,7 @@ namespace NSBinPptxRW ...@@ -385,7 +411,7 @@ namespace NSBinPptxRW
void AddRels(const CString& strRels); void AddRels(const CString& strRels);
void SaveRels(const CString& strFile); void SaveRels(const CString& strFile);
int WriteImage(const CString& strImagePath, CString strBase64Image); CRelsGeneratorInfo WriteImage(const CString& strImagePath, CString strBase64Image);
int WriteChart(int nChartNumber, _INT32 lDocType); int WriteChart(int nChartNumber, _INT32 lDocType);
int WriteRels(const CString& bsType, const CString& bsTarget, const CString& bsTargetMode); int WriteRels(const CString& bsType, const CString& bsTarget, const CString& bsTargetMode);
......
...@@ -70,6 +70,11 @@ namespace NSBinPptxRW ...@@ -70,6 +70,11 @@ namespace NSBinPptxRW
m_oImageManager.SetDstMedia(pathMedia.GetPath()); m_oImageManager.SetDstMedia(pathMedia.GetPath());
OOX::CPath pathEmbeddings = pathPPT / _T("embeddings");
FileSystem::Directory::CreateDirectory(pathEmbeddings.GetPath());
m_oImageManager.SetDstEmbed(pathEmbeddings.GetPath());
m_oReader.m_pRels->m_pManager = &m_oImageManager; m_oReader.m_pRels->m_pManager = &m_oImageManager;
OOX::CPath pathTheme = pathPPT / _T("theme"); OOX::CPath pathTheme = pathPPT / _T("theme");
...@@ -700,6 +705,7 @@ namespace NSBinPptxRW ...@@ -700,6 +705,7 @@ namespace NSBinPptxRW
CStringWriter oContentTypes; CStringWriter oContentTypes;
oContentTypes.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\ oContentTypes.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\ <Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\"/>\
<Default Extension=\"png\" ContentType=\"image/png\" />\ <Default Extension=\"png\" ContentType=\"image/png\" />\
<Default Extension=\"jpeg\" ContentType=\"image/jpeg\" />\ <Default Extension=\"jpeg\" ContentType=\"image/jpeg\" />\
<Default Extension=\"wmf\" ContentType=\"image/x-wmf\" />\ <Default Extension=\"wmf\" ContentType=\"image/x-wmf\" />\
......
...@@ -249,7 +249,7 @@ namespace NSBinPptxRW ...@@ -249,7 +249,7 @@ namespace NSBinPptxRW
LONG m_lGroupIndex; LONG m_lGroupIndex;
LONG m_lObjectId; LONG m_lObjectId;
LONG m_lObjectIdVML; LONG m_lObjectIdVML;
LONG m_lObjectIdOle;
public: public:
bool m_bIsUseOffice2007; bool m_bIsUseOffice2007;
CString m_strStyleMain; CString m_strStyleMain;
...@@ -268,6 +268,7 @@ namespace NSBinPptxRW ...@@ -268,6 +268,7 @@ namespace NSBinPptxRW
m_lGroupIndex = 0; m_lGroupIndex = 0;
m_lObjectId = 0; m_lObjectId = 0;
m_lObjectIdVML = 0; m_lObjectIdVML = 0;
m_lObjectIdOle = 0;
m_bIsUseOffice2007 = false; m_bIsUseOffice2007 = false;
m_strStyleMain = _T(""); m_strStyleMain = _T("");
......
This diff is collapsed.
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "DocxFormat/Media/Image.h" #include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/Audio.h" #include "DocxFormat/Media/Audio.h"
#include "DocxFormat/Media/Video.h" #include "DocxFormat/Media/Video.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h" #include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/External/ExternalImage.h" #include "DocxFormat/External/ExternalImage.h"
#include "DocxFormat/External/ExternalAudio.h" #include "DocxFormat/External/ExternalAudio.h"
...@@ -95,6 +96,8 @@ namespace PPTX ...@@ -95,6 +96,8 @@ namespace PPTX
return smart_ptr<PPTX::File>(new PPTX::Authors(filename, map)); return smart_ptr<PPTX::File>(new PPTX::Authors(filename, map));
else if (relation.type() == PPTX::FileTypes::SlideComments) else if (relation.type() == PPTX::FileTypes::SlideComments)
return smart_ptr<PPTX::File>(new PPTX::Comments(filename, map)); return smart_ptr<PPTX::File>(new PPTX::Comments(filename, map));
else if (relation.type() == PPTX::FileTypes::OleObject)
return smart_ptr<PPTX::File>(new PPTX::OleObject(filename));
return smart_ptr<PPTX::File>(new PPTX::UnknowTypeFile()); return smart_ptr<PPTX::File>(new PPTX::UnknowTypeFile());
} }
...@@ -131,6 +134,9 @@ namespace PPTX ...@@ -131,6 +134,9 @@ namespace PPTX
else if(strT == PPTX::FileTypes::LegacyDiagramText) else if(strT == PPTX::FileTypes::LegacyDiagramText)
return smart_ptr<PPTX::File>(new PPTX::LegacyDiagramText(filename)); return smart_ptr<PPTX::File>(new PPTX::LegacyDiagramText(filename));
else if(strT == PPTX::FileTypes::OleObject)
return smart_ptr<PPTX::File>(new PPTX::OleObject(filename));
return smart_ptr<PPTX::File>(new PPTX::UnknowTypeFile()); return smart_ptr<PPTX::File>(new PPTX::UnknowTypeFile());
} }
......
...@@ -90,5 +90,24 @@ namespace PPTX ...@@ -90,5 +90,24 @@ namespace PPTX
} }
return _T(""); return _T("");
} }
CString Blip::GetFullOleName(const PPTX::RId& oRId, FileContainer* pRels)const
{
if (pRels != NULL)
{
smart_ptr<PPTX::OleObject> p = pRels->oleObject(oRId);
if (p.is_init())
return p->filename().m_strFilename;
}
if(parentFileIs<Slide>())
return parentFileAs<Slide>().GetOleFromRId(oRId);
else if(parentFileIs<SlideLayout>())
return parentFileAs<SlideLayout>().GetOleFromRId(oRId);
else if(parentFileIs<SlideMaster>())
return parentFileAs<SlideMaster>().GetOleFromRId(oRId);
else if(parentFileIs<Theme>())
return parentFileAs<Theme>().GetOleFromRId(oRId);
return _T("");
}
} // namespace Logic } // namespace Logic
} // namespace PPTX } // namespace PPTX
\ No newline at end of file
...@@ -99,7 +99,14 @@ namespace PPTX ...@@ -99,7 +99,14 @@ namespace PPTX
if (pWriter->m_pCommonRels->is_init()) if (pWriter->m_pCommonRels->is_init())
pRels = pWriter->m_pCommonRels->operator ->(); pRels = pWriter->m_pCommonRels->operator ->();
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(this->GetFullPicName(pRels), dX, dY, dW, dH); NSShapeImageGen::COleInfo* pOleInfo = NULL;
if(oleInfo.IsInit())
{
pOleInfo = oleInfo.GetPointer();
pOleInfo->m_sFilename = this->GetFullOleName(PPTX::RId(oleInfo->m_sRid), pRels);
}
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(this->GetFullPicName(pRels), pOleInfo, dX, dY, dW, dH);
CString s = oId.GetPath2(); CString s = oId.GetPath2();
pWriter->StartRecord(3); pWriter->StartRecord(3);
...@@ -112,6 +119,7 @@ namespace PPTX ...@@ -112,6 +119,7 @@ namespace PPTX
} }
public: public:
virtual CString GetFullPicName(FileContainer* pRels = NULL)const; virtual CString GetFullPicName(FileContainer* pRels = NULL)const;
virtual CString GetFullOleName(const PPTX::RId& pRId, FileContainer* pRels = NULL)const;
public: public:
std::vector<UniEffect> Effects; std::vector<UniEffect> Effects;
...@@ -121,6 +129,7 @@ namespace PPTX ...@@ -121,6 +129,7 @@ namespace PPTX
//private: //private:
public: public:
CString m_namespace; CString m_namespace;
nullable<NSShapeImageGen::COleInfo> oleInfo;
protected: protected:
virtual void FillParentPointersForChilds(); virtual void FillParentPointersForChilds();
}; };
......
...@@ -364,7 +364,7 @@ namespace PPTX ...@@ -364,7 +364,7 @@ namespace PPTX
strUrl = pathUrl.GetPath(); strUrl = pathUrl.GetPath();
} }
LONG lId = pReader->m_pRels->WriteImage(strUrl, strOrigBase64); NSBinPptxRW::CRelsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, strOrigBase64);
// ------------------- // -------------------
if (strTempFile != _T("")) if (strTempFile != _T(""))
...@@ -376,7 +376,14 @@ namespace PPTX ...@@ -376,7 +376,14 @@ namespace PPTX
if (!blip.is_init()) if (!blip.is_init())
blip = new PPTX::Logic::Blip(); blip = new PPTX::Logic::Blip();
blip->embed = new PPTX::RId((size_t)lId); blip->embed = new PPTX::RId((size_t)oRelsGeneratorInfo.m_nImageRId);
if(oRelsGeneratorInfo.m_nOleRId > 0)
{
blip->oleInfo.Init();
blip->oleInfo->m_sOleProperty = oRelsGeneratorInfo.m_sOleProperty;
blip->oleInfo->m_sRid = PPTX::RId((size_t)oRelsGeneratorInfo.m_nOleRId).get();
}
pReader->Skip(1); // end attribute pReader->Skip(1); // end attribute
break; break;
......
...@@ -374,6 +374,50 @@ namespace PPTX ...@@ -374,6 +374,50 @@ namespace PPTX
lW = spPr.xfrm->extX.get_value_or(43200); lW = spPr.xfrm->extX.get_value_or(43200);
lH = spPr.xfrm->extY.get_value_or(43200); lH = spPr.xfrm->extY.get_value_or(43200);
} }
NSShapeImageGen::COleInfo oOleInfo;
bool bOle = false;
CString sOleProgID;
CString sOleNodeName;
if(this->spPr.Fill.Fill.is<PPTX::Logic::BlipFill>())
{
PPTX::Logic::BlipFill& oBlipFill = this->spPr.Fill.Fill.as<PPTX::Logic::BlipFill>();
if(oBlipFill.blip.IsInit() && oBlipFill.blip->oleInfo.IsInit())
oOleInfo = oBlipFill.blip->oleInfo.get();
}
if(!oOleInfo.m_sRid.IsEmpty() && !oOleInfo.m_sOleProperty.IsEmpty())
{
std::vector<CString> aOleProp;
int nTokenPos = 0;
CString strToken = oOleInfo.m_sOleProperty.Tokenize(_T("|"), nTokenPos);
while (!strToken.IsEmpty())
{
aOleProp.push_back(strToken);
strToken = oOleInfo.m_sOleProperty.Tokenize(_T("|"), nTokenPos);
}
if(3 == aOleProp.size())
{
bOle = true;
CString dxaOrig = aOleProp[0];
CString dyaOrig = aOleProp[1];
sOleProgID = aOleProp[2];
if(_T("0") != dxaOrig && _T("0") != dyaOrig)
{
sOleNodeName = _T("w:object");
pWriter->StartNode(sOleNodeName);
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("w:dxaOrig"), dxaOrig);
pWriter->WriteAttribute(_T("w:dyaOrig"), dyaOrig);
pWriter->EndAttributes();
}
else
{
sOleNodeName = _T("w:pict");
pWriter->StartNode(sOleNodeName);
pWriter->StartAttributes();
pWriter->EndAttributes();
}
}
}
#ifdef AVS_USE_CONVERT_PPTX_TOCUSTOM_VML #ifdef AVS_USE_CONVERT_PPTX_TOCUSTOM_VML
spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH); spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH);
...@@ -389,7 +433,7 @@ namespace PPTX ...@@ -389,7 +433,7 @@ namespace PPTX
CString strStrokeAttr = _T(""); CString strStrokeAttr = _T("");
CString strFillNode = _T(""); CString strFillNode = _T("");
CString strStrokeNode = _T(""); CString strStrokeNode = _T("");
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode); CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, bOle);
CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode); CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode);
if (pWriter->m_strStyleMain != _T("")) if (pWriter->m_strStyleMain != _T(""))
...@@ -460,9 +504,11 @@ namespace PPTX ...@@ -460,9 +504,11 @@ namespace PPTX
{ {
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain + oStylesWriter.GetXmlString()); pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain + oStylesWriter.GetXmlString());
} }
if(!bOle)
{
pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000")); pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath); pWriter->WriteAttribute(_T("path"), strPath);
}
if (pWriter->m_strAttributesMain) if (pWriter->m_strAttributesMain)
{ {
...@@ -581,8 +627,12 @@ namespace PPTX ...@@ -581,8 +627,12 @@ namespace PPTX
pWriter->WriteAttribute(_T("o:spid"), strSpid); pWriter->WriteAttribute(_T("o:spid"), strSpid);
pWriter->WriteAttribute(_T("style"), oStylesWriter.GetXmlString()); pWriter->WriteAttribute(_T("style"), oStylesWriter.GetXmlString());
if(!bOle)
{
pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000")); pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath); pWriter->WriteAttribute(_T("path"), strPath);
}
if (pWriter->m_strAttributesMain) if (pWriter->m_strAttributesMain)
{ {
...@@ -614,6 +664,23 @@ namespace PPTX ...@@ -614,6 +664,23 @@ namespace PPTX
pWriter->EndNode(_T("v:shape")); pWriter->EndNode(_T("v:shape"));
} }
if(!sOleProgID.IsEmpty())
{
pWriter->StartNode(_T("o:OLEObject"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("Type"), CString(_T("Embed")));
pWriter->WriteAttribute(_T("ProgID"), sOleProgID);
pWriter->WriteAttribute(_T("ShapeID"), strId);
pWriter->WriteAttribute(_T("DrawAspect"), CString(_T("Content")));
CString sObjectID;
sObjectID.Format(_T("_%010d"), pWriter->m_lObjectIdOle++);
pWriter->WriteAttribute(_T("ObjectID"), sObjectID);
pWriter->WriteAttribute(_T("r:id"), oOleInfo.m_sRid);
pWriter->EndAttributes();
pWriter->EndNode(_T("o:OLEObject"));
pWriter->EndNode(sOleNodeName);
}
} }
} // namespace Logic } // namespace Logic
} // namespace PPTX } // namespace PPTX
\ No newline at end of file
...@@ -23,7 +23,7 @@ namespace PPTX ...@@ -23,7 +23,7 @@ namespace PPTX
return sC; return sC;
} }
void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap, CString& strAttr, CString& strNode) void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::WrapperFile>& _oTheme, NSCommon::smart_ptr<PPTX::WrapperWritingElement>& _oClrMap, CString& strAttr, CString& strNode, bool bOle)
{ {
smart_ptr<PPTX::Theme> oTheme = _oTheme.smart_dynamic_cast<PPTX::Theme>(); smart_ptr<PPTX::Theme> oTheme = _oTheme.smart_dynamic_cast<PPTX::Theme>();
smart_ptr<PPTX::Logic::ClrMap> oClrMap = _oClrMap.smart_dynamic_cast<PPTX::Logic::ClrMap>(); smart_ptr<PPTX::Logic::ClrMap> oClrMap = _oClrMap.smart_dynamic_cast<PPTX::Logic::ClrMap>();
...@@ -80,16 +80,12 @@ namespace PPTX ...@@ -80,16 +80,12 @@ namespace PPTX
CString strId = oBlip.blip->embed->ToString(); CString strId = oBlip.blip->embed->ToString();
if (!oBlip.srcRect.is_init()) if(bOle)
{ {
if (oBlip.tile.is_init()) strNode = _T("<v:imagedata r:id=\"") + strId + _T("\" o:title=\"\" />");
strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"tile\"") + fopacity + _T(" />");
else
strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"frame\"") + fopacity + _T(" />");
} }
else else
{ {
// crop
if (oBlip.tile.is_init()) if (oBlip.tile.is_init())
strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"tile\"") + fopacity + _T(" />"); strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"tile\"") + fopacity + _T(" />");
else else
......
...@@ -10,7 +10,7 @@ namespace PPTX ...@@ -10,7 +10,7 @@ namespace PPTX
{ {
namespace Logic namespace Logic
{ {
void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, CString& strAttr, CString& strNode); void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, CString& strAttr, CString& strNode, bool bOle);
void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, CString& strAttr, CString& strNode); void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::WrapperFile>& oTheme, smart_ptr<PPTX::WrapperWritingElement>& oClrMap, CString& strAttr, CString& strNode);
class SpTreeElem : public WrapperWritingElement class SpTreeElem : public WrapperWritingElement
......
...@@ -341,7 +341,7 @@ namespace PPTX ...@@ -341,7 +341,7 @@ namespace PPTX
} }
// ------------------- // -------------------
LONG lId = pReader->m_pRels->WriteImage(strUrl, strOrigBase64); NSBinPptxRW::CRelsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, strOrigBase64);
// ------------------- // -------------------
if (strTempFile != _T("")) if (strTempFile != _T(""))
...@@ -353,10 +353,17 @@ namespace PPTX ...@@ -353,10 +353,17 @@ namespace PPTX
if (!pFill->blip.is_init()) if (!pFill->blip.is_init())
pFill->blip = new PPTX::Logic::Blip(); pFill->blip = new PPTX::Logic::Blip();
pFill->blip->embed = new PPTX::RId((size_t)lId); pFill->blip->embed = new PPTX::RId((size_t)oRelsGeneratorInfo.m_nImageRId);
if (pFill->blip.is_init()) if (pFill->blip.is_init())
pFill->blip->m_namespace = _T("a"); pFill->blip->m_namespace = _T("a");
if(oRelsGeneratorInfo.m_nOleRId > 0)
{
pFill->blip->oleInfo.Init();
pFill->blip->oleInfo->m_sOleProperty = oRelsGeneratorInfo.m_sOleProperty;
pFill->blip->oleInfo->m_sRid = PPTX::RId((size_t)oRelsGeneratorInfo.m_nOleRId).get();
}
pReader->Skip(1); // end attribute pReader->Skip(1); // end attribute
break; break;
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "TableStyles.h" #include "TableStyles.h"
#include "DocxFormat/Media/Image.h" #include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/External.h" #include "DocxFormat/External/External.h"
#include "DocxFormat/External/HyperLink.h" #include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/Drawing/VmlDrawing.h" #include "DocxFormat/Drawing/VmlDrawing.h"
...@@ -194,6 +195,13 @@ namespace PPTX ...@@ -194,6 +195,13 @@ namespace PPTX
return _T(""); return _T("");
} }
virtual CString GetOleFromRId(const PPTX::RId& rid)const
{
smart_ptr<PPTX::OleObject> p = oleObject(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
virtual DWORD GetRGBAFromMap(const CString& str)const virtual DWORD GetRGBAFromMap(const CString& str)const
{ {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "DocxFormat/FileTypes.h" #include "DocxFormat/FileTypes.h"
#include "DocxFormat/Media/Image.h" #include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h" #include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/Drawing/VmlDrawing.h" #include "DocxFormat/Drawing/VmlDrawing.h"
...@@ -231,6 +232,13 @@ namespace PPTX ...@@ -231,6 +232,13 @@ namespace PPTX
return _T(""); return _T("");
return p->Uri().m_strFilename; return p->Uri().m_strFilename;
} }
virtual CString GetOleFromRId(const PPTX::RId& rid)const
{
smart_ptr<PPTX::OleObject> p = oleObject(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
virtual DWORD GetRGBAFromMap(const CString& str)const virtual DWORD GetRGBAFromMap(const CString& str)const
{ {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "TableStyles.h" #include "TableStyles.h"
#include "DocxFormat/Media/Image.h" #include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h" #include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/Drawing/VmlDrawing.h" #include "DocxFormat/Drawing/VmlDrawing.h"
...@@ -299,6 +300,13 @@ namespace PPTX ...@@ -299,6 +300,13 @@ namespace PPTX
return _T(""); return _T("");
return p->Uri().m_strFilename; return p->Uri().m_strFilename;
} }
virtual CString GetOleFromRId(const PPTX::RId& rid)const
{
smart_ptr<PPTX::OleObject> p = oleObject(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
//---------------------Colors from map--------------------------------------- //---------------------Colors from map---------------------------------------
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "Presentation.h" #include "Presentation.h"
#include "DocxFormat/Media/Image.h" #include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h" #include "DocxFormat/External/HyperLink.h"
namespace PPTX namespace PPTX
...@@ -330,6 +331,13 @@ namespace PPTX ...@@ -330,6 +331,13 @@ namespace PPTX
return _T(""); return _T("");
return p->Uri().m_strFilename; return p->Uri().m_strFilename;
} }
virtual CString GetOleFromRId(const PPTX::RId& rid)const
{
smart_ptr<PPTX::OleObject> p = oleObject(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
void GetLineStyle(int number, Logic::Ln& lnStyle)const void GetLineStyle(int number, Logic::Ln& lnStyle)const
{ {
themeElements.fmtScheme.GetLineStyle(number, lnStyle); themeElements.fmtScheme.GetLineStyle(number, lnStyle);
......
...@@ -199,6 +199,7 @@ namespace OOX ...@@ -199,6 +199,7 @@ namespace OOX
public: public:
CContentTypes() CContentTypes()
{ {
AddDefault(OOX::CPath(_T(".bin")));
AddDefault(OOX::CPath(_T(".rels"))); AddDefault(OOX::CPath(_T(".rels")));
AddDefault(OOX::CPath(_T(".bmp"))); AddDefault(OOX::CPath(_T(".bmp")));
AddDefault(OOX::CPath(_T(".jpg"))); AddDefault(OOX::CPath(_T(".jpg")));
......
...@@ -1621,7 +1621,18 @@ namespace OOX ...@@ -1621,7 +1621,18 @@ namespace OOX
virtual void fromXML(XmlUtils::CXmlNode& oNode) virtual void fromXML(XmlUtils::CXmlNode& oNode)
{ {
// TO DO: COLEObject::fromXML(XmlUtils::CXmlNode& oNode) if ( _T("o:OLEObject") != oNode.GetName() )
return;
oNode.ReadAttributeBase( _T("DrawAspect"), m_oDrawAspect );
oNode.ReadAttributeBase( _T("r:id"), m_oId );
oNode.ReadAttributeBase( _T("ObjectID"), m_sObjectId );
oNode.ReadAttributeBase( _T("ProgID"), m_sProgId );
oNode.ReadAttributeBase( _T("ShapeID"), m_sShapeId );
oNode.ReadAttributeBase( _T("Type"), m_oType );
oNode.ReadAttributeBase( _T("UpdateMode"), m_oUpdateMode );
//todo FieldCodes, LinkType, LockedField
} }
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{ {
......
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