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 @@
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_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_End = _T("</Types>");
......
......@@ -54,10 +54,11 @@ bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const CString& sSrcFileName,
{
CString sMediaPath;
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))
return true;
......@@ -137,7 +138,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
RELEASEOBJECT(pFontPicker);
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
OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels");
......@@ -153,8 +154,14 @@ void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString
//media
OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T("media");
FileSystem::Directory::CreateDirectory(pathMedia.GetPath());
sMediaPath = pathMedia.GetPath();
//embeddings
OOX::CPath pathEmbeddings = pathWord + FILE_SEPARATOR_STR + _T("embeddings");
FileSystem::Directory::CreateDirectory(pathEmbeddings.GetPath());
sEmbedPath = pathEmbeddings.GetPath();
// theme
OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme");
FileSystem::Directory::CreateDirectory(pathTheme.GetPath());
......@@ -165,7 +172,7 @@ void BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString
pathTheme = pathTheme + FILE_SEPARATOR_STR + _T("theme1.xml");
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;
......@@ -240,6 +247,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
}
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//папка с картинками
......
......@@ -34,10 +34,10 @@ namespace BinDocxRW
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 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);
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 getBinaryContent(const CString& bsTxContent, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
......
......@@ -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 pathEmbedDir = sDstPath + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("embeddings");
// File Type ( , , ReadFile , )
BYTE fileType;
......@@ -45,6 +46,7 @@ namespace BinXlsxRW{
NSDirectory::CreateDirectory(string2std_string(pathThemeDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathThemeThemeRelsDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathMediaDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathEmbedDir.GetPath()));
//Create Default Theme
{
......@@ -54,11 +56,13 @@ namespace BinXlsxRW{
}
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;
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir);
//
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName));
......
......@@ -26,9 +26,9 @@ namespace BinXlsxRW {
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 loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
......
......@@ -134,9 +134,10 @@ public:
CString sDirectoryOut = bstrDirectoryOut;
CString sThemePath;
CString sMediaPath;
CString sEmbedPath;
m_oCDocxSerializer.CreateDocxFolders(sDirectoryOut, sThemePath, sMediaPath);
bool bRes = m_oCDocxSerializer.loadFromFile(CString(bstrFileIn), CString(bstrDirectoryOut), CString(_T("")), CString(sThemePath.GetString()), CString(sMediaPath.GetString()));
m_oCDocxSerializer.CreateDocxFolders(sDirectoryOut, sThemePath, sMediaPath, sEmbedPath);
bool bRes = m_oCDocxSerializer.loadFromFile(CString(bstrFileIn), CString(bstrDirectoryOut), CString(_T("")), CString(sThemePath.GetString()), CString(sMediaPath.GetString()), sEmbedPath);
return bRes ? S_OK : S_FALSE;
}
......
......@@ -60,10 +60,11 @@ public:
{
CString sDstPath = bstrDstPath;
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;
}
STDMETHOD(SaveToFile)(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions)
......
......@@ -184,6 +184,7 @@ namespace NSBinPptxRW
HRESULT SetRelsPath (const CString& bsRelsPath);
CString GetRelsPath();
HRESULT SetMediaDstPath (const CString& bsMediaPath);
HRESULT SetEmbedDstPath (const CString& bsEmbedPath);
HRESULT AddShapeType(const CString& bsXml);
HRESULT AddObject(const CString& bsXml, CString** pMainProps);
......
......@@ -50,7 +50,25 @@ namespace NSBinPptxRW
class CStringWriter;
class CCommonWriter;
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
{
public:
......@@ -97,10 +115,11 @@ namespace NSBinPptxRW
class CImageManager2
{
private:
std::map<CString, CString> m_mapImages;
std::map<CString, CImageManager2Info> m_mapImages;
_INT32 m_lIndexNextImage;
_INT32 m_lIndexNextOle;
CString m_strDstMedia;
CString m_strDstEmbed;
public:
bool m_bIsWord;
......@@ -110,6 +129,9 @@ namespace NSBinPptxRW
void Clear();
void SetDstMedia(const CString& strDst);
CString GetDstMedia();
void SetDstEmbed(const CString& strDst);
CString GetDstEmbed();
int IsDisplayedImage(const CString& strInput);
public:
template <typename T>
......@@ -117,16 +139,17 @@ namespace NSBinPptxRW
{
pWriter->WriteBYTE(m_bIsWord ? 1 : 0);
pWriter->WriteINT(m_lIndexNextImage);
pWriter->WriteINT(m_lIndexNextOle);
pWriter->WriteString(m_strDstMedia);
int lCount = (int)m_mapImages.size();
pWriter->WriteINT(lCount);
for (std::map<CString, CString>::const_iterator pPair = m_mapImages.begin(); pPair != m_mapImages.end(); ++pPair)
{
pWriter->WriteString(pPair->first);
pWriter->WriteString(pPair->second);
}
//for (std::map<CString, CString>::const_iterator pPair = m_mapImages.begin(); pPair != m_mapImages.end(); ++pPair)
//{
// pWriter->WriteString(pPair->first);
// pWriter->WriteString(pPair->second);
//}
}
template <typename T>
......@@ -134,29 +157,32 @@ namespace NSBinPptxRW
{
m_bIsWord = ((true == pReader->GetBool()) ? true : false);
m_lIndexNextImage = pReader->GetLong();
m_lIndexNextOle = pReader->GetLong();
m_strDstMedia = pReader->GetString2();
m_mapImages.clear();
_INT32 lCount = pReader->GetLong();
for (_INT32 i = 0; i < lCount; ++i)
{
CString s1 = pReader->GetString2();
CString s2 = pReader->GetString2();
//for (_INT32 i = 0; i < lCount; ++i)
//{
// CString s1 = pReader->GetString2();
// CString s2 = pReader->GetString2();
m_mapImages [s1] = s2;
}
// m_mapImages [s1] = s2;
//}
}
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 SaveImageAsJPG(const CString& strFileSrc, const CString& strFileDst);
bool IsNeedDownload(const CString& strFile);
CString DownloadImage(const CString& strFile);
CImageManager2Info DownloadImage(const CString& strFile);
CString DownloadImageExec(const CString& strFile);
};
class CBinaryFileWriter
......@@ -355,7 +381,7 @@ namespace NSBinPptxRW
private:
CStringWriter* m_pWriter;
int m_lNextRelsID;
std::map<CString, int> m_mapImages;
std::map<CString, CRelsGeneratorInfo> m_mapImages;
std::map<CString, int> m_mapLinks;
......@@ -385,7 +411,7 @@ namespace NSBinPptxRW
void AddRels(const CString& strRels);
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 WriteRels(const CString& bsType, const CString& bsTarget, const CString& bsTargetMode);
......
......@@ -70,6 +70,11 @@ namespace NSBinPptxRW
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;
OOX::CPath pathTheme = pathPPT / _T("theme");
......@@ -700,6 +705,7 @@ namespace NSBinPptxRW
CStringWriter oContentTypes;
oContentTypes.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<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=\"jpeg\" ContentType=\"image/jpeg\" />\
<Default Extension=\"wmf\" ContentType=\"image/x-wmf\" />\
......
......@@ -249,7 +249,7 @@ namespace NSBinPptxRW
LONG m_lGroupIndex;
LONG m_lObjectId;
LONG m_lObjectIdVML;
LONG m_lObjectIdOle;
public:
bool m_bIsUseOffice2007;
CString m_strStyleMain;
......@@ -268,6 +268,7 @@ namespace NSBinPptxRW
m_lGroupIndex = 0;
m_lObjectId = 0;
m_lObjectIdVML = 0;
m_lObjectIdOle = 0;
m_bIsUseOffice2007 = false;
m_strStyleMain = _T("");
......
This diff is collapsed.
......@@ -23,6 +23,7 @@
#include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/Audio.h"
#include "DocxFormat/Media/Video.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/External/ExternalImage.h"
#include "DocxFormat/External/ExternalAudio.h"
......@@ -95,6 +96,8 @@ namespace PPTX
return smart_ptr<PPTX::File>(new PPTX::Authors(filename, map));
else if (relation.type() == PPTX::FileTypes::SlideComments)
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());
}
......@@ -130,6 +133,9 @@ namespace PPTX
else if(strT == PPTX::FileTypes::LegacyDiagramText)
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());
}
......
......@@ -90,5 +90,24 @@ namespace PPTX
}
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 PPTX
\ No newline at end of file
......@@ -99,7 +99,14 @@ namespace PPTX
if (pWriter->m_pCommonRels->is_init())
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();
pWriter->StartRecord(3);
......@@ -112,6 +119,7 @@ namespace PPTX
}
public:
virtual CString GetFullPicName(FileContainer* pRels = NULL)const;
virtual CString GetFullOleName(const PPTX::RId& pRId, FileContainer* pRels = NULL)const;
public:
std::vector<UniEffect> Effects;
......@@ -121,6 +129,7 @@ namespace PPTX
//private:
public:
CString m_namespace;
nullable<NSShapeImageGen::COleInfo> oleInfo;
protected:
virtual void FillParentPointersForChilds();
};
......
......@@ -364,7 +364,7 @@ namespace PPTX
strUrl = pathUrl.GetPath();
}
LONG lId = pReader->m_pRels->WriteImage(strUrl, strOrigBase64);
NSBinPptxRW::CRelsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, strOrigBase64);
// -------------------
if (strTempFile != _T(""))
......@@ -376,7 +376,14 @@ namespace PPTX
if (!blip.is_init())
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
break;
......
......@@ -374,7 +374,51 @@ namespace PPTX
lW = spPr.xfrm->extX.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
spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH);
#endif
......@@ -389,7 +433,7 @@ namespace PPTX
CString strStrokeAttr = _T("");
CString strFillNode = _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);
if (pWriter->m_strStyleMain != _T(""))
......@@ -460,9 +504,11 @@ namespace PPTX
{
pWriter->WriteAttribute(_T("style"), pWriter->m_strStyleMain + oStylesWriter.GetXmlString());
}
pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath);
if(!bOle)
{
pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath);
}
if (pWriter->m_strAttributesMain)
{
......@@ -581,8 +627,12 @@ namespace PPTX
pWriter->WriteAttribute(_T("o:spid"), strSpid);
pWriter->WriteAttribute(_T("style"), oStylesWriter.GetXmlString());
pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath);
if(!bOle)
{
pWriter->WriteAttribute(_T("coordsize"), (CString)_T("100000,100000"));
pWriter->WriteAttribute(_T("path"), strPath);
}
if (pWriter->m_strAttributesMain)
{
......@@ -614,6 +664,23 @@ namespace PPTX
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 PPTX
\ No newline at end of file
......@@ -23,7 +23,7 @@ namespace PPTX
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::Logic::ClrMap> oClrMap = _oClrMap.smart_dynamic_cast<PPTX::Logic::ClrMap>();
......@@ -80,16 +80,12 @@ namespace PPTX
CString strId = oBlip.blip->embed->ToString();
if (!oBlip.srcRect.is_init())
if(bOle)
{
if (oBlip.tile.is_init())
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(" />");
strNode = _T("<v:imagedata r:id=\"") + strId + _T("\" o:title=\"\" />");
}
else
{
// crop
if (oBlip.tile.is_init())
strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"tile\"") + fopacity + _T(" />");
else
......
......@@ -10,7 +10,7 @@ namespace PPTX
{
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);
class SpTreeElem : public WrapperWritingElement
......
......@@ -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(""))
......@@ -353,10 +353,17 @@ namespace PPTX
if (!pFill->blip.is_init())
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())
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
break;
}
......
......@@ -20,6 +20,7 @@
#include "TableStyles.h"
#include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/External.h"
#include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/Drawing/VmlDrawing.h"
......@@ -194,6 +195,13 @@ namespace PPTX
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
{
......
......@@ -22,6 +22,7 @@
#include "DocxFormat/FileTypes.h"
#include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/Drawing/VmlDrawing.h"
......@@ -231,6 +232,13 @@ namespace PPTX
return _T("");
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
{
......
......@@ -22,6 +22,7 @@
#include "TableStyles.h"
#include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/Drawing/VmlDrawing.h"
......@@ -299,6 +300,13 @@ namespace PPTX
return _T("");
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---------------------------------------
......
......@@ -14,6 +14,7 @@
#include "Presentation.h"
#include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h"
namespace PPTX
......@@ -330,6 +331,13 @@ namespace PPTX
return _T("");
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
{
themeElements.fmtScheme.GetLineStyle(number, lnStyle);
......
......@@ -199,6 +199,7 @@ namespace OOX
public:
CContentTypes()
{
AddDefault(OOX::CPath(_T(".bin")));
AddDefault(OOX::CPath(_T(".rels")));
AddDefault(OOX::CPath(_T(".bmp")));
AddDefault(OOX::CPath(_T(".jpg")));
......
......@@ -1621,7 +1621,18 @@ namespace OOX
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)
{
......
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