Commit fa863111 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

PptFormat Reader

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65231 954022d7-b5bf-4e40-9824-e11837661b57
parent 440ff533
......@@ -68,8 +68,6 @@ HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDs
m_Status = NULLMODE;
return S_FALSE;
}
m_strEditorXml = _T("");
if (0 < ((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_arUsers.size())
{
NSPresentationEditor::CPPTXWriter oPPTXWriter;
......@@ -88,19 +86,6 @@ HRESULT COfficePPTFile::GetAdditionalParam (CString sParamName, VARIANT* ParamVa
if (NULL == ParamValue)
return S_FALSE;
if (_T("EditorXml") == sParamName)
{
#if defined(_WIN32) || defined (_WIN64)
if (m_strEditorXml.IsEmpty())
{
m_strEditorXml = ((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_arUsers[0]->ToXmlEditor2();
}
ParamValue->bstrVal = m_strEditorXml.AllocSysString();
#else
ParamValue->bstrVal = m_strEditorXml;
#endif
}
return S_OK;
}
......
......@@ -30,7 +30,6 @@ private:
void* m_pReader;
std::vector<CString> m_arUserSources;
CString m_strEditorXml;
std::wstring m_strTempDirectory;
......
......@@ -5,10 +5,10 @@
class CPPTDocumentInfo
{
public:
CCurrentUser m_oCurrentUser;
std::vector<CPPTUserInfo*> m_arUsers;
CString m_strFileDirectory;
CCurrentUser m_oCurrentUser;
std::vector<CPPTUserInfo*> m_arUsers;
CString m_strFileDirectory;
std::map<int, std::wstring> m_mapStoreImageFile;
public:
......@@ -54,9 +54,10 @@ public:
oHeader.ReadFromStream(pStream);
oUserAtom.ReadFromStream(oHeader, pStream);
CPPTUserInfo* pInfo = new CPPTUserInfo();
pInfo->m_strFileDirectory = m_strFileDirectory;
bool bRes = pInfo->ReadFromStream(&oUserAtom, pStream, strFolderMem);
CPPTUserInfo* pInfo = new CPPTUserInfo();
pInfo->m_strFileDirectory = m_strFileDirectory;
bool bRes = pInfo->ReadFromStream(&oUserAtom, pStream, strFolderMem);
offsetToEdit = pInfo->m_oUser.m_nOffsetLastEdit;
......@@ -74,46 +75,22 @@ public:
pInfo = NULL;
}
// , blip. -
LONG lCount = m_arUsers.size();
if (1 < lCount)
// -
for (size_t i = 1; i < m_arUsers.size(); ++i)
{
m_arUsers[0]->m_arEmptyPictures = m_arUsers[lCount - 1]->m_arEmptyPictures;
for (long j = 0 ; j < m_arUsers[i]->m_arEmptyPictures.size(); j++)
{
if (m_arUsers[i]->m_arEmptyPictures[j] == false && j < m_arUsers[0]->m_arEmptyPictures.size())
m_arUsers[0]->m_arEmptyPictures[j] = false;
}
}
// FromDocument...
for (size_t i = 0; i < m_arUsers.size(); ++i)
{
m_arUsers[i]->FromDocument();
}
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
SaveXmlInfo();
#endif
}
void SaveXmlInfo()
{
if (!PPT_DUMP_LOG)
return;
XmlUtils::CXmlWriter oWriter;
oWriter.WriteNodeBegin(_T("PPTInfo"));
oWriter.WriteString(m_oCurrentUser.ToString());
for (size_t nIndex = 0; nIndex < m_arUsers.size(); ++nIndex)
{
oWriter.WriteString(m_arUsers[nIndex]->m_strXmlInfo);
}
oWriter.WriteNodeEnd(_T("PPTInfo"));
//CDirectory::SaveToFile(_T("C:\\PPTInfo.xml"), oWriter.GetXmlString());
oWriter.SaveToFile(_T("C:\\PPTInfo.xml"), TRUE);
}
LONG GetCountPicturesUsed(size_t nUser)
......
......@@ -251,18 +251,17 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
m_arrFonts.push_back(oFont);
}
UpdateXMLInfo();
//FromDocument();
// FromDocument - , (!!!)
//
//
std::vector<CRecordBlipStoreContainer*> oArray;
m_oDocument.GetRecordsByType(&oArray, true, true);
if (0 < oArray.size())
//std::vector<CRecordBlipStoreContainer*> oArray;
m_oDocument.GetRecordsByType(&m_arrBlipStore, true, true);
if (0 < m_arrBlipStore.size())
{
m_bIsSetupEmpty = TRUE;
oArray[0]->SetUpEmptyInfos(&m_arEmptyPictures);
m_arrBlipStore[0]->SetUpEmptyInfos(&m_arEmptyPictures);
}
return TRUE;
......@@ -270,7 +269,6 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
void CPPTUserInfo::FromDocument()
{
UpdateXMLInfo();
m_arSlides.clear();
//
......@@ -423,78 +421,64 @@ void CPPTUserInfo::LoadSlide(DWORD dwSlideID, CSlide* pSlide)
CSlideInfo* pSlideWrapper = &m_arSlideWrapper.back();
pSlideWrapper->m_parEmptyPictures = &m_arEmptyPictures;
pSlideWrapper->m_parEmptyPictures = &m_arEmptyPictures;
pSlideWrapper->m_mapFilePictures = &m_pDocumentInfo->m_mapStoreImageFile;
// , placeholder
pSlideWrapper->m_arTextPlaceHolders = pRecordSlide->m_oPersist.m_arTextAttrs;
//
std::vector<CRecordSlideAtom*> oArrayAtoms;
pRecordSlide->GetRecordsByType(&oArrayAtoms, false, true);
if (0 == oArrayAtoms.size())
std::vector<CRecordSlideAtom*> oArraySlideAtoms;
pRecordSlide->GetRecordsByType(&oArraySlideAtoms, false, true);
if (0 == oArraySlideAtoms.size())
{
// !!!
return;
}
bool bMasterColorScheme = oArraySlideAtoms[0]->m_bMasterScheme;
bool bMasterBackGround = oArraySlideAtoms[0]->m_bMasterBackground;
bool bMasterObjects = oArraySlideAtoms[0]->m_bMasterObjects;
std::map<DWORD, LONG>::iterator pPair = m_mapMasterToTheme.find(oArrayAtoms[0]->m_nMasterIDRef);
std::map<DWORD, LONG>::iterator pPairTheme = m_mapMasterToTheme.find(oArraySlideAtoms[0]->m_nMasterIDRef);
if (pPair == m_mapMasterToTheme.end())
if (pPairTheme == m_mapMasterToTheme.end())
{
//?????
//????? !!!
pPairTheme = m_mapMasterToTheme.begin();
}
pSlide->m_lThemeID = pPair->second;
pSlide->m_lThemeID = pPairTheme->second;
CTheme * pTheme = &m_arThemes [pSlide->m_lThemeID];
CSlideInfo * pThemeWrapper = &m_arMasterWrapper[pSlide->m_lThemeID];
CLayout* pLayout = NULL;
std::wstring strLayoutType = ConvertLayoutType(oArraySlideAtoms[0]->m_oLayout.m_nGeom, oArraySlideAtoms[0]->m_oLayout.m_pPlaceHolderID);
pPair = m_mapMasterToLayout.find(oArrayAtoms[0]->m_nMasterIDRef);
if (pPair == m_mapMasterToLayout.end())
std::map<std::wstring, LONG>::iterator pPairLayout = pTheme->m_mapGeomToLayout.find(strLayoutType);
if (pPairLayout == pTheme->m_mapGeomToLayout.end())
{
//?????
pSlide->m_lLayoutID = AddNewLayout(pTheme, &oArraySlideAtoms[0]->m_oLayout, pRecordSlide->m_oPersist.m_arTextAttrs);
pLayout = &pTheme->m_arLayouts[pSlide->m_lLayoutID];
pLayout->m_bShowMasterShapes = true;
}
else
{
pSlide->m_lLayoutID = pPairLayout->second;
pLayout = &pTheme->m_arLayouts[pPairLayout->second];
}
pSlide->m_lLayoutID = pPair->second;
CSlideInfo* pThemeWrapper = &m_arMasterWrapper[pSlide->m_lThemeID];
CTheme* pTheme = &m_arThemes[pSlide->m_lThemeID];
CLayout* pLayout = &pTheme->m_arLayouts[pSlide->m_lLayoutID];
std::vector<NSPresentationEditor::CColor>* pArrayColorScheme = &pTheme->m_arColorScheme;
if (!pLayout->m_bUseThemeColorScheme)
pArrayColorScheme = &pLayout->m_arColorScheme;
////todoooooo
//int idxTheme = pSlide->m_lThemeID;
//CSlideInfo* pThemeWrapper = NULL;
//CTheme* pTheme = NULL;
//CLayout* pLayout = NULL;
//if (idxTheme < m_arMasterWrapper.size())
// pThemeWrapper = &m_arMasterWrapper[pSlide->m_lThemeID];
//if (idxTheme < m_arThemes.size())
// pTheme = &m_arThemes[idxTheme];
//int idxLayout = pSlide->m_lLayoutID;
//if (pTheme)
//{
// if (idxLayout < pTheme->m_arLayouts.size())
// pLayout = &pTheme->m_arLayouts[idxLayout];
//}
//std::vector<NSPresentationEditor::CColor>* pArrayColorScheme;
//if (pLayout)
//{
// pArrayColorScheme = &pTheme->m_arColorScheme;
// if (!pLayout->m_bUseThemeColorScheme)
// pArrayColorScheme = &pLayout->m_arColorScheme;
//}
// -----------------------------------------------------------
pSlide->m_bUseLayoutColorScheme = true;
if (!oArrayAtoms[0]->m_bMasterScheme)
if (!bMasterColorScheme)
{
std::vector<CRecordColorSchemeAtom*> oArrayColors;
pRecordSlide->GetRecordsByType(&oArrayColors, false);
......@@ -536,7 +520,7 @@ void CPPTUserInfo::LoadSlide(DWORD dwSlideID, CSlide* pSlide)
pRecordSlide->GetRecordsByType(&oArrayShapes, true);
pSlide->m_bShowMasterShapes = oArrayAtoms[0]->m_bMasterObjects;
pSlide->m_bShowMasterShapes = bMasterObjects;
pSlide->m_bIsBackground = false;
for (int nShape = 0; nShape < oArrayShapes.size(); ++nShape)
......@@ -544,14 +528,12 @@ void CPPTUserInfo::LoadSlide(DWORD dwSlideID, CSlide* pSlide)
IElement* pElem = NULL;
oArrayShapes[nShape]->GetElement(&pElem, &m_oExMedia, pSlide->m_lOriginalWidth, pSlide->m_lOriginalHeight,
pTheme, pLayout, pThemeWrapper, pSlideWrapper, pSlide);
pTheme, pLayout, pThemeWrapper, pSlideWrapper, pSlide);
if (NULL != pElem)
{
if (pElem->m_bIsBackground && !pElem->m_bHaveAnchor)
if (pElem->m_bIsBackground && !pElem->m_bHaveAnchor && !bMasterBackGround)
{
//if (!oArrayAtoms[0]->m_bMasterBackground)
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
if (NULL != pShape)
{
......@@ -566,11 +548,57 @@ void CPPTUserInfo::LoadSlide(DWORD dwSlideID, CSlide* pSlide)
}else
AddAnimation ( dwSlideID, pSlide->m_lOriginalWidth, pSlide->m_lOriginalHeight, pElem );
pSlide->m_arElements.push_back(pElem);
if (pElem->m_bHaveAnchor)
{
pSlide->m_arElements.push_back(pElem);
}
}
}
}
LONG CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayoutAtom* layoutRecord, std::vector<CTextFullSettings> & text, bool addShapes)
{
if (pTheme == NULL) return -1;
LONG ind = pTheme->m_arLayouts.size();
CLayout layout;
pTheme->m_arLayouts.push_back(layout);
CLayout *pLayout = &pTheme->m_arLayouts.back();
pLayout = &pTheme->m_arLayouts.back();
pLayout->m_lOriginalWidth = pTheme->m_lOriginalWidth;
pLayout->m_lOriginalHeight = pTheme->m_lOriginalHeight;
pLayout->m_lWidth = (LONG)(c_dMasterUnitsToMillimetreKoef * pLayout->m_lOriginalWidth);
pLayout->m_lHeight = (LONG)(c_dMasterUnitsToMillimetreKoef * pLayout->m_lOriginalHeight);
pLayout->m_bUseThemeColorScheme = true;
pLayout->m_bShowMasterShapes = true;
pLayout->m_strLayoutType = ConvertLayoutType(layoutRecord->m_nGeom, layoutRecord->m_pPlaceHolderID);
pTheme->m_mapGeomToLayout.insert(std::pair<std::wstring, LONG>(pLayout->m_strLayoutType, ind));
if (!addShapes) return ind;
for (int i = 0 ; i < 8; i ++)
{
if (layoutRecord->m_pPlaceHolderID[i] == 0) break;
CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pShape->m_lPlaceholderType = CPPTElement::CorrectPlaceHolderType(layoutRecord->m_pPlaceHolderID[i]);
pShape->m_bPlaceholderSet = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pShape));
}
return ind;
}
void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, const LONG& lOriginHeight)
{
std::map<DWORD, LONG>::iterator pPair = m_mapMasterToTheme.find(dwMasterID);
......@@ -589,7 +617,10 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
CRecordSlide* pMaster = pPairMaster->second;
if (pMaster == NULL)
{
//m_mapMasters.erase(pPairMaster);
return; //todooo 20080720.ppt
}
std::vector<CRecordSlideAtom*> oArraySlideAtoms;
pMaster->GetRecordsByType(&oArraySlideAtoms, true);
......@@ -628,12 +659,14 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
LONG lIndexTheme = (LONG)m_arThemes.size();
m_mapMasterToTheme.insert(std::pair<DWORD, LONG>(dwMasterID, lIndexTheme));
m_mapMasterToLayout.insert(std::pair<DWORD, LONG>(dwMasterID, 0));
CTheme theme;
m_arThemes.push_back(theme);
CTheme* pTheme = &m_arThemes[lIndexTheme];
pTheme->m_lOriginalWidth = lOriginWidth;
pTheme->m_lOriginalHeight = lOriginHeight;
std::vector<CRecordCString*> oArrayStrings;
pMaster->GetRecordsByType(&oArrayStrings, false, false);
for (int i=0; i < oArrayStrings.size(); i++)
......@@ -644,10 +677,6 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
}
}
CLayout layout;
pTheme->m_arLayouts.push_back(layout);
CLayout* pLayout = &pTheme->m_arLayouts.back();
CSlideInfo slide_info;
m_arMasterWrapper.push_back(slide_info);
CSlideInfo* pMasterWrapper = &m_arMasterWrapper[lIndexTheme];
......@@ -680,10 +709,14 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
CorrectColorScheme(extra);
pTheme->m_arExtraColorScheme.push_back(extra);
}
}
CorrectColorScheme(pTheme->m_arColorScheme);
if (pTheme->m_arColorScheme.empty() && !pTheme->m_arExtraColorScheme.empty())
{
pTheme->m_arColorScheme = pTheme->m_arExtraColorScheme[0];
}
//CorrectColorScheme(m_oSchemeColors);//??
// ---------------------------------------------------------------------------------
......@@ -696,7 +729,8 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
pMasterWrapper->m_arTextPlaceHolders = pPairMaster1->second->m_oPersist.m_arTextAttrs;
}
pMasterWrapper->m_parEmptyPictures = &m_arEmptyPictures;
pMasterWrapper->m_parEmptyPictures = &m_arEmptyPictures;
pMasterWrapper->m_mapFilePictures = &m_pDocumentInfo->m_mapStoreImageFile;
// -----------------------------------------------
std::vector<CRecordTextMasterStyleAtom*> oArrayTextMasters;
......@@ -736,23 +770,13 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
pTheme->m_pStyles[3].ApplyAfter(pMasterWrapper->m_pStyles[3].get());
// ---------------------------------------------------------------------------------
pLayout->m_lOriginalWidth = lOriginWidth;
pLayout->m_lOriginalHeight = lOriginHeight;
pLayout->m_lWidth = (LONG)(c_dMasterUnitsToMillimetreKoef * lOriginWidth);
pLayout->m_lHeight = (LONG)(c_dMasterUnitsToMillimetreKoef * lOriginHeight);
pLayout->m_bUseThemeColorScheme = true;
pLayout->m_bShowMasterShapes = bMasterObjects;
if (oArraySlideAtoms[0]->m_oLayout.m_nGeom == 1) oArraySlideAtoms[0]->m_oLayout.m_nGeom = 15;
pLayout->m_strLayoutType = ConvertLayoutType(oArraySlideAtoms[0]->m_oLayout.m_nGeom, oArraySlideAtoms[0]->m_oLayout.m_pPlaceHolderID);
// ...-----------------------------------------------------------
std::vector<CRecordShapeContainer*> oArrayShapes;
pMaster->GetRecordsByType(&oArrayShapes, true);
pTheme->CalculateStyles();
CLayout* pLayout = NULL; // ...!!
for (int nShape = 0; nShape < oArrayShapes.size(); ++nShape)
{
......@@ -762,46 +786,22 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
if (NULL != pElem)
{
AddAnimation ( dwMasterID, lOriginWidth, lOriginHeight, pElem );
if (-1 == pElem->m_lPlaceholderType)
if (pElem->m_bIsBackground && !pElem->m_bHaveAnchor)
{
if (pElem->m_bIsBackground)
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
if (NULL != pShape)
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
if (NULL != pShape)
{
pShape->SetupProperties(NULL, pTheme, pLayout);
pShape->SetupProperties(NULL, pTheme, pLayout);
pTheme->m_bIsBackground = true;
pTheme->m_oBackground = pShape->m_oShape.m_oBrush;
}
RELEASEINTERFACE(pElem);
continue;
pTheme->m_bIsBackground = true;
pTheme->m_oBackground = pShape->m_oShape.m_oBrush;
}
pTheme->m_arElements.push_back(pElem);
}
else
{
if (pElem->m_bIsBackground)
{
if (!bMasterBackGround)
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
if (NULL != pShape)
{
pShape->SetupProperties(NULL, pTheme, pLayout);
pLayout->m_bIsBackground = true;
pLayout->m_oBackground = pShape->m_oShape.m_oBrush;
}
}
RELEASEINTERFACE(pElem);
continue;
}
pLayout->m_arElements.push_back(pElem);
RELEASEINTERFACE(pElem);
continue;
}
pTheme->m_arElements.push_back(pElem);
}
}
}
......@@ -844,9 +844,9 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
if (0 == oArraySlideAtoms.size())
return;
bool bMasterColorScheme = oArraySlideAtoms[0]->m_bMasterScheme;
bool bMasterBackGround = oArraySlideAtoms[0]->m_bMasterBackground;
bool bMasterObjects = oArraySlideAtoms[0]->m_bMasterObjects;
bool bMasterColorScheme = false;//oArraySlideAtoms[0]->m_bMasterScheme;
bool bMasterBackGround = false;//oArraySlideAtoms[0]->m_bMasterBackground;
bool bMasterObjects = false;//oArraySlideAtoms[0]->m_bMasterObjects;
DWORD dwID = (DWORD)oArraySlideAtoms[0]->m_nMasterIDRef;
......@@ -871,36 +871,44 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
return;
}
// LoadSlide
// LoadSlide
CSlideInfo elm;
m_arMasterWrapper.push_back(elm);
CSlideInfo* pMasterWrapper = &m_arMasterWrapper[m_arMasterWrapper.size() - 1];
// , placeholder
pMasterWrapper->m_arTextPlaceHolders = pCurMaster->m_oPersist.m_arTextAttrs;
pMasterWrapper->m_parEmptyPictures = &m_arEmptyPictures;
pMasterWrapper->m_mapFilePictures = &m_pDocumentInfo->m_mapStoreImageFile;
std::map<DWORD, LONG>::iterator pPairTheme = m_mapMasterToTheme.find(dwID);
if (m_mapMasterToTheme.end() == pPairTheme)
return;
CTheme* pTheme = &m_arThemes[pPairTheme->second];
LONG lIndexLayout = (LONG)pTheme->m_arLayouts.size();
m_mapMasterToTheme[dwCurID] = pPairTheme->second;
m_mapMasterToLayout[dwCurID] = lIndexLayout;
CLayout layout_elm;
pTheme->m_arLayouts.push_back(layout_elm);
CLayout* pLayout = &pTheme->m_arLayouts[lIndexLayout];
m_mapMasterToTheme.insert(std::pair<DWORD, LONG>(dwMasterID, pPairTheme->second));
CSlideInfo elm;
m_arMasterWrapper.push_back(elm);
CSlideInfo* pMasterWrapper = &m_arMasterWrapper[m_arMasterWrapper.size() - 1];
CSlideInfo* pThemeWrapper = &m_arMasterWrapper[pPairTheme->second];
CSlideInfo * pThemeWrapper = &m_arMasterWrapper[pPairTheme->second];
CTheme * pTheme = &m_arThemes [pPairTheme->second];
// , placeholder
pMasterWrapper->m_arTextPlaceHolders = pCurMaster->m_oPersist.m_arTextAttrs;
std::wstring strLayoutType = ConvertLayoutType(oArraySlideAtoms[0]->m_oLayout.m_nGeom, oArraySlideAtoms[0]->m_oLayout.m_pPlaceHolderID);
pMasterWrapper->m_parEmptyPictures = &m_arEmptyPictures;
CLayout* pLayout = NULL;
std::map<std::wstring, LONG>::iterator pPair1 = pTheme->m_mapGeomToLayout.find(strLayoutType);
if (pPair1 == pTheme->m_mapGeomToLayout.end())
{
// - !!
int lLayoutID = AddNewLayout(pTheme, &oArraySlideAtoms[0]->m_oLayout, pCurMaster->m_oPersist.m_arTextAttrs, false);
pLayout = &pTheme->m_arLayouts[lLayoutID];
pLayout->m_bShowMasterShapes = false;
}
else
{
pLayout = &pTheme->m_arLayouts[pPair1->second];
}
pLayout->m_bUseThemeColorScheme = true;
pLayout->m_bShowMasterShapes = bMasterObjects;
pLayout->m_strLayoutType = ConvertLayoutType(oArraySlideAtoms[0]->m_oLayout.m_nGeom, oArraySlideAtoms[0]->m_oLayout.m_pPlaceHolderID);
std::vector<NSPresentationEditor::CColor>* pArrayColorScheme = &pTheme->m_arColorScheme;
// -----------------------------------------------------------
......@@ -940,14 +948,6 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
}
}
}
// ---------------------------------------------------------------------------------
pLayout->m_lOriginalWidth = lOriginWidth;
pLayout->m_lOriginalHeight = lOriginHeight;
pLayout->Clear();
// ---------------------------------------------------------------------------------
// ...
std::vector<CRecordShapeContainer*> oArrayShapes;
pCurMaster->GetRecordsByType(&oArrayShapes, true);
......@@ -961,112 +961,27 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
{
AddAnimation ( dwMasterID, lOriginWidth, lOriginHeight, pElem );
if (pElem->m_bIsBackground)
if (pElem->m_bIsBackground && !pElem->m_bHaveAnchor)
{
if (!bMasterBackGround)
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
if (NULL != pShape)
{
pShape->SetupProperties(NULL, pTheme, pLayout);
if (NULL != pShape)
{
pShape->SetupProperties(NULL, pTheme, pLayout);
pLayout->m_bIsBackground = true;
pLayout->m_oBackground = pShape->m_oShape.m_oBrush;
}
pLayout->m_bIsBackground = true;
pLayout->m_oBackground = pShape->m_oShape.m_oBrush;
}
RELEASEINTERFACE(pElem);
continue;
}
pElem->m_bPlaceholderSet = true;
pLayout->m_arElements.push_back(pElem);
}
}
}
void CPPTUserInfo::UpdateXMLInfo()
{
if (!PPT_DUMP_LOG)
return;
XmlUtils::CXmlWriter oWriter;
oWriter.WriteNodeBegin(_T("User"));
oWriter.WriteString(m_oDocument.ToString());
// Slides...
if (0 != m_mapSlides.size())
{
oWriter.WriteNodeBegin(_T("Slides"));
//for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.begin(); pPair != m_mapSlides.end(); ++pPair)
for (int i=0; i< m_arrSlidesOrder.size(); i++)
{
std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.find(m_arrSlidesOrder[i]);
if (pPair == m_mapSlides.end())
continue;
CRecordSlide* pSlide = pPair->second;
if (NULL != pSlide)
{
oWriter.WriteString(pSlide->ToString(pPair->first));
}
}
oWriter.WriteNodeEnd(_T("Slides"));
}
// Masters
if (0 != m_mapMasters.size())
{
oWriter.WriteNodeBegin(_T("Masters"));
//for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapMasters.begin(); pPair != m_mapMasters.end(); ++pPair)
for (long i=0; i< m_arrMastersOrder.size(); i++)
{
std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapMasters.find(m_arrMastersOrder[i]);
if (pPair == m_mapMasters.end())continue;
CRecordSlide* pSlide = pPair->second;
if (NULL != pSlide)
{
oWriter.WriteString(pSlide->ToString(pPair->first));
}
}
oWriter.WriteNodeEnd(_T("Masters"));
}
// Notes
if (0 != m_mapNotes.size())
{
oWriter.WriteNodeBegin(_T("Notes"));
//for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapNotes.begin(); pPair != m_mapNotes.end(); ++pPair)
for (long i=0; i< m_arrNotesOrder.size(); i++)
{
std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapNotes.find(m_arrNotesOrder[i]);
if (pPair == m_mapMasters.end())continue;
CRecordSlide* pSlide = pPair->second;
if (NULL != pSlide)
{
oWriter.WriteString(pSlide->ToString(pPair->first));
}
}
oWriter.WriteNodeEnd(_T("Notes"));
}
oWriter.WriteNodeEnd(_T("User"));
m_strXmlInfo = oWriter.GetXmlString();
//CDirectory::SaveToFile(_T("C:\\PPTInfo.xml"), m_strXmlInfo);
}
void CPPTUserInfo::LoadSlideFromPrevUsers(DWORD dwSlideID)
{
if ((NULL == m_pDocumentInfo) || (-1 == m_lIndexThisUser))
......@@ -1078,10 +993,9 @@ void CPPTUserInfo::LoadSlideFromPrevUsers(DWORD dwSlideID)
return; //
size_t lUsersCount = m_pDocumentInfo->m_arUsers.size();
// -
//for (size_t lIndexUser = lUsersCount - 1; lIndexUser > m_lIndexThisUser ; lIndexUser--)
for (size_t lIndexUser = m_lIndexThisUser + 1; lIndexUser < lUsersCount; ++lIndexUser)
//for (size_t lIndexUser = lUsersCount - 1; lIndexUser > m_lIndexThisUser; lIndexUser--)
{
std::map<DWORD, CRecordSlide*>::iterator pPair = m_pDocumentInfo->m_arUsers[lIndexUser]->m_mapSlides.find(dwSlideID);
if (pPair == m_pDocumentInfo->m_arUsers[lIndexUser]->m_mapSlides.end())
......@@ -1116,8 +1030,6 @@ void CPPTUserInfo::LoadMasterFromPrevUsers(DWORD dwMasterID)
size_t lUsersCount = m_pDocumentInfo->m_arUsers.size();
// -
for (size_t lIndexUser = m_lIndexThisUser + 1; lIndexUser < lUsersCount; ++lIndexUser)
//for (size_t lIndexUser = lUsersCount - 1; lIndexUser > m_lIndexThisUser; lIndexUser--)
{
......@@ -1227,30 +1139,25 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects)
// -----------------------------------------------------------
// ----------------------------------------------
std::vector<CRecordExCDAudioContainer*> oArrayAudioCD;
std::vector<CRecordExCDAudioContainer*> oArrayAudioCD;
std::vector<CRecordExMIDIAudioContainer*> oArrayAudioMIDI;
std::vector<CRecordWAVAudioLinkContainer*> oArrayWAVLink;
std::vector<CRecordWAVAudioEmbeddedContainer*> oArrayAudioEmbedded;
std::vector<CRecordWAVAudioEmbeddedContainer*> oArrayAudioEmbedded;
pExObjects->GetRecordsByType(&oArrayAudioCD , true);
pExObjects->GetRecordsByType(&oArrayAudioMIDI , true);
pExObjects->GetRecordsByType(&oArrayWAVLink , true);
pExObjects->GetRecordsByType(&oArrayAudioEmbedded , true);
int nSize1 = oArrayAudioCD.size();
int nSize2 = oArrayAudioMIDI.size();
int nSize3 = oArrayWAVLink.size();
int nSize4 = oArrayAudioEmbedded.size();
for (int nIndex = 0; nIndex < nSize2; ++nIndex)
for (int nIndex = 0; nIndex < oArrayAudioMIDI.size(); ++nIndex)
{
LoadExAudio(oArrayAudioMIDI[nIndex]);
}
for (int nIndex = 0; nIndex < nSize3; ++nIndex)
for (int nIndex = 0; nIndex < oArrayWAVLink.size(); ++nIndex)
{
LoadExAudio(oArrayWAVLink[nIndex]);
}
for (int nIndex = 0; nIndex < nSize4; ++nIndex)
for (int nIndex = 0; nIndex < oArrayAudioEmbedded.size(); ++nIndex)
{
DWORD dwKeySound = oArrayAudioEmbedded[nIndex]->m_nSoundID;
DWORD dwKeyObj = oArrayAudioEmbedded[nIndex]->m_oMedia.m_nExObjID;
......@@ -1267,7 +1174,7 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects)
m_oExMedia.m_arAudios.push_back(oAudio);
}
}
for (int nIndex = 0; nIndex < nSize1; ++nIndex)
for (int nIndex = 0; nIndex < oArrayAudioCD.size(); ++nIndex)
{
DWORD dwKeyObj = oArrayAudioCD[nIndex]->m_oMedia.m_nExObjID;
......@@ -1280,12 +1187,31 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects)
pInfo->m_bLoop = oArrayAudioCD[nIndex]->m_oMedia.m_bLoop;
}
}
// -----------------------------------------------------------
oArrayAudioCD.clear();
oArrayAudioMIDI.clear();
oArrayWAVLink.clear();
oArrayAudioEmbedded.clear();
//--------------------------------------------------------------------
std::vector<CRecordExHyperlinkContainer*> oArrayHyperlinkContainer;
pExObjects->GetRecordsByType(&oArrayHyperlinkContainer , true);
for (int nIndex = 0; nIndex < oArrayHyperlinkContainer.size(); ++nIndex)
{
std::vector<CRecordExHyperlinkAtom*> oArrayHyperlink;
std::vector<CRecordCString*> oArrayCString;
oArrayHyperlinkContainer[nIndex]->GetRecordsByType (&oArrayHyperlink, false);
oArrayHyperlinkContainer[nIndex]->GetRecordsByType (&oArrayCString, false);
if (oArrayCString.size() > 0 && oArrayHyperlink.size() > 0)
{
NSPresentationEditor::CExFilesInfo oInfo;
oInfo.m_dwID = oArrayHyperlink[0]->m_nHyperlinkID;
oInfo.m_strFilePath = oArrayCString[0]->m_strText;
m_oExMedia.m_arHyperlinks.push_back(oInfo);
}
}
}
void CPPTUserInfo::LoadExVideo(CRecordsContainer* pExObject)
......
......@@ -17,21 +17,20 @@ public:
CRecordDocument m_oDocument;
//todooo C++11 unsorted_map - m_arr .. Order
std::map<DWORD, CRecordSlide*> m_mapSlides;
std::map<DWORD, CRecordSlide*> m_mapMasters;
std::map<DWORD, CRecordSlide*> m_mapNotes;
std::vector<DWORD> m_arrSlidesOrder;
std::vector<DWORD> m_arrMastersOrder;
std::vector<DWORD> m_arrNotesOrder;
std::map<DWORD, CRecordSlide*> m_mapSlides;
std::map<DWORD, CRecordSlide*> m_mapMasters;
std::map<DWORD, CRecordSlide*> m_mapNotes;
std::vector<DWORD> m_arrSlidesOrder;
std::vector<DWORD> m_arrMastersOrder;
std::vector<DWORD> m_arrNotesOrder;
// id /
std::map<DWORD, LONG> m_mapMasterToTheme;
std::map<DWORD, LONG> m_mapMasterToLayout;
std::map<DWORD, LONG> m_mapMasterToTheme;
// original id -> natural id
std::map<DWORD, DWORD> m_mapMasterOriginalIds;
std::map<DWORD, DWORD> m_mapMasterOriginalIds;
// -
std::vector<CSlideInfo> m_arSlideWrapper;
......@@ -39,33 +38,31 @@ public:
// - .
// () -
std::vector<CFont> m_arrFonts;
NSPresentationEditor::CTextStyles m_oDefaultTextStyle;
std::vector<CRecordBlipStoreContainer*> m_arrBlipStore;
std::vector<CFont> m_arrFonts;
NSPresentationEditor::CTextStyles m_oDefaultTextStyle;
// ()
CPPTDocumentInfo* m_pDocumentInfo;
size_t m_lIndexThisUser;
CPPTDocumentInfo* m_pDocumentInfo;
size_t m_lIndexThisUser;
// Animations structures
std::map <DWORD, Animations::CSlideTimeLine*> m_mapAnimations;
double m_nWriteSlideTimeOffset;
double m_nWriteSlideTime;
double m_nWriteSlideTimeOffset;
double m_nWriteSlideTime;
std::map<DWORD, CSlideShowSlideInfoAtom> m_mapTransitions;
std::map<DWORD, CSlideShowSlideInfoAtom> m_mapTransitions;
// "" -
std::vector<bool> m_arEmptyPictures;
bool m_bIsSetupEmpty;
std::vector<bool> m_arEmptyPictures;
bool m_bIsSetupEmpty;
CString m_strFileDirectory;
CString m_strFileDirectory;
// ex -
CExMedia m_oExMedia;
// DEBUG information
CString m_strXmlInfo;
std::vector<CColor> m_oSchemeColors;
public:
......@@ -87,8 +84,6 @@ public:
void LoadNoMainMaster (DWORD dwMasterID, const LONG& lOriginWidth, const LONG& lOriginHeight);
void LoadMainMaster (DWORD dwMasterID, const LONG& lOriginWidth, const LONG& lOriginHeight);
void UpdateXMLInfo();
void LoadSlideFromPrevUsers (DWORD dwSlideID);
void LoadMasterFromPrevUsers(DWORD dwSlideID);
void LoadNoteFromPrevUsers (DWORD dwSlideID);
......@@ -170,16 +165,19 @@ public:
oScheme = oArrayMem;
}
CString ConvertLayoutType(INT nGeom, BYTE* pPlaceholders)
std::wstring ConvertLayoutType(INT nGeom, BYTE* pPlaceholders)
{
switch (nGeom)
{
case 0x00:
case 0x02:
case 0x00: //SL_TitleSlide
case 0x02: //SL_MasterTitle
return _T("title");
case 0x01:
case 0x01: // SL_TitleBody
{
NSOfficePPT::PlaceholderEnum phbody = (NSOfficePPT::PlaceholderEnum)pPlaceholders[0];
int ind = 0;
if (pPlaceholders[0] == 13 && pPlaceholders[1] != 0) ind++;
NSOfficePPT::PlaceholderEnum phbody = (NSOfficePPT::PlaceholderEnum)pPlaceholders[ind];
switch (phbody)
{
case NSOfficePPT::MasterTitle:
......@@ -195,9 +193,9 @@ public:
}
return _T("obj");
}
case 0x07:
case 0x07: //SL_TitleOnly
return _T("titleOnly");
case 0x08:
case 0x08: //SL_TwoColumns
{
NSOfficePPT::PlaceholderEnum leftType = (NSOfficePPT::PlaceholderEnum)pPlaceholders[1];
NSOfficePPT::PlaceholderEnum rightType = (NSOfficePPT::PlaceholderEnum)pPlaceholders[2];
......@@ -236,7 +234,7 @@ public:
}
return _T("twoObj");
}
case 0x09:
case 0x09: //SL_TwoRows
{
NSOfficePPT::PlaceholderEnum topType = (NSOfficePPT::PlaceholderEnum)pPlaceholders[1];
NSOfficePPT::PlaceholderEnum bottomType = (NSOfficePPT::PlaceholderEnum)pPlaceholders[2];
......@@ -247,7 +245,7 @@ public:
}
return _T("objOverTx");
}
case 0x0A:
case 0x0A: //SL_ColumnTwoRows
{
NSOfficePPT::PlaceholderEnum leftType = (NSOfficePPT::PlaceholderEnum)pPlaceholders[1];
......@@ -257,7 +255,7 @@ public:
}
return _T("txAndTwoObj");
}
case 0x0B:
case 0x0B: //SL_TwoRowsColumn
{
NSOfficePPT::PlaceholderEnum rightType = (NSOfficePPT::PlaceholderEnum)pPlaceholders[2];
......@@ -267,22 +265,24 @@ public:
}
return _T("twoObjAndTx");
}
case 0x0D:
case 0x0D: //SL_TwoColumnsRow
return _T("twoObjOverTx");
case 0x0F:
case 0x0E://SL_FourObjects
return _T("fourObj");
case 0x0F: //SL_BigObject
return _T("objOnly");
case 0x10:
case 0x10: //SL_Blank
return _T("blank");
case 0x0E:
return _T("fourObj");
case 0x11:
case 0x11: //SL_VerticalTitleBody
return _T("vertTitleAndTx");
case 0x12:
case 0x12: //SL_VerticalTwoRows
return _T("vertTx");
}
return _T("obj");
return _T("blank");
}
void AddAnimation (DWORD dwSlideID, double Width, double Height, IElement* pElement);
void AddAudioTransition (DWORD dwSlideID, CTransition* pTransition, const std::wstring& strFilePath);
LONG AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayoutAtom* layoutRecord, std::vector<CTextFullSettings> & text, bool addShapes = true);
};
......@@ -12,12 +12,6 @@
typedef BYTE BOOL1;
#define PSFLAG_CONTAINER 0xFF
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
#define PPT_DUMP_LOG FALSE // TRUE - xml
#else
#define PPT_DUMP_LOG FALSE //
#endif
#define PPT_DEFAULT_SLIDE_DURATION 5000
/////////////////////////////////////////////////////////////////////////
......
......@@ -70,21 +70,13 @@ public:
void ReadPersistDirectory()
{
bool bRes = SavePictures();
// ...
m_oDocumentInfo.ReadFromStream(&m_oCurrentUser, GetDocStream(), (CStringW)m_strMemoryForder);
m_oDocumentInfo.ReadFromStream(&m_oCurrentUser, GetDocStream(), m_strMemoryForder);
}
void ReadSlideList()
{
// .
// m_arLoadImageFlags
//std::vector<CRecordBlipStoreEntry*> oArrayBSE;
//m_oDocumentInfo.m_arUsers[0]->m_oDocument.GetRecordsByType(&oArrayBSE, true, false);
// ...
bool bRes = SavePictures();
if (m_oDocumentInfo.m_arUsers.size() > 0)
{
......@@ -96,11 +88,6 @@ public:
DWORD offset = pPair->second;
StreamUtils::StreamSeek((long)offset, GetDocStream());
}
if (PPT_DUMP_LOG)
{
ParseForSlideLists();
}
}
protected:
......@@ -152,36 +139,6 @@ protected:
return m_pPictureStream;
}
DWORD ParseForSlideLists()
{
POLE::Stream *pStm = GetDocStream();
SRecordHeader oHeader;
//DWORD nRd = 0;
XmlUtils::CXmlWriter oWriter;
oWriter.WriteNodeBegin(_T("PPTFile"));
while (TRUE)
{
/////////////////////////////////////////////
// xml
if ( oHeader.ReadFromStream(pStm) == false )
break;
oHeader.ToXmlWriter(&oWriter, pStm);
}
oWriter.WriteNodeEnd(_T("PPTFile"));
CDirectory::SaveToFile(_T("C:\\PPT.xml"), oWriter.GetXmlString());
//oWriter.SaveToFile(_T("C:\\PPT.xml"));
return 0;
}
bool SavePictures()
{
POLE::Stream* pStream = GetPictureStream();
......@@ -199,16 +156,9 @@ protected:
while (TRUE)
{
/*if (m_lImagesCount < m_oDocumentInfo.m_arEmptyPictures.GetCount())
{
if (m_oDocumentInfo.m_arEmptyPictures[m_lImagesCount])
{
++m_lImagesCount;
continue;
}
}*/
CMetaFileBuffer oMetaFile;
CString sExt = L".jpg";
if (oHeader.ReadFromStream(pStream) == false )
{
......@@ -234,7 +184,8 @@ protected:
StreamUtils::StreamSkip(lOffset, pStream);
lOffset += 34;
oMetaFile.m_bIsValid = TRUE;
oMetaFile.m_bIsValid = TRUE;
oMetaFile.m_sExtension = L".emf";
CMetaHeader oMetaHeader;
oMetaHeader.FromStream(pStream);
......@@ -276,7 +227,8 @@ protected:
lOffset += 34;
oMetaFile.m_bIsValid = TRUE;
oMetaFile.m_bIsValid = TRUE;
oMetaFile.m_sExtension = L".wmf";
CMetaHeader oMetaHeader;
oMetaHeader.FromStream(pStream);
......@@ -315,7 +267,8 @@ protected:
StreamUtils::StreamSkip(lOffset, pStream);
lOffset += 34;
oMetaFile.m_bIsValid = TRUE;
oMetaFile.m_bIsValid = TRUE;
oMetaFile.m_sExtension = L".wmf";
CMetaHeader oMetaHeader;
oMetaHeader.FromStream(pStream);
......@@ -352,6 +305,8 @@ protected:
lOffset = 33;
}
StreamUtils::StreamSkip(lOffset, pStream);
sExt = _T(".jpg");
break;
}
case RECORD_TYPE_ESCHER_BLIP_PNG:
......@@ -365,6 +320,8 @@ protected:
lOffset = 33;
}
StreamUtils::StreamSkip(lOffset, pStream);
sExt = _T(".png");
break;
}
case RECORD_TYPE_ESCHER_BLIP_DIB:
......@@ -378,6 +335,8 @@ protected:
lOffset = 33;
}
StreamUtils::StreamSkip(lOffset, pStream);
sExt = _T(".bmp");
break;
}
case RECORD_TYPE_ESCHER_BLIP_TIFF:
......@@ -391,6 +350,8 @@ protected:
lOffset = 33;
}
StreamUtils::StreamSkip(lOffset, pStream);
sExt = _T(".tif");
break;
}
default:
......@@ -401,50 +362,52 @@ protected:
if (oMetaFile.m_bIsValid)
{
CString strFile = CDirectory::ToString(++m_lImagesCount) + _T(".jpg");
CString strFile = CString(L"Image ") + CDirectory::ToString(++m_lImagesCount) + oMetaFile.m_sExtension;
CFile fileMeta;
HRESULT hr = fileMeta.CreateFile((CString)m_strMemoryForder + FILE_SEPARATOR_STR + strFile);
HRESULT hr = fileMeta.CreateFile(m_strMemoryForder + FILE_SEPARATOR_STR + strFile);
if (hr == S_OK)
{
oMetaFile.ToFile(&fileMeta);
fileMeta.CloseFile();
}
m_oDocumentInfo.m_mapStoreImageFile[m_lImagesCount] = string2std_string(strFile);
continue;
}
BYTE* pImage = new BYTE[oHeader.RecLen - lOffset];
//StreamUtils::StreamSkip(lOffset, pStream);
pStream->read(pImage, oHeader.RecLen - lOffset);
CString strFile = CDirectory::ToString(++m_lImagesCount) + _T(".jpg");
CString strFile = CString(L"Image ") + CDirectory::ToString(++m_lImagesCount) + sExt;
CFile fileJpeg;
HRESULT hr = fileJpeg.CreateFile((CString)m_strMemoryForder+ FILE_SEPARATOR_STR + strFile);
CFile fileImage;
HRESULT hr = fileImage.CreateFile(m_strMemoryForder+ FILE_SEPARATOR_STR + strFile);
if (hr == S_OK)
{
if (RECORD_TYPE_ESCHER_BLIP_DIB == oHeader.RecType)
{
WORD vtType = 0x4D42;
fileJpeg.WriteFile((void*)&vtType, 2);
fileImage.WriteFile((void*)&vtType, 2);
DWORD dwLen = oHeader.RecLen - lOffset;
fileJpeg.WriteFile((void*)&dwLen, 4);
fileImage.WriteFile((void*)&dwLen, 4);
DWORD dwRes = 0;
fileJpeg.WriteFile((void*)&dwRes, 4);
fileImage.WriteFile((void*)&dwRes, 4);
DWORD dwOffset = 2;
fileJpeg.WriteFile((void*)&dwOffset, 4);
fileImage.WriteFile((void*)&dwOffset, 4);
}
fileJpeg.WriteFile((void*)pImage, oHeader.RecLen - lOffset);
fileJpeg.CloseFile();
fileImage.WriteFile((void*)pImage, oHeader.RecLen - lOffset);
fileImage.CloseFile();
}
m_oDocumentInfo.m_mapStoreImageFile[m_lImagesCount] = string2std_string(strFile);
delete[] pImage;
}
else
{
// ...
m_lImagesCount++;
continue;
}
}
......@@ -466,6 +429,5 @@ public:
std::vector<bool> m_arLoadImageFlags;
DWORD m_lImagesCount;
public:
CPPTDocumentInfo m_oDocumentInfo;
CPPTDocumentInfo m_oDocumentInfo;
};
......@@ -269,34 +269,13 @@ public:
pHeader->Checksum ^= (pHeader->Reserved & 0x0000FFFFL);
pHeader->Checksum ^= ((pHeader->Reserved & 0xFFFF0000L) >> 16);
}
//
// static void DecompressDeflate(BYTE* pSrc, LONG lSrcSize, BYTE** ppDst, LONG& lDstSize)
// {
//#if defined(_WIN32) || defined (_WIN64)
// CComPtr<IEncodingFilterFactory> pEFF;
// HRESULT hr = pEFF.CoCreateInstance(CLSID_StdEncodingFilterFac);
// CComPtr<IDataFilter> pDF;
// //accquire suitable filter
// if (!pEFF || FAILED(pEFF->GetDefaultFilter( L"deflate", L"text", &pDF)))
// return;
// //temporary out buffers
// BYTE* outBuff = new BYTE[200000];
// DWORD dwOutBuffSize = sizeof(outBuff);
// long dwRead = 0, dwWritten = 0;
// //encode chunk of data
// //hr = pDF->DoDecode(0, lSrcSize, pSrc, lDstSize, *ppDst, lSrcSize, &dwRead, &dwWritten, 0);
// hr = pDF->DoDecode(0, lSrcSize, pSrc, dwOutBuffSize, outBuff, lSrcSize, &dwRead, &dwWritten, 0);
//#endif
// }
};
class CMetaFileBuffer
{
public:
bool m_bIsValid;
bool m_bIsValid;
CString m_sExtension;
private:
BYTE* m_pMetaHeader;
BYTE* m_pMetaFile;
......
......@@ -148,13 +148,14 @@ IRecord* CreateByType(SRecordHeader oHeader)
//CREATE_BY_TYPE(RECORD_TYPE_FONT_EMBEDDEDDATA , CRecordFontEmbedDataBlob)
//CREATE_BY_TYPE(RECORD_TYPE_METAFILE , CRecordMetafileBlob)
CREATE_BY_TYPE(RECORD_TYPE_CSTRING , CRecordCString)
//CREATE_BY_TYPE(RECORD_TYPE_EXOLEOBJ_ATOM , CRecordExOleObjAtom)
//CREATE_BY_TYPE(RECORD_TYPE_EXEMBEDATOM , CRecordExOleEmbedAtom)
CREATE_BY_TYPE(RECORD_TYPE_EXOLEOBJ_ATOM , CRecordExOleObjAtom)
CREATE_BY_TYPE(RECORD_TYPE_EXEMBEDATOM , CRecordExOleEmbedAtom)
//CREATE_BY_TYPE(RECORD_TYPE_BOOKMARK_ENTITY_ATOM , CRecordBookmarkEntityAtom)
//CREATE_BY_TYPE(RECORD_TYPE_EXLINK_ATOM , CRecordExOleLinkAtom)
//CREATE_BY_TYPE(RECORD_TYPE_SRKINSOKU_ATOM , CRecordKinsokuAtom)
//CREATE_BY_TYPE(RECORD_TYPE_EXHYPERLINK_ATOM , CRecordExHyperlinkAtom)
CREATE_BY_TYPE(RECORD_TYPE_EXHYPERLINK , CRecordExHyperlinkContainer)
CREATE_BY_TYPE(RECORD_TYPE_EXHYPERLINK_ATOM , CRecordExHyperlinkAtom)
//CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordSlideNumberMCAtom)
CREATE_BY_TYPE(RECORD_TYPE_HEADERSFOOTERS_ATOM , CRecordHeadersFootersAtom)
//CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordMouseTextInteractiveInfoAtom)
......@@ -222,10 +223,10 @@ IRecord* CreateByType(SRecordHeader oHeader)
pRecord = new CUnknownRecord();
}
}
#ifdef _DEBUG
wchar_t str[1024]={};
swprintf(str, L"%s record type: %xd\n" , GetRecordName((DWORD)oHeader.RecType).GetBuffer(), oHeader.RecType);
std::wcout << str;
#endif
//#ifdef _DEBUG
//wchar_t str[1024]={};
//swprintf(str, L"%s record type: %xd\n" , GetRecordName((DWORD)oHeader.RecType).GetBuffer(), oHeader.RecType);
//std::wcout << str;
//#endif
return pRecord;
}
......@@ -3,6 +3,7 @@
#include "PPTFileDefines.h"
#include "../Reader/ReadStructures.h"
#include "../../../ASCPresentationEditor/OfficeDrawing/Shapes/BaseShape/PPTShape/Enums.h"
#include "../../../Common/3dParty/pole/pole.h"
using namespace NSPresentationEditor;
......
......@@ -48,12 +48,12 @@ public:
class CSlideInfo
{
public:
std::vector<CTextFullSettings> m_arTextPlaceHolders;
std::map<LONG, CElementInfo> m_mapElements;
//std::unordered_map<LONG, CElementInfo> m_mapElements;
std::vector<bool>* m_parEmptyPictures;
nullable_base<NSPresentationEditor::CTextStyles> m_pStyles[9];
std::vector<CTextFullSettings> m_arTextPlaceHolders;
std::map<LONG, CElementInfo> m_mapElements;
//std::unordered_map<LONG, CElementInfo> m_mapElements;
std::vector<bool>* m_parEmptyPictures;
std::map<int, std::wstring>* m_mapFilePictures;
nullable_base<NSPresentationEditor::CTextStyles> m_pStyles[9];
public:
CSlideInfo()
......@@ -71,24 +71,30 @@ public:
{
m_arTextPlaceHolders = oSrc.m_arTextPlaceHolders;
m_parEmptyPictures = oSrc.m_parEmptyPictures;
m_parEmptyPictures = oSrc.m_parEmptyPictures;
m_mapFilePictures = oSrc.m_mapFilePictures;
for (int i = 0; i < 9; ++i)
{
m_pStyles[i] = oSrc.m_pStyles[i];
}
//m_mapElements.clear();
//for (std::map<LONG, CElementInfo>::const_iterator it = oSrc.m_mapElements.begin(); it != oSrc.m_mapElements.end(); ++it)
//{
// m_mapElements.insert(std::pair<LONG, CElementInfo>(it->first,it->second));
//}
m_mapElements = oSrc.m_mapElements;
return *this;
}
std::wstring GetFileNamePicture(DWORD lIndex)
{
std::map<int, std::wstring>::iterator pic = m_mapFilePictures->find(lIndex);
if (pic != m_mapFilePictures->end())
{
return pic->second;
}
return _T("");
}
DWORD GetIndexPicture(DWORD lIndex)
{
if (NULL == m_parEmptyPictures)
......
......@@ -4,7 +4,7 @@
class CRecordClientAnchor : public CUnknownRecord
{
public:
SSmallRectAtom m_oBounds;
SRectAtom m_oBounds;
public:
......@@ -19,10 +19,21 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
m_oHeader = oHeader;
m_oBounds.Top = StreamUtils::ReadSHORT(pStream);
m_oBounds.Left = StreamUtils::ReadSHORT(pStream);
m_oBounds.Right = StreamUtils::ReadSHORT(pStream);
m_oBounds.Bottom = StreamUtils::ReadSHORT(pStream);
if (m_oHeader.RecLen == 0x00000008) //SSmallRectAtom
{
m_oBounds.Top = StreamUtils::ReadSHORT(pStream);
m_oBounds.Left = StreamUtils::ReadSHORT(pStream);
m_oBounds.Right = StreamUtils::ReadSHORT(pStream);
m_oBounds.Bottom = StreamUtils::ReadSHORT(pStream);
}
if (m_oHeader.RecLen == 0x00000010) //SRectAtom
{
m_oBounds.Top = StreamUtils::ReadLONG(pStream);
m_oBounds.Left = StreamUtils::ReadLONG(pStream);
m_oBounds.Right = StreamUtils::ReadLONG(pStream);
m_oBounds.Bottom = StreamUtils::ReadLONG(pStream);
}
}
virtual CString ToString()
{
......
#pragma once
#include "../../Reader/Records.h"
#include "GroupShapeContainer.h"
class CRecordDrawingContainer : public CRecordsContainer
......
#pragma once
#include <vector>
#include "ShapeContainer.h"
class CRecordGroupShapeContainer : public CRecordsContainer
......@@ -32,7 +34,7 @@ public:
// ...
std::vector<CRecordShapeContainer*> oArrayShapes;
this->GetRecordsByType(&oArrayShapes, false, false);
GetRecordsByType(&oArrayShapes, false, false);
int nIndexBreak = -1;
for (int nIndex = 0; nIndex < oArrayShapes.size(); ++nIndex)
......
......@@ -5,6 +5,7 @@ class CRecordShape : public CUnknownRecord
{
public:
UINT m_nID;
UINT m_nShapeID;
bool m_bGroup;
bool m_bChild;
......@@ -54,6 +55,8 @@ public:
{
StreamUtils::StreamSkip(lSize, pStream);
}
m_nShapeID = m_oHeader.RecInstance;
}
virtual CString ToString()
{
......
#pragma once
#include "Shape.h"
#include "ShapeProperties.h"
#include "../ExObjRefAtom.h"
#include "../TextBytesAtom.h"
#include "../TextCharsAtom.h"
......@@ -8,14 +12,16 @@
#include "../OutlineTextRefAtom.h"
#include "../InteractiveInfoAtom.h"
#include "../TextInteractiveInfoAtom.h"
//#include "../../Reader/Slide.h"
#include "../../../../ASCPresentationEditor/OfficeDrawing/Document.h"
#include "Shape.h"
#include "ShapeProperties.h"
#include "../../Reader/ClassesAtom.h"
#include "../../Reader/SlideInfo.h"
#include "../../../../ASCPresentationEditor/OfficeDrawing/Document.h"
#include "../../../../ASCPresentationEditor/OfficeDrawing/Shapes/BaseShape/PPTShape/ElementSettings.h"
#include "../../../../DesktopEditor/raster/BgraFrame.h"
#include "../../../../Common/DocxFormat/source/Base/Types_32.h"
const double EMU_MM = 36000;
using namespace NSOfficeDrawing;
......@@ -24,6 +30,162 @@ using namespace NSPresentationEditor;
class CPPTElement
{
public:
bool ChangeBlack2ColorImage(std::wstring image_path, int rgbColor1, int rgbColor2)
{
CBgraFrame bgraFrame;
if (bgraFrame.OpenFile(image_path))
{
int smpl = abs(bgraFrame.get_Stride() / bgraFrame.get_Width());
BYTE * rgb = bgraFrame.get_Data();
BYTE R1 = (BYTE)(rgbColor1);
BYTE G1 = (BYTE)(rgbColor1 >> 8);
BYTE B1 = (BYTE)(rgbColor1 >> 16);
BYTE R2 = (BYTE)(rgbColor2);
BYTE G2 = (BYTE)(rgbColor2 >> 8);
BYTE B2 = (BYTE)(rgbColor2 >> 16);
for (int i = 0 ; i < bgraFrame.get_Width() * bgraFrame.get_Height(); i++)
{
if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00)
{
rgb[i * smpl + 0 ] = R1;
rgb[i * smpl + 1 ] = G1;
rgb[i * smpl + 2 ] = B1;
}
else
{
rgb[i * smpl + 0 ] = R2;
rgb[i * smpl + 1 ] = G2;
rgb[i * smpl + 2 ] = B2;
}
}
bgraFrame.SaveFile(image_path, 1);
return true;
}
return false;
}
CColor CorrectSysColor(int nColorCode, CShapeElement* pElement, CTheme* pTheme)
{
if (pElement == NULL) return CColor();
CShape* pShape = &pElement->m_oShape;
CColor color;
unsigned short nParameter = (unsigned short)(( nColorCode >> 16 ) & 0x00ff); // the HiByte of nParameter is not zero, an exclusive AND is helping :o
unsigned short nFunctionBits = (unsigned short)(( nColorCode & 0x00000f00 ) >> 8 );
unsigned short nAdditionalFlags = (unsigned short)(( nColorCode & 0x0000f000) >> 8 );
unsigned short nColorIndex = (unsigned short) ( nColorCode & 0x00ff);
unsigned short nPropColor = 0;
switch (nColorIndex)
{
case 0xF0: color = pShape->m_oBrush.Color1; break;
case 0xF1:
{
if (pElement->m_bLine) color = pShape->m_oPen.Color;
else color = pShape->m_oBrush.Color1;
}break;
case 0xF2: color = pShape->m_oPen.Color; break;
case 0xF3: color = pShape->m_oShadow.Color; break;
case 0xF4: break; ///this
case 0xF5: color = pShape->m_oBrush.Color2; break;
case 0xF6: break; //lineBackColor
case 0xF7: //FillThenLine
case 0xF8: //colorIndexMask
color = pShape->m_oBrush.Color1; break;
default:
//from table
break;
}
if (color.m_lSchemeIndex != -1)
{
// (
color = pTheme->m_arColorScheme[color.m_lSchemeIndex];
}
//if ( nCProp && ( nPropColor & 0x10000000 ) == 0 ) // beware of looping recursive
// color = CorrectSysColor( nPropColor, pShape);
if( nAdditionalFlags & 0x80 ) // make color gray
{
BYTE nZwi = 0x7f;//= aColor.GetLuminance();
color.SetRGB(nZwi, nZwi, nZwi);
}
switch( nFunctionBits )
{
case 0x01 : // darken color by parameter
{
color.SetR ( static_cast<BYTE> ( ( nParameter * color.GetR() ) >> 8 ) );
color.SetG ( static_cast<BYTE> ( ( nParameter * color.GetG() ) >> 8 ) );
color.SetB ( static_cast<BYTE> ( ( nParameter * color.GetB() ) >> 8 ) );
}
break;
case 0x02 : // lighten color by parameter
{
unsigned short nInvParameter = ( 0x00ff - nParameter ) * 0xff;
color.SetR( static_cast<BYTE>( ( nInvParameter + ( nParameter * color.GetR() ) ) >> 8 ) );
color.SetG( static_cast<BYTE>( ( nInvParameter + ( nParameter * color.GetG() ) ) >> 8 ) );
color.SetB( static_cast<BYTE>( ( nInvParameter + ( nParameter * color.GetB() ) ) >> 8 ) );
}
break;
case 0x03 : // add grey level RGB(p,p,p)
{
short nR = (short)color.GetR() + (short)nParameter;
short nG = (short)color.GetG() + (short)nParameter;
short nB = (short)color.GetB() + (short)nParameter;
if ( nR > 0x00ff ) nR = 0x00ff;
if ( nG > 0x00ff ) nG = 0x00ff;
if ( nB > 0x00ff ) nB = 0x00ff;
color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB );
}
break;
case 0x04 : // substract grey level RGB(p,p,p)
{
short nR = (short)color.GetR() - (short)nParameter;
short nG = (short)color.GetG() - (short)nParameter;
short nB = (short)color.GetB() - (short)nParameter;
if ( nR < 0 ) nR = 0;
if ( nG < 0 ) nG = 0;
if ( nB < 0 ) nB = 0;
color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB );
}
break;
case 0x05 : // substract from gray level RGB(p,p,p)
{
short nR = (short)nParameter - (short)color.GetR();
short nG = (short)nParameter - (short)color.GetG();
short nB = (short)nParameter - (short)color.GetB();
if ( nR < 0 ) nR = 0;
if ( nG < 0 ) nG = 0;
if ( nB < 0 ) nB = 0;
color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB );
}
break;
case 0x06 : // per component: black if < p, white if >= p
{
color.SetR( color.GetR() < nParameter ? 0x00 : 0xff );
color.SetG( color.GetG() < nParameter ? 0x00 : 0xff );
color.SetB( color.GetB() < nParameter ? 0x00 : 0xff );
}
break;
}
if ( nAdditionalFlags & 0x40 ) // top-bit invert
color.SetRGB( color.GetR() ^ 0x80, color.GetG() ^ 0x80, color.GetB() ^ 0x80 );
if ( nAdditionalFlags & 0x20 ) // invert color
color.SetRGB(0xff - color.GetR(), 0xff - color.GetG(), 0xff - color.GetB());
return color;
}
static inline LONG CorrectPlaceHolderType(const LONG& lType)
{
switch (lType)
......@@ -56,10 +218,12 @@ public:
return 9; // object
case 0x05: //PT_MasterNotesSlideImage
case 0x14: //PT_Graph //????
case 0x0B: //PT_NotesSlideImage
return 11; // slideImg
case 0x14: //PT_Graph //????
return 1; //chart
case 0x15: //PT_Table
return 14; // table
......@@ -111,6 +275,7 @@ public:
for (long i = 0; i < lCount; ++i)
{
SetUpPropertyImage((CImageElement*)pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]);
//SetUpPropertyShape((CImageElement*)pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]);
}
break;
}
......@@ -170,7 +335,10 @@ public:
}
case rotation:
{
pElement->m_dRotate = (double)((LONG)pProperty->m_lValue) / 0x00010000;
short Integral = (short)(pProperty->m_lValue >> 16);
short Fractional= (short)(pProperty->m_lValue);
pElement->m_dRotate = (double)(Integral + (Fractional / 65536.0));
return true;
}
case fFlipH:
......@@ -192,6 +360,38 @@ public:
return true;
}
case fNoLineDrawDash: //Line Style Boolean Properties
{
bool bNoLineDrawDash = GETBIT(pProperty->m_lValue, 0);
bool bLineFillShape = GETBIT(pProperty->m_lValue, 1);
bool bHitTestLine = GETBIT(pProperty->m_lValue, 2);
bool bLine = GETBIT(pProperty->m_lValue, 3);
bool bArrowheadsOK = GETBIT(pProperty->m_lValue, 4);
bool bInsetPenOK = GETBIT(pProperty->m_lValue, 5);
bool bInsetPen = GETBIT(pProperty->m_lValue, 6);
bool bLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 9);
bool bUsefNoLineDrawDash = GETBIT(pProperty->m_lValue, 16);
bool bUsefLineFillShape = GETBIT(pProperty->m_lValue, 17);
bool bUsefHitTestLine = GETBIT(pProperty->m_lValue, 18);
bool bUsefLine = GETBIT(pProperty->m_lValue, 19);
bool bUsefArrowheadsOK = GETBIT(pProperty->m_lValue, 20);
bool bUsefInsetPenOK = GETBIT(pProperty->m_lValue, 21);
bool bUsefInsetPen = GETBIT(pProperty->m_lValue, 22);
bool bUsefLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 25);
if (bUsefLine)
pElement->m_bLine = bLine;
return true;
}
case lineStyle:
case lineDashStyle://from Complex
{
pElement->m_bLine = true;
return true;
}
default:
break;
}
......@@ -214,10 +414,13 @@ public:
{
case Pib:
{
DWORD dwIndex = pInfo->GetIndexPicture(pProperty->m_lValue);
CString strVal = CDirectory::ToString(dwIndex);
pElement->m_strFileName = pElement->m_strFileName + strVal.GetBuffer() + L".jpg";
DWORD dwIndex = pInfo->GetIndexPicture(pProperty->m_lValue);
pElement->m_strFileName = pElement->m_strFileName + pInfo->GetFileNamePicture(dwIndex);
pElement->m_bImagePresent = true;
}break;
case pictureId://OLE identifier of the picture.
{
pElement->m_bOLE = true;
}break;
case pibName:
{
......@@ -378,42 +581,40 @@ public:
case NSOfficeDrawing::fillType:
{
DWORD dwType = pProperty->m_lValue;
if (NSOfficeDrawing::fillPattern == dwType ||
NSOfficeDrawing::fillTexture == dwType ||
NSOfficeDrawing::fillPicture == dwType)
switch(dwType)
{
//pElemProps->SetAt(CElementProperty::epBrushType, c_BrushTypeTexture);
//pElemProps->SetAt(CElementProperty::epBrushTxMode,
// (NSOfficeDrawing::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile);
pParentShape->m_oBrush.Type = c_BrushTypeTexture;
pParentShape->m_oBrush.TextureMode = (NSOfficeDrawing::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile;
}
else if (NSOfficeDrawing::fillShade == dwType ||
NSOfficeDrawing::fillShadeCenter == dwType ||
NSOfficeDrawing::fillShadeTitle == dwType)
{
pParentShape->m_oBrush.Type = c_BrushTypeVertical;
//pElemProps->SetAt(CElementProperty::epBrushType, c_BrushTypeVertical);
}
else if (NSOfficeDrawing::fillShadeShape == dwType || NSOfficeDrawing::fillShadeScale == dwType)
{
pParentShape->m_oBrush.Type = c_BrushTypeSolid;
//pElemProps->SetAt(CElementProperty::epBrushType, c_BrushTypeSolid);
}
else
{
pParentShape->m_oBrush.Type = c_BrushTypeSolid;
//pElemProps->SetAt(CElementProperty::epBrushType, c_BrushTypeSolid);
case NSOfficeDrawing::fillPattern:
{
pParentShape->m_oBrush.Type = c_BrushTypePattern;
//texture + change black to color2, white to color1
}break;
case NSOfficeDrawing::fillTexture :
case NSOfficeDrawing::fillPicture :
{
pParentShape->m_oBrush.Type = c_BrushTypeTexture;
pParentShape->m_oBrush.TextureMode = (NSOfficeDrawing::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile;
}break;
case NSOfficeDrawing::fillShadeCenter://1 color
case NSOfficeDrawing::fillShadeShape:
{
pParentShape->m_oBrush.Type = c_BrushTypeCenter;
}break;//
case NSOfficeDrawing::fillShadeTitle://2 colors and more
case NSOfficeDrawing::fillShade :
case NSOfficeDrawing::fillShadeScale:
{
pParentShape->m_oBrush.Type = c_BrushTypePathGradient1;
}break;
case NSOfficeDrawing::fillBackground:
{
pParentShape->m_oBrush.Type = c_BrushTypeNoFill;
}break;
}
break;
}
}break;
case NSOfficeDrawing::fillBlip:
{
DWORD dwIndex = pInfo->GetIndexPicture(pProperty->m_lValue);
CString strVal = CDirectory::ToString(dwIndex);
int nIndex = pParentShape->m_oBrush.TexturePath.rfind(FILE_SEPARATOR_CHAR);
int nLen = pParentShape->m_oBrush.TexturePath.length() - 1;
if (nLen != nIndex)
......@@ -422,45 +623,150 @@ public:
}
//pElemProps->SetAt(CElementProperty::epBrushTxPath, pParentShape->m_oBrush.TexturePath + strVal + L".jpg");
pParentShape->m_oBrush.TexturePath = pParentShape->m_oBrush.TexturePath + strVal.GetBuffer() + L".jpg";
pParentShape->m_oBrush.TexturePath = pParentShape->m_oBrush.TexturePath + pInfo->GetFileNamePicture(dwIndex);
if (pParentShape->m_oBrush.Type == c_BrushTypePattern)
{
int rgbColor1 = 0;
int rgbColor2 = 0xFFFFFF;
if (pParentShape->m_oBrush.Color1.m_lSchemeIndex == -1)
{
rgbColor1 = pParentShape->m_oBrush.Color1.GetLONG_RGB();
}
else
{
if ((pSlide) && (pSlide->m_arColorScheme.size() > 0))
{
rgbColor1 = pSlide->m_arColorScheme[pParentShape->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB();
}
else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0))
{
rgbColor1 = pTheme->m_arColorScheme[pParentShape->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB();
}
}
if (pParentShape->m_oBrush.Color2.m_lSchemeIndex == -1)
{
rgbColor2 = pParentShape->m_oBrush.Color2.GetLONG_RGB();
}
else
{
if ((pSlide) && (pSlide->m_arColorScheme.size() > 0))
{
rgbColor2 = pSlide->m_arColorScheme[pParentShape->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB();
}
else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0))
{
rgbColor2 = pTheme->m_arColorScheme[pParentShape->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB();
}
}
ChangeBlack2ColorImage(pParentShape->m_oBrush.TexturePath, rgbColor1, rgbColor2);
pParentShape->m_oBrush.Type = c_BrushTypeTexture;
pParentShape->m_oBrush.TextureMode = c_BrushTextureModeTile;
}
break;
}
case NSOfficeDrawing::fillColor:
{
SColorAtom oAtom;
oAtom.FromValue(pProperty->m_lValue);
//pElemProps->SetAt(CElementProperty::epBrushColor1, oAtom.ToValueProperty());
oAtom.ToColor(&pParentShape->m_oBrush.Color1);
pParentShape->m_oBrush.Type = c_BrushTypeSolid;
if(oAtom.bSysIndex)
pParentShape->m_oBrush.Color1 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme);
else
oAtom.ToColor(&pParentShape->m_oBrush.Color1);
if (pParentShape->m_oBrush.Type == c_BrushTypeNoFill )
pParentShape->m_oBrush.Type = c_BrushTypeSolid;
break;
}
case NSOfficeDrawing::fillBackColor:
{
SColorAtom oAtom;
oAtom.FromValue(pProperty->m_lValue);
//pElemProps->SetAt(CElementProperty::epBrushColor2, oAtom.ToValueProperty());
oAtom.ToColor(&pParentShape->m_oBrush.Color2);
break;
}
oAtom.FromValue(pProperty->m_lValue);
if(oAtom.bSysIndex)
pParentShape->m_oBrush.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme);
else
oAtom.ToColor(&pParentShape->m_oBrush.Color2);
}break;
case NSOfficeDrawing::fillOpacity:
{
//pElemProps->SetAt(CElementProperty::epBrushAlpha1, (std::min)(255, CDirectory::NormFixedPoint(pProperty->m_lValue, 255)));
pParentShape->m_oBrush.Alpha1 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255));
break;
}
case NSOfficeDrawing::fillBackOpacity:
{
pParentShape->m_oBrush.Alpha2 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255));
//pElemProps->SetAt(CElementProperty::epBrushAlpha2,(std::min)(255, CDirectory::NormFixedPoint(pProperty->m_lValue, 255)));
break;
}
case NSOfficeDrawing::fillRectLeft:
{
pParentShape->m_oBrush.Rect.X = pProperty->m_lValue;
pParentShape->m_oBrush.Rectable = true;
}break;
case NSOfficeDrawing::fillRectRight:
{
pParentShape->m_oBrush.Rect.Width = pProperty->m_lValue - pParentShape->m_oBrush.Rect.X;
pParentShape->m_oBrush.Rectable = true;
}break;
case NSOfficeDrawing::fillRectTop:
{
pParentShape->m_oBrush.Rect.Y = pProperty->m_lValue;
pParentShape->m_oBrush.Rectable = true;
}break;
case NSOfficeDrawing::fillRectBottom:
{
pParentShape->m_oBrush.Rect.Height = pProperty->m_lValue - pParentShape->m_oBrush.Rect.Y;
pParentShape->m_oBrush.Rectable = true;
}break;
case NSOfficeDrawing::fillBackground:
{
//bIsFilled = false;
break;
}
case NSOfficeDrawing::fillShadeType:
{
bool bShadeNone = GETBIT(pProperty->m_lValue, 31);
bool bShadeGamma = GETBIT(pProperty->m_lValue, 30);
bool bShadeSigma = GETBIT(pProperty->m_lValue, 29);
bool bShadeBand = GETBIT(pProperty->m_lValue, 28);
bool bShadeOneColor = GETBIT(pProperty->m_lValue, 27);
}break;
case NSOfficeDrawing::fillAngle:
{
}break;
case NSOfficeDrawing::fillFocus://relative position of the last color in the shaded fill
{
}break;
case NSOfficeDrawing::fillShadePreset:
{//value (int) from 0x00000088 through 0x0000009F or complex
}break;
case NSOfficeDrawing::fillShadeColors:
{//array of colors
struct _a
{
_INT32 color;
_INT32 position;
};
std::vector<_a> colors;
unsigned short nElems;
nElems = pProperty->m_lValue;
_INT32* compl = (_INT32*)pProperty->m_pOptions;
while(nElems--)
{
_a a1;
a1.color = *compl; compl++;
a1.position = *compl; compl++;
colors.push_back(a1);
}
}break;
case NSOfficeDrawing::fNoFillHitTest:
{
BYTE flag1 = (BYTE)(pProperty->m_lValue);
......@@ -492,19 +798,33 @@ public:
{
SColorAtom oAtom;
oAtom.FromValue(pProperty->m_lValue);
//pElemProps->SetAt(CElementProperty::epPenColor, oAtom.ToValueProperty());
oAtom.ToColor(&pParentShape->m_oPen.Color);
if (oAtom.bSysIndex)
pParentShape->m_oPen.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme);
else
oAtom.ToColor(&pParentShape->m_oPen.Color);
break;
}
case NSOfficeDrawing::lineOpacity:
{
//pElemProps->SetAt(CElementProperty::epPenAlpha, min(255, CDirectory::NormFixedPoint(pProperty->m_lValue, 255)));
pParentShape->m_oPen.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255));
break;
}
case NSOfficeDrawing::lineBackColor:
{
SColorAtom oAtom;
oAtom.FromValue(pProperty->m_lValue);
if (oAtom.bSysIndex)
pParentShape->m_oPen.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme);
else
oAtom.ToColor(&pParentShape->m_oPen.Color2);
}break;
case NSOfficeDrawing::lineWidth:
{
pParentShape->m_oPen.Size = (double)pProperty->m_lValue / EMU_MM;
pParentShape->m_oPen.Size = (double)pProperty->m_lValue / EMU_MM;
pElement->m_bLine = true;
//pElemProps->SetAt(CElementProperty::epPenWidth, pProperty->m_lValue);
break;
}
......@@ -550,7 +870,8 @@ public:
}
};
//pElemProps->SetAt(CElementProperty::epLineDash, nDashStyle);
pParentShape->m_oPen.DashStyle = nDashStyle;
pElement->m_bLine = true;
pParentShape->m_oPen.DashStyle = nDashStyle;
break;
}
case NSOfficeDrawing::lineJoinStyle:
......@@ -564,7 +885,6 @@ public:
break;
} // bevel
case 1:
{
nLineJoin = 1;
break;
......@@ -676,12 +996,20 @@ public:
break;
}
// text --------------------------------------------------------
case NSOfficeDrawing::gtextUNICODE:
case NSOfficeDrawing::gtextUNICODE://word art text
{
if (pProperty->m_bComplex && 0 < pProperty->m_lValue)
{
std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1);
//pParentShape->m_oText.m_sText = str;
if (!str.empty() && pParentShape->m_oText.m_arParagraphs.empty())
{
NSPresentationEditor::CParagraph p;
NSPresentationEditor::CSpan s;
s.m_strText = std_string2string(str);
p.m_arSpans.push_back(s);
pParentShape->m_oText.m_arParagraphs.push_back(p);
}
}
break;
}
......@@ -876,15 +1204,11 @@ public:
pParentShape->m_dTextMarginRight = 1.27;
pParentShape->m_dTextMarginY = 2.54;
pParentShape->m_dTextMarginBottom = 1.27;
//pElemProps->SetAt(CElementProperty::epTextMarginLeft, (DWORD)(2.54 * EMU_MM));
//pElemProps->SetAt(CElementProperty::epTextMarginTop, (DWORD)(2.54 * EMU_MM));
//pElemProps->SetAt(CElementProperty::epTextMarginRight, (DWORD)(1.27 * EMU_MM));
//pElemProps->SetAt(CElementProperty::epTextMarginBottom, (DWORD)(1.27 * EMU_MM));
}
}
break;
}
// geometry shape
// geometry shape
case NSOfficeDrawing::fFillOK:
{
BYTE flag1 = (BYTE)(pProperty->m_lValue);
......@@ -914,6 +1238,52 @@ public:
break;
}
case NSOfficeDrawing::shadowType:
{
//pParentShape->m_oShadow.Visible = true;
}break;
case NSOfficeDrawing::shadowColor:
{
//pParentShape->m_oShadow.Visible = true;
SColorAtom oAtom;
oAtom.FromValue(pProperty->m_lValue);
if (oAtom.bSysIndex)
pParentShape->m_oShadow.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme);
else
oAtom.ToColor(&pParentShape->m_oShadow.Color);
pParentShape->m_oShadow.Visible = true;
}break;
case NSOfficeDrawing::shadowOpacity:
{
pParentShape->m_oShadow.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255));
}break;
case NSOfficeDrawing::shadowHighlight:
{
//
}break;
case shadowOffsetX:
{
pParentShape->m_oShadow.DistanceX = ((int)pProperty->m_lValue) / EMU_MM;
}break;
case shadowOffsetY:
{
pParentShape->m_oShadow.DistanceY = ((int)pProperty->m_lValue) / EMU_MM;
}break;
case fshadowObscured:
{
bool fshadowObscured = GETBIT(pProperty->m_lValue, 0);
bool fShadow = GETBIT(pProperty->m_lValue, 1);
bool fUsefshadowObscured = GETBIT(pProperty->m_lValue, 16);
bool fUsefShadow = GETBIT(pProperty->m_lValue, 17);
if (fUsefShadow)
pParentShape->m_oShadow.Visible = fShadow;
if (fUsefShadow && fUsefshadowObscured)
pParentShape->m_oShadow.Visible = fshadowObscured;
}break;
default:
break;
}
......@@ -975,28 +1345,31 @@ public:
return CRecordsContainer::ToString();
}
virtual void GetElement(IElement** ppElement, CExMedia* pMapIDs,
long lSlideWidth, long lSlideHeight, CTheme* pTheme, CLayout* pLayout,
CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide = NULL)
virtual void GetElement (IElement** ppElement, CExMedia* pMapIDs,
long lSlideWidth, long lSlideHeight, CTheme* pTheme, CLayout* pLayout,
CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide = NULL)
{
if (NULL == ppElement)
if (NULL == ppElement)
return;
*ppElement = NULL;
std::vector<CRecordShape*> oArrayShape;
this->GetRecordsByType(&oArrayShape, true, true);
GetRecordsByType(&oArrayShape, true, true);
if (0 == oArrayShape.size())
return;
std::vector<CRecordShapeProperties*> oArrayOptions;
this->GetRecordsByType(&oArrayOptions, true, /*true*/false/*secondary & tetriary*/);
GetRecordsByType(&oArrayOptions, true, /*true*/false/*secondary & tetriary*/);
PPTShapes::ShapeType eType = (PPTShapes::ShapeType)oArrayShape[0]->m_oHeader.RecInstance;
ElementType elType = GetTypeElem((NSOfficeDrawing::SPT)oArrayShape[0]->m_oHeader.RecInstance);
ElementType elType = GetTypeElem((NSOfficeDrawing::SPT)oArrayShape[0]->m_oHeader.RecInstance);
LONG lMasterID = -1;
IElement * pElementLayout = NULL;
if (NULL != pSlide)
{
bool bIsMaster = oArrayShape[0]->m_bHaveMaster;
......@@ -1011,19 +1384,31 @@ public:
if (pLayout)
{
size_t nIndexMem = pLayout->m_arElements.size();
for (size_t nIndex = 0; nIndex < nIndexMem; ++nIndex)
{
if (lMasterID == pLayout->m_arElements[nIndex]->m_lID && (elType == pLayout->m_arElements[nIndex]->m_etType))
if (elType == pLayout->m_arElements[nIndex]->m_etType)
{
*ppElement = pLayout->m_arElements[nIndex]->CreateDublicate();
if (elType == etShape)
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(*ppElement);
if (NULL != pShape)
pShape->m_oShape.m_oText.m_arParagraphs.clear();
}
break;
if (pLayout->m_arElements[nIndex]->m_bPlaceholderSet == false)
{
pElementLayout = pLayout->m_arElements[nIndex]; //
pElementLayout->m_lID = lMasterID;
}
if (lMasterID == pLayout->m_arElements[nIndex]->m_lID)
{
*ppElement = pLayout->m_arElements[nIndex]->CreateDublicate();
if (elType == etShape)
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(*ppElement);
if (NULL != pShape)
pShape->m_oShape.m_oText.m_arParagraphs.clear();
}
break;
}
}
}
}
......@@ -1040,33 +1425,26 @@ public:
{
switch (eType)
{
//case sptMin:
case sptMax:
case sptNil:
{
break;
}
break;
case sptPictureFrame:
{
std::vector<CRecordExObjRefAtom*> oArrayEx;
this->GetRecordsByType(&oArrayEx, true, true);
GetRecordsByType(&oArrayEx, true, true);
CExFilesInfo oInfo;
std::wstring strPathPicture = _T("");
// ( )
CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone;
CExFilesInfo* pInfo = pMapIDs->Lock(0xFFFFFFFF, exType);
if (NULL != pInfo)
{
oInfo = *pInfo;
strPathPicture = oInfo.m_strFilePath + FILE_SEPARATOR_STR;
}
if (0 != oArrayEx.size())
{
CExFilesInfo* pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType);
pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType);
if (NULL != pInfo)
{
oInfo = *pInfo;
......@@ -1103,15 +1481,9 @@ public:
pLayout->m_arElements.push_back(pAudioElem);
}
CImageElement* pImageElem = new CImageElement();
pImageElem->m_strFileName = strPathPicture;
pElem = (IElement*)pImageElem;
//
//pElem = (IElement*)pAudioElem;
pElem = (IElement*)pAudioElem;
}
else
else
{
CImageElement* pImageElem = new CImageElement();
pImageElem->m_strFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR;
......@@ -1126,8 +1498,8 @@ public:
CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, eType);
if (true)//if (/* */OOXMLShapes::sptCustom != pShape->m_oShape.m_eType)
{
CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone;
CExFilesInfo* pTextureInfo = pMapIDs->Lock(0xFFFFFFFF, exType);
CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone;
CExFilesInfo * pTextureInfo = pMapIDs->Lock(0xFFFFFFFF, exType);
if (NULL != pTextureInfo)
{
......@@ -1135,6 +1507,18 @@ public:
}
pElem = (IElement*)pShape;
std::vector<CRecordExObjRefAtom*> oArrayEx;
GetRecordsByType(&oArrayEx, true, true);
if (0 != oArrayEx.size())
{
CExFilesInfo* pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType);
if (CExFilesInfo::eftHyperlink == exType && pInfo)
{
pShape->m_sHyperlink = pInfo->m_strFilePath;
}
}
}
else
{
......@@ -1143,23 +1527,51 @@ public:
}
break;
}
};
}
}
if (NULL == pElem)
return;
pElem->m_lID = oArrayShape[0]->m_nID;
// placeholder
std::vector<CRecordPlaceHolderAtom*> oArrayPlaceHolder;
GetRecordsByType(&oArrayPlaceHolder, true, true);
if (0 < oArrayPlaceHolder.size())
{
pElem->m_lPlaceholderID = (LONG)(oArrayPlaceHolder[0]->m_nPosition);
pElem->m_lPlaceholderType = (LONG)(oArrayPlaceHolder[0]->m_nPlacementID);
if (0 == pElem->m_lPlaceholderType)
pElem->m_lPlaceholderID = 1;
else if (15 == pElem->m_lPlaceholderType)//??
pElem->m_lPlaceholderID = -1;
pElem->m_lPlaceholderType = CPPTElement::CorrectPlaceHolderType(pElem->m_lPlaceholderType);
}
std::vector<CRecordRoundTripHFPlaceholder12Atom*> oArrayHFPlaceholder;
this->GetRecordsByType(&oArrayHFPlaceholder, true, true);
if (0 < oArrayHFPlaceholder.size())
{
pElem->m_lPlaceholderType = oArrayHFPlaceholder[0]->m_nPlacementID;//PT_MasterDate, PT_MasterSlideNumber, PT_MasterFooter, or PT_MasterHeader
pElem->m_lPlaceholderType = CPPTElement::CorrectPlaceHolderType(pElem->m_lPlaceholderType);
}
std::vector<CRecordClientAnchor*> oArrayAnchor;
this->GetRecordsByType(&oArrayAnchor, true, true);
bool bAnchor = false;
if (0 != oArrayAnchor.size())
{
pElem->m_rcBoundsOriginal.left = (LONG)oArrayAnchor[0]->m_oBounds.Left;
pElem->m_rcBoundsOriginal.top = (LONG)oArrayAnchor[0]->m_oBounds.Top;
pElem->m_rcBoundsOriginal.right = (LONG)oArrayAnchor[0]->m_oBounds.Right;
pElem->m_rcBoundsOriginal.bottom = (LONG)oArrayAnchor[0]->m_oBounds.Bottom;
bAnchor = true;
}
else
{
......@@ -1174,6 +1586,7 @@ public:
pElem->m_rcBoundsOriginal.bottom = oArrayChildAnchor[0]->m_oBounds.bottom;
RecalcGroupShapeAnchor(pElem->m_rcBoundsOriginal);
bAnchor = true;
}
else
{
......@@ -1187,14 +1600,11 @@ public:
}
else
{
// ...
pElem->m_rcBoundsOriginal.left = 0;
pElem->m_rcBoundsOriginal.top = 0;
pElem->m_rcBoundsOriginal.right = lSlideWidth;
pElem->m_rcBoundsOriginal.bottom = lSlideHeight;
//delete pElem;
//return;
// ...
pElem->m_rcBoundsOriginal.left = -1;
pElem->m_rcBoundsOriginal.top = -1;
pElem->m_rcBoundsOriginal.right = 0;
pElem->m_rcBoundsOriginal.bottom = 0;
}
}
}
......@@ -1207,18 +1617,30 @@ public:
pElem->m_bFlipH = oArrayShape[0]->m_bFlipH;
pElem->m_bFlipV = oArrayShape[0]->m_bFlipV;
if (pElementLayout && bAnchor)
{
pElementLayout->m_rcBoundsOriginal = pElem->m_rcBoundsOriginal;
pElementLayout->m_rcBounds = pElem->m_rcBounds;
pElementLayout->m_bPlaceholderSet = true;
}
//
CShapeElement* pShapeElem = dynamic_cast<CShapeElement*>(pElem);
if (NULL != pShapeElem)
{
CElementInfo oElementInfo;
oElementInfo.m_lMasterPlaceholderType = pElem->m_lPlaceholderType;
pShapeElem->m_oShape.m_dWidthLogic = ShapeSizeVML;
pShapeElem->m_oShape.m_dHeightLogic = ShapeSizeVML;
// textheader present
std::vector<CRecordTextHeaderAtom*> oArrayTextHeader;
this->GetRecordsByType(&oArrayTextHeader, true, true);
GetRecordsByType(&oArrayTextHeader, true, true);
if (0 < oArrayTextHeader.size())
{
pShapeElem->m_oShape.m_oText.m_lTextType = oArrayTextHeader[0]->m_nTextType;
......@@ -1234,45 +1656,13 @@ public:
//
std::vector<CRecordOutlineTextRefAtom*> oArrayTextRefs;
this->GetRecordsByType(&oArrayTextRefs, true, true);
GetRecordsByType(&oArrayTextRefs, true, true);
if (0 < oArrayTextRefs.size())
{
oElementInfo.m_lPersistIndex = oArrayTextRefs[0]->m_nIndex;
}
// placeholder
std::vector<CRecordPlaceHolderAtom*> oArrayPlace;
this->GetRecordsByType(&oArrayPlace, true, true);
if (0 < oArrayPlace.size())
{
pElem->m_lPlaceholderID = (LONG)(oArrayPlace[0]->m_nPosition);
pElem->m_lPlaceholderType = (LONG)(oArrayPlace[0]->m_nPlacementID);
oElementInfo.m_lMasterPlaceholderType = pElem->m_lPlaceholderType;
if (0 == pElem->m_lPlaceholderType)
pElem->m_lPlaceholderID = 1;
else if (15 == pElem->m_lPlaceholderType)//??
pElem->m_lPlaceholderID = -1;
pElem->m_lPlaceholderType = CPPTElement::CorrectPlaceHolderType(pElem->m_lPlaceholderType);
if (pElem->m_lPlaceholderID != -1)
{
pLayout->m_mapPlaceholders.insert(std::pair<LONG, LONG>(pElem->m_lPlaceholderID, pElem->m_lPlaceholderType));
}
}
std::vector<CRecordRoundTripHFPlaceholder12Atom*> oArrayHFPlaceholder;
this->GetRecordsByType(&oArrayHFPlaceholder, true, true);
if (0 < oArrayHFPlaceholder.size())
{
pElem->m_lPlaceholderType= oArrayHFPlaceholder[0]->m_nPlacementID;//PT_MasterDate, PT_MasterSlideNumber, PT_MasterFooter, or PT_MasterHeader
pElem->m_lPlaceholderType = CPPTElement::CorrectPlaceHolderType(pElem->m_lPlaceholderType);
}
CString strText = _T("");
// ...
std::vector<CRecordTextBytesAtom*> oArrayTextBytes;
......@@ -1305,7 +1695,7 @@ public:
if (0 != oArrayTextStyle.size())
{
oElementInfo.m_pStream = m_pStream;
oElementInfo.m_lOffsetTextStyle = oArrayTextStyle[0]->m_lOffsetInStream;
oElementInfo.m_lOffsetTextStyle = oArrayTextStyle[0]->m_lOffsetInStream;
}
std::vector<CRecordTextSpecInfoAtom*> oArrayTextProp;
......@@ -1340,34 +1730,31 @@ public:
pShapeElem->m_oActions.m_arRanges.push_back(oRange);
}
}
double dAngle = pShapeElem->m_dRotate;
if (0 <= dAngle)
{
LONG lCount = (LONG)dAngle / 360;
dAngle -= (lCount * 360.0);
}
else
{
LONG lCount = (LONG)dAngle / 360;
dAngle += ((-lCount + 1) * 360.0);
}
if (((dAngle > 45) && (dAngle < 135)) || ((dAngle > 225) && (dAngle < 315)))
{
double dW = pShapeElem->m_rcBounds.GetWidth();
double dH = pShapeElem->m_rcBounds.GetHeight();
// . 90 270 0 180 -
// 90 .
//double dAngle = pShapeElem->m_dRotate;
//if (0 <= dAngle)
//{
// LONG lCount = (LONG)dAngle / 360;
// dAngle -= (lCount * 360.0);
//}
//else
//{
// LONG lCount = (LONG)dAngle / 360;
// dAngle += ((-lCount + 1) * 360.0);
//}
//if (((dAngle > 45) && (dAngle < 135)) || ((dAngle > 225) && (dAngle < 315)))
//{
// double dW = pShapeElem->m_rcBounds.GetWidth();
// double dH = pShapeElem->m_rcBounds.GetHeight();
// double dCx = (pShapeElem->m_rcBounds.left + pShapeElem->m_rcBounds.right) / 2.0;
// double dCy = (pShapeElem->m_rcBounds.top + pShapeElem->m_rcBounds.bottom) / 2.0;
// pShapeElem->m_rcBounds.left = dCx - dH / 2.0;
// pShapeElem->m_rcBounds.right = dCx + dH / 2.0;
// pShapeElem->m_rcBounds.top = dCy - dW / 2.0;
// pShapeElem->m_rcBounds.bottom = dCy + dW / 2.0;
//}
double dCx = (pShapeElem->m_rcBounds.left + pShapeElem->m_rcBounds.right) / 2.0;
double dCy = (pShapeElem->m_rcBounds.top + pShapeElem->m_rcBounds.bottom) / 2.0;
pShapeElem->m_rcBounds.left = dCx - dH / 2.0;
pShapeElem->m_rcBounds.right = dCx + dH / 2.0;
pShapeElem->m_rcBounds.top = dCy - dW / 2.0;
pShapeElem->m_rcBounds.bottom = dCy + dW / 2.0;
}
pSlideWrapper->m_mapElements.insert(std::pair<LONG, CElementInfo>(pShapeElem->m_lID, oElementInfo));
SetUpTextStyle(strText, pTheme, pLayout, pElem, pThemeWrapper, pSlideWrapper, pSlide);
......@@ -1401,7 +1788,6 @@ public:
pElem->m_bIsBackground = (true == oArrayShape[0]->m_bBackground);
pElem->m_bHaveAnchor = (true == oArrayShape[0]->m_bHaveAnchor);
*ppElement = pElem;
}
......@@ -1876,7 +2262,7 @@ protected:
case sptTextCanUp:
case sptTextCanDown:
{
pShape->m_oShape.m_oText.m_arParagraphs.clear();
//pShape->m_oShape.m_oText.m_arParagraphs.clear();
pShape->m_oShape.m_oText.m_oAttributes.m_oTextBrush = pShape->m_oShape.m_oBrush;
......@@ -1894,7 +2280,7 @@ protected:
void ApplyHyperlink(CShapeElement* pShape, CColor& oColor)
{
std::vector<CTextRange>* pRanges = &pShape->m_oActions.m_arRanges;
std::vector<CTextRange>* pRanges = &pShape->m_oActions.m_arRanges;
CTextAttributesEx* pTextAttributes = &pShape->m_oShape.m_oText;
LONG lCountHyper = (LONG)pRanges->size();
......@@ -1952,4 +2338,5 @@ protected:
}
}
}
};
#pragma once
#include "../../Reader/Records.h"
#include "../../../../ASCPresentationEditor/OfficeDrawing/Shapes/BaseShape/PPTShape/ElementSettings.h"
class CRecordShapeProperties : public CUnknownRecord
{
......
#pragma once
#include "../Reader/Records.h"
class CRecordExHyperlinkContainer : public CRecordsContainer
{
public:
CRecordExHyperlinkContainer()
{
}
~CRecordExHyperlinkContainer()
{
}
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
CRecordsContainer::ReadFromStream(oHeader, pStream);
}
virtual CString ToString()
{
return CRecordsContainer::ToString();
}
};
class CRecordExHyperlinkAtom : public CUnknownRecord
{
UINT m_nHyperlinkID;
public:
UINT m_nHyperlinkID;
CRecordExHyperlinkAtom()
{
......@@ -17,7 +37,9 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
return CUnknownRecord::ReadFromStream(oHeader, pStream);
m_oHeader = oHeader;
m_nHyperlinkID = StreamUtils::ReadDWORD(pStream);
}
virtual CString ToString()
{
......
......@@ -17,11 +17,9 @@
#include "Drawing/DrawingGroup.h"
#include "Drawing/DrawingRecord.h"
#include "Drawing/GroupShape.h"
#include "Drawing/GroupShapeContainer.h"
#include "Drawing/Shape.h"
#include "Drawing/ShapeProperties.h"
#include "Drawing/TextBox.h"
#include "Drawing/ShapeContainer.h"
#include "Drawing/RegGroupItems.h"
#include "Drawing/DrawingContainer.h"
......
......@@ -918,6 +918,10 @@
<Filter
Name="PresentationEditor"
>
<File
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Attributes.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\Converter.cpp"
>
......@@ -962,6 +966,10 @@
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Layout.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Shapes\Shape.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\ShapeWriter.cpp"
>
......@@ -974,6 +982,10 @@
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Slide.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Structures.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\StylesWriter.h"
>
......@@ -1038,6 +1050,10 @@
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Theme.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\XmlWriter.h"
>
</File>
</Filter>
<Filter
Name="OOXWriter"
......
......@@ -139,7 +139,24 @@ namespace NSBinPptxRW
s.Replace(_T("\""), _T("&quot;"));
WriteString(s);
}
AVSINLINE void WriteStringXML(const std::wstring & wString)
{
std::wstring buffer;
buffer.reserve(wString.size());
for(size_t pos = 0; pos != wString.size(); ++pos)
{
switch(wString[pos])
{
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
default: buffer.append(&wString[pos], 1); break;
}
}
WriteString(buffer);
}
AVSINLINE size_t GetCurSize()
{
return m_lSizeCur;
......
......@@ -11,7 +11,7 @@
#include "Effects.h"
#include "../../Common/DocxFormat/Source/XML/xmlutils.h"
#include "../../Common/ASCUtils.h"
#include "XmlWriter.h"
#include "./XmlWriter.h"
......@@ -27,7 +27,9 @@ namespace NSPresentationEditor
{
eftNone = 0,
eftVideo = 1,
eftAudio = 2
eftAudio = 2,
eftHyperlink= 3,
eftObject = 4
};
public:
DWORD m_dwID;
......@@ -78,6 +80,7 @@ namespace NSPresentationEditor
std::vector<CExFilesInfo> m_arVideos;
std::vector<CExFilesInfo> m_arImages;
std::vector<CExFilesInfo> m_arAudios;
std::vector<CExFilesInfo> m_arHyperlinks;
std::vector<CExFilesInfo> m_arAudioCollection;
......@@ -116,7 +119,19 @@ namespace NSPresentationEditor
return *this;
}
CExFilesInfo* LockHyperlink(DWORD dwID)
{
size_t nCount = m_arHyperlinks.size();
for (size_t i = 0; i < nCount; ++i)
{
if (dwID == m_arHyperlinks[i].m_dwID)
{
return &m_arHyperlinks[i];
}
}
return NULL;
}
CExFilesInfo* LockVideo(DWORD dwID)
{
size_t nCount = m_arVideos.size();
......@@ -174,6 +189,12 @@ namespace NSPresentationEditor
{
CExFilesInfo* pInfo = NULL;
pInfo = LockHyperlink(dwID);
if (NULL != pInfo)
{
eType = CExFilesInfo::eftHyperlink;
return pInfo;
}
pInfo = LockVideo(dwID);
if (NULL != pInfo)
{
......@@ -313,6 +334,21 @@ namespace NSPresentationEditor
m_lSchemeIndex = -1;
}
void SetRGB(BYTE r, BYTE g, BYTE b)
{
R = r;
G = g;
B = b;
m_lSchemeIndex = -1;
}
void SetR(BYTE r){ R = r; }
void SetG(BYTE g){ G = g; }
void SetB(BYTE b){ B = b; }
BYTE GetR(){ return R; }
BYTE GetG(){ return G; }
BYTE GetB(){ return B; }
friend bool operator==(const CColor& color1, const CColor& color2)
{
......@@ -428,6 +464,7 @@ namespace NSPresentationEditor
LONG Align;
double MiterLimit;
CColor Color2; //backLine
public:
void GetDashPattern(double* arrDashPattern, long& nCount) const
......@@ -473,7 +510,7 @@ namespace NSPresentationEditor
Alpha = dNewAlpha;
}
bool IsEqual(CPen* pPen)
bool IsEqual(CPen* pPen)
{
if (NULL == pPen)
return false;
......@@ -512,7 +549,6 @@ namespace NSPresentationEditor
}
void SetDefaultParams()
{
Color = 0;
Alpha = 255;
Size = 0.26458;
......@@ -524,9 +560,12 @@ namespace NSPresentationEditor
DashPattern = NULL;
Count = 0;
DashOffset = 0;
Align = Gdiplus::PenAlignmentCenter;
MiterLimit = 0.5;
Color.SetRGB (0x00, 0x00, 0x00);
Color2.SetRGB (0xff, 0xff, 0xff);
DashOffset = 0;
Align = Gdiplus::PenAlignmentCenter;
MiterLimit = 0.5;
}
......@@ -542,14 +581,15 @@ namespace NSPresentationEditor
}
CPen& operator=(const CPen& other)
{
Color = other.Color;
Alpha = other.Alpha;
Size = other.Size;
Color = other.Color;
Color2 = other.Color2;
Alpha = other.Alpha;
Size = other.Size;
DashStyle = other.DashStyle;
LineStartCap = other.LineStartCap;
LineEndCap = other.LineEndCap;
LineJoin = other.LineJoin;
DashStyle = other.DashStyle;
LineStartCap = other.LineStartCap;
LineEndCap = other.LineEndCap;
LineJoin = other.LineJoin;
RELEASEARRAYOBJECTS(DashPattern);
Count = other.Count;
......@@ -603,7 +643,7 @@ namespace NSPresentationEditor
}
inline CString ToXmlWriter(NSPresentationEditor::CXmlWriter* pWriter)
{
pWriter->WriteNodeBegin(_T("pen"), true);
pWriter->WriteNodeBegin(_T("pen"), true);
pWriter->WriteAttributeString(_T("color"), Color.ToString());
pWriter->WriteAttributeLONG(_T("alpha"), Alpha);
pWriter->WriteAttributeDouble(_T("size"), Size);
......@@ -612,8 +652,8 @@ namespace NSPresentationEditor
pWriter->WriteAttributeDouble(_T("line-start-cap"), (LONG)LineStartCap);
pWriter->WriteAttributeDouble(_T("line-end-cap"), (LONG)LineEndCap);
pWriter->WriteAttributeDouble(_T("line-join"), (LONG)LineJoin);
pWriter->WriteNodeEnd(_T("pen"), true);
pWriter->WriteNodeEnd(_T("pen"), true);
return CString(_T(""));
}
};
......@@ -630,11 +670,11 @@ namespace NSPresentationEditor
long Alpha1;
long Alpha2;
std::wstring TexturePath;
long TextureAlpha;
long TextureMode;
std::wstring TexturePath;
long TextureAlpha;
long TextureMode;
bool Rectable;
bool Rectable;
Gdiplus::RectF Rect;
double LinearAngle;
......@@ -1023,12 +1063,12 @@ namespace NSPresentationEditor
void SetDefaultParams()
{
Visible = false;
DistanceX = 15;
DistanceY = 15;
Visible = false;
DistanceX = 0.1;
DistanceY = 0.1;
BlurSize = 0;
Color = 0;
Alpha = 120;
Alpha = 255;
}
public:
......
......@@ -5,7 +5,7 @@
namespace NSPresentationEditor
{
class CDocument : public IBase
class CDocument
{
public:
std::vector<CTheme> m_arThemes;
......@@ -164,104 +164,6 @@ namespace NSPresentationEditor
}
}
// videosource
CString SaveToXML()
{
CString strXmlSource = _T("");
CString strXmlVideoOverlay = _T("");
CAudioOverlay oAudioOverlay;
CalculateTimes(oAudioOverlay);
size_t nCountSlides = m_arSlides.size();
if ( nCountSlides > 0 )
{
double dDuration = 0.0;
for (size_t nIndex = 0; nIndex < m_arSlides.size(); ++nIndex)
{
dDuration += m_arSlides[nIndex].m_dDuration;
}
CString XmlSlideSource = _T("");
for ( size_t nIndex = 0; nIndex < m_arSlides.size(); ++nIndex )
{
CSlide* pSlide = &m_arSlides[nIndex];
CString XmlCompose = _T("");
CString XmlTransforms = _T("");
bool bIsTransition = (0 != pSlide->m_oSlideShow.m_oTransition.m_dSpeed);
if ( bIsTransition )
{
XmlCompose = GetXmlSlideTransition (m_arSlides[nIndex]/*, oAudioOverlay*/);
}
XmlSlideSource.Format ( _T("<ColorSource Color=\"16777215\" Duration=\"%lf\" widthmetric=\"%lf\" heightmetric=\"%lf\">"),
pSlide->m_dDuration, (double)pSlide->m_lWidth, (double)pSlide->m_lHeight );
double dScaleHor = (double)(pSlide->m_lWidth) / pSlide->m_lOriginalWidth;
double dScaleVer = (double)(pSlide->m_lHeight) / pSlide->m_lOriginalHeight;
if ( FALSE )
{
//
}
else
{
int nElements = (int)pSlide->m_arElements.size();
for ( int nElem = 0; nElem < nElements; ++nElem )
{
if (etVideo == pSlide->m_arElements[nElem]->m_etType)
{
CString strParam = pSlide->m_arElements[nElem]->SaveToXML();
strXmlVideoOverlay += strParam;
}
else if (etAudio == pSlide->m_arElements[nElem]->m_etType)
{
//
continue;
}
else
{
CString strParam = pSlide->m_arElements[nElem]->SaveToXML();
XmlTransforms += strParam;
}
}
}
if ( bIsTransition && (0 == nIndex) && (XmlCompose.GetLength () > 1) )
{
CString strMem = _T("");
strMem.Format(_T("<ColorSource Color=\"0\" Duration=\"%d\" widthmetric=\"%lf\" heightmetric=\"%lf\" />"),
pSlide->m_oSlideShow.m_oTransition.m_dSpeed, (double)pSlide->m_lWidth, (double)pSlide->m_lHeight );
strXmlSource += strMem;
}
strXmlSource += XmlCompose;
XmlSlideSource += _T("<VideoTransforms>") + XmlTransforms + _T("</VideoTransforms>");
XmlSlideSource += _T("</ColorSource>");
strXmlSource += XmlSlideSource;
}
strXmlSource = _T("<VideoSources>") + strXmlSource + _T("</VideoSources>");
}
oAudioOverlay.Calculate();
CString strAudioOverlay = oAudioOverlay.GetAudioOverlay();
CString strXmlOverlays = _T("<VideoOverlays>") + strXmlVideoOverlay + _T("</VideoOverlays>") + _T("<AudioOverlays>") +
_T("<AudioSources>") + strAudioOverlay + _T("</AudioSources>") + _T("</AudioOverlays>");
strXmlSource = _T("<SingleSource>") + strXmlSource + _T("</SingleSource>");
strXmlSource = _T("<MultiSource>") + strXmlSource + strXmlOverlays + _T("</MultiSource>");
return strXmlSource;
}
CString GetXmlSlideTransition ( CSlide& oSlide/*, CAudioOverlay& oAudioOverlay*/ )
{
CString Source = CString ( _T("") );
......@@ -634,345 +536,8 @@ namespace NSPresentationEditor
}
}
public:
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode)
{
#ifdef _PRESENTATION_WRITER_
Clear();
m_oInfo.m_lMillimetresHor = oNode.ReadAttributeInt(_T("hor_mm"));
m_oInfo.m_lMillimetresVer = oNode.ReadAttributeInt(_T("ver_mm"));
//m_oInfo.m_lUnitsHor = oNode.ReadAttributeInt(_T("hor_uni"));
//m_oInfo.m_lUnitsVer = oNode.ReadAttributeInt(_T("ver_uni"));
m_oInfo.m_lUnitsHor = 36000 * m_oInfo.m_lMillimetresHor;
m_oInfo.m_lUnitsVer = 36000 * m_oInfo.m_lMillimetresVer;
XmlUtils::CXmlNode oNodeThemes;
if (oNode.GetNode(_T("Themes"), oNodeThemes))
{
XmlUtils::CXmlNodes oThemes;
if (oNodeThemes.GetNodes(_T("Theme"), oThemes))
{
int nCountThemes = oThemes.GetCount();
for (int i = 0; i < nCountThemes; ++i)
{
XmlUtils::CXmlNode oNodeT;
oThemes.GetAt(i, oNodeT);
CTheme elem;
m_arThemes.push_back(elem);
CTheme* pTheme = &m_arThemes.back();
pTheme->m_oInfo = m_oInfo;
pTheme->ReadFromXml(oNodeT);
}
}
}
XmlUtils::CXmlNode oNodeSlides;
if (oNode.GetNode(_T("Slides"), oNodeSlides))
{
XmlUtils::CXmlNodes oSlides;
if (oNodeSlides.GetNodes(_T("Slide"), oSlides))
{
int nCountSlides = oSlides.GetCount();
for (int i = 0; i < nCountSlides; ++i)
{
XmlUtils::CXmlNode oNodeS;
oSlides.GetAt(i, oNodeS);
CSlide elem;
m_arSlides.push_back(elem);
CSlide* pSlide = &m_arSlides.back();
pSlide->m_lThemeID = oNodeS.ReadAttributeInt(_T("themeid"));
pSlide->m_lLayoutID = oNodeS.ReadAttributeInt(_T("layoutid"));
pSlide->m_bShowMasterShapes = (1 == oNodeS.ReadAttributeInt(_T("usethemeobjects")));
pSlide->SetMetricInfo(m_oInfo);
pSlide->ReadFromXml(oNodeS);
}
}
}
#endif
}
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
{
}
public:
CString ToXmlVideoSource()
{
return SaveToXML();
}
CString ToXmlVideoSource2()
{
CString strXmlSource = _T("");
CString strXmlVideoOverlay = _T("");
//CAudioOverlay oAudioOverlay;
//CalculateTimes(oAudioOverlay);
size_t nCountSlides = m_arSlides.size();
if ( nCountSlides > 0 )
{
double dDuration = 0.0;
for (size_t nIndex = 0; nIndex < m_arSlides.size(); ++nIndex)
{
dDuration += m_arSlides[nIndex].m_dDuration;
}
for ( size_t nIndex = 0; nIndex < m_arSlides.size(); ++nIndex )
{
CSlide* pSlide = &m_arSlides[nIndex];
CString XmlCompose = _T("");
CString XmlTransforms = _T("");
bool bIsTransition = (0 != pSlide->m_oSlideShow.m_oTransition.m_dSpeed);
if ( bIsTransition )
{
XmlCompose = GetXmlSlideTransition (m_arSlides[nIndex]/*, oAudioOverlay*/);
}
CString XmlSlideSource = _T("");
XmlSlideSource.Format ( _T("<ColorSource Color=\"16777215\" Duration=\"%lf\" widthmetric=\"%lf\" heightmetric=\"%lf\">"),
pSlide->m_dDuration, (double)pSlide->m_lWidth, (double)pSlide->m_lHeight );
double dScaleHor = (double)(pSlide->m_lWidth) / pSlide->m_lOriginalWidth;
double dScaleVer = (double)(pSlide->m_lHeight) / pSlide->m_lOriginalHeight;
if ( FALSE )
{
//
}
else
{
CTheme* pTheme = NULL;
CLayout* pLayout = NULL;
if ((0 <= pSlide->m_lThemeID) && (pSlide->m_lThemeID < (LONG)m_arThemes.size()))
{
pTheme = &m_arThemes[pSlide->m_lThemeID];
}
if ((NULL != pTheme) && ((0 <= pSlide->m_lLayoutID) && (pSlide->m_lLayoutID < (LONG)pTheme->m_arLayouts.size())))
{
pLayout = &pTheme->m_arLayouts[pSlide->m_lLayoutID];
}
// background
#ifdef PPT_DEF
CShapeElement oElem(NSPresentationEditor::NSBaseShape::ppt, PPTShapes::sptCRect);
#else
#endif
oElem.m_oMetric = m_oInfo;
oElem.m_rcBoundsOriginal.left = 0.0;
oElem.m_rcBoundsOriginal.right = (double)m_oInfo.m_lUnitsHor;
oElem.m_rcBoundsOriginal.top = 0.0;
oElem.m_rcBoundsOriginal.bottom = (double)m_oInfo.m_lUnitsVer;
double dScaleX = (double)m_oInfo.m_lMillimetresHor / m_oInfo.m_lUnitsHor;
double dScaleY = (double)m_oInfo.m_lMillimetresVer / m_oInfo.m_lUnitsVer;
oElem.NormalizeCoords(dScaleX, dScaleY);
if (pSlide->m_bIsBackground)
{
oElem.m_oShape.m_oBrush = pSlide->m_oBackground;
oElem.SetupProperties(pSlide, pTheme, pLayout);
}
else if ((NULL != pLayout) && pLayout->m_bIsBackground)
{
oElem.m_oShape.m_oBrush = pLayout->m_oBackground;
oElem.SetupProperties(NULL, pTheme, pLayout);
}
else if (NULL != pTheme)
{
oElem.m_oShape.m_oBrush = pTheme->m_oBackground;
oElem.SetupProperties(NULL, pTheme, NULL);
}
XmlTransforms += oElem.SaveToXML();
// theme elements
if (pSlide->m_bShowMasterShapes && (NULL != pLayout) && pLayout->m_bShowMasterShapes && (NULL != pTheme))
{
size_t nCount = pTheme->m_arElements.size();
for (size_t ii = 0; ii < nCount; ++ii)
XmlTransforms += pTheme->m_arElements[ii]->SaveToXML();
}
// layout elements
if (NULL != pLayout)
{
size_t nCount = pLayout->m_arElements.size();
for (size_t ii = 0; ii < nCount; ++ii)
{
if (-1 == pLayout->m_arElements[ii]->m_lPlaceholderType)
XmlTransforms += pLayout->m_arElements[ii]->SaveToXML();
}
}
int nElements = (int)pSlide->m_arElements.size();
for ( int nElem = 0; nElem < nElements; ++nElem )
{
if (etVideo == pSlide->m_arElements[nElem]->m_etType)
{
CString strParam = pSlide->m_arElements[nElem]->SaveToXML();
XmlTransforms += strParam;
}
else if (etAudio == pSlide->m_arElements[nElem]->m_etType)
{
CString strParam = pSlide->m_arElements[nElem]->SaveToXML();
XmlTransforms += strParam;
}
else
{
CString strParam = pSlide->m_arElements[nElem]->SaveToXML();
XmlTransforms += strParam;
}
}
if ( bIsTransition && (0 == nIndex) && (XmlCompose.GetLength () > 1) )
{
CString strMem = _T("");
strMem.Format(_T("<ColorSource Color=\"0\" Duration=\"%lf\" widthmetric=\"%lf\" heightmetric=\"%lf\" />"),
pSlide->m_oSlideShow.m_oTransition.m_dSpeed, (double)pSlide->m_lWidth, (double)pSlide->m_lHeight );
strXmlSource += strMem;
}
strXmlSource += XmlCompose;
XmlSlideSource += _T("<VideoTransforms>") ;
XmlSlideSource += XmlTransforms;
XmlSlideSource += _T("</VideoTransforms>");
XmlSlideSource += _T("</ColorSource>");
}
strXmlSource += XmlSlideSource;
}
strXmlSource = _T("<VideoSources>") + strXmlSource + _T("</VideoSources>");
}
//oAudioOverlay.Calculate();
//CString strAudioOverlay = oAudioOverlay.GetAudioOverlay();
//
//CString strXmlOverlays = _T("<VideoOverlays>") + strXmlVideoOverlay + _T("</VideoOverlays>") +
// _T("<AudioOverlays>") + _T("<AudioSources>") + strAudioOverlay + _T("</AudioSources>") + _T("</AudioOverlays>");
strXmlSource = _T("<SingleSource>") + strXmlSource + _T("</SingleSource>");
strXmlSource = _T("<MultiSource>") + strXmlSource /*+ strXmlOverlays*/ + _T("</MultiSource>");
return strXmlSource;
}
CString ToXmlEditor()
{
CString strXmlSource = _T("");
CAudioOverlay oAudioOverlay;
CalculateTimes(oAudioOverlay);
size_t nCountSlides = m_arSlides.size();
if ( nCountSlides > 0 )
{
CString XmlSlideSource = _T("");
for ( size_t nIndex = 0; nIndex < nCountSlides; ++nIndex )
{
CSlide* pSlide = &m_arSlides[nIndex];
CString XmlTransforms = _T("");
LONG lWidthPix = (LONG)(96.0 * pSlide->m_lWidth / 25.4);
LONG lHeightPix = (LONG)(96.0 * pSlide->m_lHeight / 25.4);
XmlSlideSource.Format ( _T("<Slide color=\"16777215\" duration=\"%lf\" width=\"%d\" height=\"%d\" transition=\"%d\" transition-speed=\"%.2lf\">"),
pSlide->m_dDuration, lWidthPix, lHeightPix,
pSlide->m_oSlideShow.m_oTransition.m_nEffectType, pSlide->m_oSlideShow.m_oTransition.m_dSpeed );
int nElements = (int)pSlide->m_arElements.size();
for ( int nElem = 0; nElem < nElements; ++nElem )
{
if (etAudio == pSlide->m_arElements[nElem]->m_etType)
{
//
continue;
}
XmlTransforms += pSlide->m_arElements[nElem]->ToXmlEditor();
}
XmlSlideSource += XmlTransforms;
XmlSlideSource += _T("</Slide>");
strXmlSource += XmlSlideSource;
}
strXmlSource = _T("<Graphics>") + strXmlSource + _T("</Graphics>");
}
oAudioOverlay.Calculate();
strXmlSource = _T("<Presentation xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">") + strXmlSource + _T("<Audio>") + oAudioOverlay.GetAudioOverlay() + _T("</Audio>") + _T("</Presentation>");
return strXmlSource;
}
CString ToXmlEditor2()
{
CStringWriter oWriter;
CString strMetric = _T("");
strMetric.Format(_T(" hor_mm=\"%d\" ver_mm=\"%d\" hor_uni=\"%d\" ver_uni=\"%d\">"),
m_oInfo.m_lMillimetresHor, m_oInfo.m_lMillimetresVer, m_oInfo.m_lUnitsHor, m_oInfo.m_lUnitsVer);
oWriter.WriteString(std::wstring(L"<Presentation xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\""));
oWriter.WriteString(strMetric);
oWriter.WriteString(std::wstring(L"<Themes>"));
size_t nCount = m_arThemes.size();
for (size_t i = 0; i < nCount; ++i)
{
oWriter.WriteString(m_arThemes[i].ToXmlEditor(m_oInfo));
}
oWriter.WriteString(std::wstring(L"</Themes>"));
oWriter.WriteString(std::wstring(L"<Slides>"));
nCount = m_arSlides.size();
for (size_t i = 0; i < nCount; ++i)
{
NSPresentationEditor::CTheme* pThemeSlide = NULL;
NSPresentationEditor::CLayout* pLayoutSlide = NULL;
NSPresentationEditor::CSlide* pSlide = &m_arSlides[i];
if ((0 <= pSlide->m_lThemeID) && (pSlide->m_lThemeID < (LONG)m_arThemes.size()))
{
pThemeSlide = &m_arThemes[pSlide->m_lThemeID];
}
if ((NULL != pThemeSlide) && (0 <= pSlide->m_lLayoutID) && (pSlide->m_lLayoutID < (LONG)pThemeSlide->m_arLayouts.size()))
{
pLayoutSlide = &pThemeSlide->m_arLayouts[pSlide->m_lLayoutID];
}
oWriter.WriteString(m_arSlides[i].ToXmlEditor(pThemeSlide, pLayoutSlide, m_oInfo));
}
oWriter.WriteString(std::wstring(L"</Slides>"));
oWriter.WriteString(std::wstring(L"</Presentation>"));
oWriter.CorrectUnicodeString();
return oWriter.GetData();
}
void CalculateEditor(const NSPresentationEditor::CMetricInfo& oInfo, bool bIsPlaceholderSetUp = false)
{
m_oInfo = oInfo;
......@@ -1108,15 +673,6 @@ namespace NSPresentationEditor
}
}
virtual CString SerializeToXml()
{
CString strDoc = _T("<Document>");
for (size_t i = 0; i < m_arSlides.size(); ++i)
{
strDoc += m_arSlides[i].SerializeToXml();
}
strDoc += _T("</Document>");
return strDoc;
}
};
}
......@@ -19,7 +19,7 @@ namespace NSPresentationEditor
class CLayout;
class CSlide;
class IElement : public IBase
class IElement
{
public:
ElementType m_etType;
......@@ -38,6 +38,7 @@ namespace NSPresentationEditor
LONG m_lPlaceholderID;
LONG m_lPlaceholderType;
bool m_bPlaceholderSet;
//
CMetricInfo m_oMetric;
......@@ -46,6 +47,8 @@ namespace NSPresentationEditor
bool m_bFlipH; //
bool m_bFlipV; //
bool m_bLine;
bool m_bIsBackground;
bool m_bHaveAnchor;
......@@ -60,6 +63,8 @@ namespace NSPresentationEditor
std::wstring m_sName;
std::wstring m_sDescription;
std::wstring m_sHyperlink;
protected:
ULONG m_lCountRef;
......@@ -96,6 +101,7 @@ namespace NSPresentationEditor
m_lPlaceholderID = -1;
m_lPlaceholderType = -1;
m_bPlaceholderSet = false;
m_etType = etPicture;
......@@ -115,6 +121,7 @@ namespace NSPresentationEditor
m_dRotate = 0.0;
m_bFlipH = false;
m_bFlipV = false;
m_bLine = false;
m_lCountRef = 1;
......@@ -172,6 +179,7 @@ namespace NSPresentationEditor
pDublicate->m_lPlaceholderID = m_lPlaceholderID;
pDublicate->m_lPlaceholderType = m_lPlaceholderType;
pDublicate->m_bPlaceholderSet = m_bPlaceholderSet;
pDublicate->m_oMetric = m_oMetric;
pDublicate->m_oProperties = m_oProperties;
......@@ -179,6 +187,7 @@ namespace NSPresentationEditor
pDublicate->m_dRotate = m_dRotate;
pDublicate->m_bFlipH = m_bFlipH;
pDublicate->m_bFlipV = m_bFlipV;
pDublicate->m_bLine = m_bLine;
pDublicate->m_pTheme = m_pTheme;
pDublicate->m_pLayout = m_pLayout;
......@@ -200,9 +209,6 @@ namespace NSPresentationEditor
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty) = 0;
virtual IElement* CreateDublicate() = 0;
virtual CString ToXmlVideoSource() = 0;
virtual CString ToXmlEditor() = 0;
virtual CString SerializeToXml()
{
CString strElement = _T("");
......
......@@ -342,15 +342,6 @@ namespace NSPresentationEditor
{
}
virtual CString ToXmlVideoSource()
{
return SaveToXML();
}
virtual CString ToXmlEditor()
{
return SaveToXML();
}
inline CString GetVideoStream ()
{
int lIndex = m_strFileName.find(L"file:///");
......@@ -447,6 +438,9 @@ namespace NSPresentationEditor
bool m_bStretch;
bool m_bTile;
bool m_bOLE;
bool m_bImagePresent;
public:
CImageElement() : IElement()
{
......@@ -465,6 +459,8 @@ namespace NSPresentationEditor
m_bStretch = true;
m_bTile = false;
m_bOLE = false;
m_bImagePresent = false;
}
......@@ -551,93 +547,15 @@ namespace NSPresentationEditor
pImageElement->m_bStretch = m_bStretch;
pImageElement->m_bTile = m_bTile;
pImageElement->m_bImagePresent = m_bImagePresent;
pImageElement->m_bOLE = m_bOLE;
return (IElement*)pImageElement;
}
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty)
{
}
virtual CString ToXmlVideoSource()
{
return SaveToXML();
}
virtual CString ToXmlEditor()
{
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
return _T("");
#else
CString strPPTXShape = _T("");
//NSBaseShape::ClassType eShapeType = NSBaseShape::unknown;
//if (m_oShape.m_pShape != NULL)
// eShapeType = m_oShape.m_pShape->GetClassType();
#ifdef ENABLE_PPT_TO_PPTX_CONVERT
strPPTXShape = ConvertPPTShapeToPPTX();
#endif
NSHtmlRenderer::CASCSVGRenderer* pSVG = new NSHtmlRenderer::CASCSVGRenderer();
//todo FontManager
pSVG->put_Width(m_oMetric.m_lMillimetresHor);
pSVG->put_Height(m_oMetric.m_lMillimetresVer);
pSVG->CreateOfficeFile(L"", 0);
pSVG->DrawImageFromFile(m_strFileName, m_rcBounds.left, m_rcBounds.top, m_rcBounds.right - m_rcBounds.left, m_rcBounds.bottom - m_rcBounds.top, 255);
pSVG->CloseFile(0);
std::wstring bsResult;
pSVG->get_Data(&bsResult);
CString strXml = CString(bsResult.c_str());
RELEASEOBJECT(pSVG);
int nIndexStart = strXml.Find((TCHAR)'>');
int nIndexEnd = strXml.ReverseFind((TCHAR)'<');
if ((-1 != nIndexStart) && (nIndexEnd > nIndexStart))
{
strXml = strXml.Mid(nIndexStart + 1, nIndexEnd - nIndexStart - 1);
}
//nIndexStart = strXml.Find((TCHAR)'>');
//nIndexEnd = strXml.ReverseFind((TCHAR)'<');
//if ((-1 != nIndexStart) && (nIndexEnd > nIndexStart))
//{
// strXml = strXml.Mid(nIndexStart + 1, nIndexEnd - nIndexStart - 1);
//}
double _dLeft = m_rcBounds.left * 96 / 25.4;
double _dTop = m_rcBounds.top * 96 / 25.4;
double _dWidth = (m_rcBounds.right - m_rcBounds.left) * 96 / 25.4;
double _dHeight = (m_rcBounds.bottom - m_rcBounds.top) * 96 / 25.4;
CString strTxPath = std_string2string(m_strFileName);
if (_T("") != strTxPath)
CorrectXmlString(strTxPath);
if (_T("") != strPPTXShape)
CorrectXmlString(strPPTXShape);
CString strElement = _T("");
strElement.Format(_T("<shape type='75' background='%d' changeable='%d' left='%d' top='%d' width='%d' height='%d'"),
(int)(m_bIsBackground ? 1 : 0), (int)(m_bIsChangeable ? 1 : 0), (LONG)_dLeft, (LONG)_dTop, (LONG)_dWidth, (LONG)_dHeight);
strElement += _T(" txpath=\"") + strTxPath + _T("\"");
if (strPPTXShape.GetLength() >0)
strElement += _T(" pptx_shape=\"") + strPPTXShape + _T("\"");
strElement += _T(">");
strXml = strElement + strXml + _T("</shape>");
return strXml;
#endif
}
#ifdef ENABLE_PPT_TO_PPTX_CONVERT
......@@ -1015,165 +933,6 @@ namespace NSPresentationEditor
}
}
virtual CString ToXmlVideoSource()
{
return SaveToXML();
}
virtual CString ToXmlEditor()
{
#ifdef BUILD_CONFIG_OPENSOURCE_VERSION
return _T("");
#else
NSBaseShape::ClassType eShapeType = NSBaseShape::unknown;
if (m_oShape.m_pShape != NULL)
eShapeType = m_oShape.m_pShape->GetClassType();
CString strPPTXShape = _T("");
CGeomShapeInfo oInfo;
oInfo.SetBounds(m_rcBounds);
oInfo.m_dRotate = m_dRotate;
oInfo.m_bFlipH = m_bFlipH;
oInfo.m_bFlipV = m_bFlipV;
oInfo.m_lOriginalWidth = (LONG)m_rcBoundsOriginal.GetWidth();
oInfo.m_lOriginalHeight = (LONG)m_rcBoundsOriginal.GetHeight();
if ((0 == m_oShape.m_oPen.Alpha) && (0 == m_oShape.m_oBrush.Alpha1) && (1000 == m_oShape.m_oBrush.Type))
m_oShape.m_lDrawType &= c_ShapeDrawType_Text;
CString strXml = _T("");
if (m_oShape.m_lDrawType & c_ShapeDrawType_Graphic)
{
NSHtmlRenderer::CASCSVGRenderer* pSVG = new NSHtmlRenderer::CASCSVGRenderer();
//todo FontManager
pSVG->put_Width(m_oMetric.m_lMillimetresHor);
pSVG->put_Height(m_oMetric.m_lMillimetresVer);
pSVG->CreateOfficeFile(L"", 0);
//if (m_oShape.m_oPen.LineEndCap == 0x11 ||
// m_oShape.m_oPen.LineEndCap == 0x14 ||
// m_oShape.m_oPen.LineEndCap == 0x13 ||
// m_oShape.m_oPen.LineEndCap == 0x12)
//{
// ASCGraphics::IAVSMetafile* pMetafile = NULL;
// CoCreateInstance(ASCGraphics::CLSID_CAVSMetafile, NULL, CLSCTX_ALL, ASCGraphics::IID_IAVSMetafile, (void**)&pMetafile);
// m_oShape.ToRenderer((IASCRenderer*)pMetafile, oInfo, m_oMetric, m_dStartTime, m_dEndTime);
// pMetafile->Draw2((IUnknown*)pSVG, 96.0, 96.0, NULL);
// RELEASEINTERFACE(pMetafile);
//}
//else
{
m_oShape.ToRenderer((IRenderer*)pSVG, oInfo, m_oMetric, m_dStartTime, m_dEndTime);
}
pSVG->CloseFile(0);
std::wstring bsResult;
pSVG->get_Data(&bsResult);
strXml = CString(bsResult.c_str());
RELEASEOBJECT(pSVG);
int nIndexStart = strXml.Find((TCHAR)'>');
int nIndexEnd = strXml.ReverseFind((TCHAR)'<');
if ((-1 != nIndexStart) && (nIndexEnd > nIndexStart))
{
strXml = strXml.Mid(nIndexStart + 1, nIndexEnd - nIndexStart - 1);
}
double _dLeft = m_rcBounds.left * 96 / 25.4;
double _dTop = m_rcBounds.top * 96 / 25.4;
double _dWidth = (m_rcBounds.right - m_rcBounds.left) * 96 / 25.4;
double _dHeight = (m_rcBounds.bottom - m_rcBounds.top) * 96 / 25.4;
CString strTxPath = _T("");
if (c_BrushTypeTexture == m_oShape.m_oBrush.Type)
strTxPath = std_string2string(m_oShape.m_oBrush.TexturePath);
CorrectXmlString(strTxPath);
CString strElement = _T("");
strElement.Format(_T("<shape background=\"%d\" changeable=\"%d\" left=\"%d\" top=\"%d\" width=\"%d\" height=\"%d\""),
(int)(m_bIsBackground ? 1 : 0), (int)(m_bIsChangeable ? 1 : 0), (LONG)_dLeft, (LONG)_dTop, (LONG)_dWidth, (LONG)_dHeight);
strElement += _T(" txpath=\"") + strTxPath + _T("\"");
#ifdef ENABLE_PPT_TO_PPTX_CONVERT
if (eShapeType == NSBaseShape::ppt)
strPPTXShape = ConvertPPTShapeToPPTX();
#endif
if (strPPTXShape.GetLength() >0)
{
CorrectXmlString(strPPTXShape);
strElement += _T(" pptx_shape=\"") + strPPTXShape + _T("\"");
}
strElement += _T(">");
strXml = strElement + strXml + _T("</shape>");
}
else
{
double _dLeft = m_rcBounds.left * 96 / 25.4;
double _dTop = m_rcBounds.top * 96 / 25.4;
double _dWidth = (m_rcBounds.right - m_rcBounds.left) * 96 / 25.4;
double _dHeight = (m_rcBounds.bottom - m_rcBounds.top) * 96 / 25.4;
int nL = (int)_dLeft;
int nT = (int)_dTop;
int nR = nL + (int)_dWidth;
int nB = nT + (int)_dHeight;
strXml.Format(_T("<g><path style=\"fill:none;stroke:none\" d=\"M %d,%d L %d,%d L %d,%d L %d,%d Z\"/></g>"),
nL, nT, nR, nT, nR, nB, nL, nB);
CString strTxPath = _T("");
if (c_BrushTypeTexture == m_oShape.m_oBrush.Type)
strTxPath = std_string2string(m_oShape.m_oBrush.TexturePath);
CorrectXmlString(strTxPath);
CString strElement = _T("");
strElement.Format(_T("<shape background=\"%d\" changeable=\"%d\" left=\"%d\" top=\"%d\" width=\"%d\" height=\"%d\""),
(int)(m_bIsBackground ? 1 : 0), (int)(m_bIsChangeable ? 1 : 0), (LONG)_dLeft, (LONG)_dTop, (LONG)_dWidth, (LONG)_dHeight );
strElement += _T(" txpath=\"") + strTxPath + _T("\"");
#ifdef ENABLE_PPT_TO_PPTX_CONVERT
if (eShapeType == NSBaseShape::ppt)
strPPTXShape = ConvertPPTShapeToPPTX();
#endif
if (strPPTXShape.GetLength() >0)
{
CorrectXmlString(strPPTXShape);
strElement += _T(" pptx_shape=\"") + strPPTXShape + _T("\"");
}
strElement += _T(">");
strXml = strElement + strXml + _T("</shape>");
}
if ((m_oShape.m_oText.IsEmptyText()) && (m_oShape.m_oBrush.Type == c_BrushTypeTexture))
{
return strXml;
}
CElemInfo oElemInfo;
oElemInfo.m_bIsBackground = m_bIsBackground;
oElemInfo.m_bIsChangeable = m_bIsChangeable;
oElemInfo.m_lID = m_lID;
return strXml + m_oShape.GetTextXHTML(oInfo, m_oMetric, m_dStartTime, m_dEndTime, oElemInfo, m_pTheme, m_pLayout);
#endif
}
#ifdef _PRESENTATION_WRITER_
void LoadFromXmlNode2(XmlUtils::CXmlNode& oNode)
{
......@@ -1688,15 +1447,6 @@ namespace NSPresentationEditor
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty)
{
}
virtual CString ToXmlVideoSource()
{
return SaveToXML();
}
virtual CString ToXmlEditor()
{
return _T("");
}
};
}
namespace NSStrings
......
//#include "stdafx.h"
#include "Elements.h"
namespace NSPresentationEditor
{
CString NSPresentationEditor::CLayout::ToXmlEditor(NSPresentationEditor::CTheme* pTheme, const NSPresentationEditor::CMetricInfo& oInfo)
{
NSPresentationEditor::CStringWriter oWriter;
CString strStart = _T("");
strStart.Format(_T("<Layout usethemeobjects=\"%d\" type=\"%ls\">"), m_bShowMasterShapes ? 1 : 0, m_strLayoutType);
oWriter.WriteString(strStart);
if (!m_bUseThemeColorScheme)
{
// colors ----
oWriter.WriteString(std::wstring(L"<Colors>"));
size_t nCountColors = m_arColorScheme.size();
for (size_t i = 0; i < nCountColors; ++i)
{
CString strFormat = _T("");
LONG lColorValue = m_arColorScheme[i].GetLONG_RGB();
strFormat.Format(_T(".color%u { color: #%06x; } .stroke%u { stroke:#%06x; } .fill%u { fill:#%06x; }\n"),
i + 1, lColorValue, i + 1, lColorValue, i + 1, lColorValue);
oWriter.WriteString(strFormat);
}
oWriter.WriteString(std::wstring(L"</Colors>"));
// -----------
}
if (m_bIsBackground)
{
// background
#ifndef ENABLE_PPT_TO_PPTX_CONVERT
#ifdef PPT_DEF
CShapeElement oElem(NSPresentationEditor::NSBaseShape::ppt, PPTShapes::sptCRect);
#else
CShapeElement oElem(NSPresentationEditor::NSBaseShape::pptx, OOXMLShapes::sptCRect);
#endif
#else
CShapeElement oElem(NSPresentationEditor::NSBaseShape::pptx, OOXMLShapes::sptCRect);
#endif
oElem.m_oMetric = oInfo;
oElem.m_rcBoundsOriginal.left = 0.0;
oElem.m_rcBoundsOriginal.right = (double)oInfo.m_lUnitsHor;
oElem.m_rcBoundsOriginal.top = 0.0;
oElem.m_rcBoundsOriginal.bottom = (double)oInfo.m_lUnitsVer;
double dScaleX = (double)oInfo.m_lMillimetresHor / oInfo.m_lUnitsHor;
double dScaleY = (double)oInfo.m_lMillimetresVer / oInfo.m_lUnitsVer;
oElem.NormalizeCoords(dScaleX, dScaleY);
oElem.m_oShape.m_oBrush = m_oBackground;
oElem.m_bIsBackground = true;
oElem.m_bIsChangeable = false;
oWriter.WriteString(std::wstring(L"<Background>"));
oElem.SetupProperties(NULL, pTheme, this);
oWriter.WriteString(oElem.ToXmlEditor());
oWriter.WriteString(std::wstring(L"</Background>"));
}
// -----------
// elements (no placeholders)
oWriter.WriteString(std::wstring(L"<Elements>"));
size_t nCountElems = m_arElements.size();
for (size_t i = 0; i < nCountElems; ++i)
{
if (-1 == m_arElements[i]->m_lPlaceholderType)
{
m_arElements[i]->m_bIsBackground = false;
m_arElements[i]->m_bIsChangeable = false;
oWriter.WriteString(m_arElements[i]->ToXmlEditor());
}
}
oWriter.WriteString(std::wstring(L"</Elements>"));
// ----------------
// placeholders
oWriter.WriteString(std::wstring(L"<Placeholders>"));
std::wstring strStylesPh = _T("");
std::wstring strFontRefs = _T("");
for (size_t i = 0; i < nCountElems; ++i)
{
IElement* pElement = m_arElements[i];
if (-1 != pElement->m_lPlaceholderType)
{
LONG lPercentL = (LONG)(pElement->m_rcBounds.left * 100 / m_lWidth);
LONG lPercentT = (LONG)(pElement->m_rcBounds.top * 100 / m_lHeight);
LONG lPercentW = (LONG)(pElement->m_rcBounds.GetWidth() * 100 / m_lWidth);
LONG lPercentH = (LONG)(pElement->m_rcBounds.GetHeight() * 100 / m_lHeight);
CString strPlaceholder = _T("");
strPlaceholder.Format(_T("<Placeholder id=\"%d\" type=\"%d\" left=\"%d\" top=\"%d\" width=\"%d\" height=\"%d\" angle=\"%lf\" flipx=\"%d\" flipy=\"%d\">"),
m_arElements[i]->m_lPlaceholderID, m_arElements[i]->m_lPlaceholderType, lPercentL, lPercentT, lPercentW, lPercentH,
m_arElements[i]->m_dRotate, m_arElements[i]->m_bFlipH ? 1 : 0, m_arElements[i]->m_bFlipV ? 1 : 0);
oWriter.WriteString(strPlaceholder);
oWriter.WriteString(pElement->ToXmlEditor());
if (etShape == pElement->m_etType)
{
CShapeElement* pTextElement = dynamic_cast<CShapeElement*>(pElement);
if (NULL != pTextElement)
{
LONG lCountThisType = this->GetCountPlaceholderWithType(pTextElement->m_lPlaceholderType);
LONG lID = -1;
if (1 < lCountThisType)
lID = pTextElement->m_lPlaceholderID;
strStylesPh += pTextElement->m_oShape.m_oText.m_oStyles.ToXmlEditor(oInfo, true, pTextElement->m_lPlaceholderType, lID);
LONG lFontRef = pTextElement->m_oShape.m_oText.m_lFontRef;
if ((0 <= lFontRef) && (lFontRef < (LONG)pTheme->m_arFonts.size()))
{
CString strRef = _T("");
strRef.Format(_T("l_font%d { font-index:%d;font-family:%ls; }\n"),
pTextElement->m_lPlaceholderType, lFontRef, pTheme->m_arFonts[lFontRef].Name);
strFontRefs += strRef;
}
}
}
CString strEndPlaceHolder = _T("</Placeholder>");
oWriter.WriteString(strEndPlaceHolder);
}
}
oWriter.WriteString(std::wstring(L"</Placeholders>"));
oWriter.WriteString(std::wstring(L"<Styles>") + strStylesPh + _T("</Styles>"));
oWriter.WriteString(std::wstring(L"<StylesFontRef>") + strFontRefs + _T("</StylesFontRef>"));
oWriter.WriteString(std::wstring(L"</Layout>"));
return oWriter.GetData();
}
void NSPresentationEditor::CLayout::ReadFromXml(XmlUtils::CXmlNode& oNode)
{
#ifdef _PRESENTATION_WRITER_
m_strLayoutType = oNode.GetAttribute(_T("type"));
m_bShowMasterShapes = (oNode.ReadAttributeInt(_T("usethemeobjects")) == 1) ? true : false;
m_bUseThemeColorScheme = true;
//colors
m_arColorScheme.clear();
XmlUtils::CXmlNode oNodeColors;
if (oNode.GetNode(_T("Colors"), oNodeColors))
{
m_bUseThemeColorScheme = false;
CStylesCSS oStyles;
CString strStyles = oNodeColors.GetText();
oStyles.LoadStyles(strStyles);
size_t nCount = oStyles.m_arStyles.size();
LONG lColor = 0;
for (size_t i = 0; i < nCount; i += 3)
{
CColor elem;
m_arColorScheme.push_back(elem);
oStyles.m_arStyles[i].LoadColor(m_arColorScheme[lColor]);
++lColor;
}
}
m_bIsBackground = false;
// background
XmlUtils::CXmlNode oNodeBackround;
if (oNode.GetNode(_T("Background"), oNodeBackround))
{
m_bIsBackground = true;
XmlUtils::CXmlNode oNodeMem;
if (oNodeBackround.GetNode(_T("shape"), oNodeMem))
{
CShapeElement oElem;
oElem.m_oMetric = m_oInfo;
oElem.LoadFromXmlNode2(oNodeMem);
m_oBackground = oElem.m_oShape.m_oBrush;
}
}
// Elements
XmlUtils::CXmlNode oNodeElements;
if (oNode.GetNode(_T("Elements"), oNodeElements))
{
XmlUtils::CXmlNodes oNodes;
if (oNodeElements.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNodeMem;
oNodes.GetAt(i, oNodeMem);
CShapeElement* pShapeEl = new CShapeElement();
pShapeEl->m_oMetric = m_oInfo;
pShapeEl->LoadFromXmlNode2(oNodeMem);
m_arElements.push_back(pShapeEl);
}
}
}
// Placeholders
XmlUtils::CXmlNode oNodePlaceholders;
if (oNode.GetNode(_T("Placeholders"), oNodePlaceholders))
{
XmlUtils::CXmlNodes oNodes;
if (oNodePlaceholders.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNodeMem;
oNodes.GetAt(i, oNodeMem);
CShapeElement* pShapeEl = new CShapeElement();
pShapeEl->m_oMetric = m_oInfo;
CDoubleRect oRectBounds;
oRectBounds.left = oNodeMem.ReadAttributeDouble(_T("left")) * m_oInfo.m_lMillimetresHor / 100.0;
oRectBounds.top = oNodeMem.ReadAttributeDouble(_T("top")) * m_oInfo.m_lMillimetresVer / 100.0;
oRectBounds.right = oRectBounds.left + oNodeMem.ReadAttributeDouble(_T("width")) * m_oInfo.m_lMillimetresHor / 100.0;
oRectBounds.bottom = oRectBounds.top + oNodeMem.ReadAttributeDouble(_T("height")) * m_oInfo.m_lMillimetresVer / 100.0;
pShapeEl->LoadFromXmlNode(oNodeMem, &oRectBounds);
pShapeEl->m_oShape.m_rcBounds = pShapeEl->m_rcBounds;
pShapeEl->m_lPlaceholderID = oNodeMem.ReadAttributeInt(_T("id"), -1);
pShapeEl->m_lPlaceholderType = oNodeMem.ReadAttributeInt(_T("type"), -1);
m_arElements.push_back(pShapeEl);
}
}
}
size_t nCountElements = m_arElements.size();
XmlUtils::CXmlNode oNodeStyles;
if (oNode.GetNode(_T("Styles"), oNodeStyles))
{
XmlUtils::CXmlNodes oStyles;
if (oNodeStyles.GetNodes(_T("Style"), oStyles))
{
int nCount = oStyles.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNodeS;
oStyles.GetAt(i, oNodeS);
LONG lPhType = oNodeS.ReadAttributeInt(_T("type"));
CShapeElement* pElement = NULL;
//
for (size_t nIndex = 0; nIndex < nCountElements; ++nIndex)
{
if (m_arElements[nIndex]->m_lPlaceholderType == lPhType)
{
if (m_arElements[nIndex]->m_etType == etShape)
{
pElement = dynamic_cast<CShapeElement*>(m_arElements[nIndex]);
break;
}
}
}
if (NULL != pElement)
{
CStylesCSS oCSS;
CString strStyles = oNodeS.GetText();
oCSS.LoadStyles(strStyles);
size_t nCountS = oCSS.m_arStyles.size();
for (size_t nIndexStyle = 0; nIndexStyle < nCountS; ++nIndexStyle)
{
LONG _lPhType = 0;
LONG _lLevel = 0;
LONG _lTypeStyle = -1;
CLayout::CheckPlaceholderStyle(oCSS.m_arStyles[nIndexStyle].m_strClassName, _lPhType, _lLevel, _lTypeStyle);
if (-1 != _lTypeStyle)
{
if (!pElement->m_oShape.m_oText.m_oStyles.m_pLevels[_lLevel].is_init())
pElement->m_oShape.m_oText.m_oStyles.m_pLevels[_lLevel] = new NSPresentationEditor::CTextStyleLevel();
}
if (0 == _lTypeStyle)
{
oCSS.m_arStyles[nIndexStyle].LoadStylePF(pElement->m_oShape.m_oText.m_oStyles.m_pLevels[_lLevel]->m_oPFRun, m_oInfo);
}
else if (1 == _lTypeStyle)
{
oCSS.m_arStyles[nIndexStyle].LoadStyleCF(pElement->m_oShape.m_oText.m_oStyles.m_pLevels[_lLevel]->m_oCFRun, m_oInfo);
}
}
}
}
}
}
XmlUtils::CXmlNode oNodeFontRefs;
if (oNode.GetNode(_T("StylesFontRef"), oNodeFontRefs))
{
CStylesCSS oCSS;
CString strStyles = oNodeFontRefs.GetText();
oCSS.LoadStyles(strStyles);
size_t nCountS = oCSS.m_arStyles.size();
for (size_t i = 0; i < nCountS; ++i)
{
oCSS.m_arStyles[i].m_strClassName.Delete(0, 6);
LONG lPhType = XmlUtils::GetInteger(oCSS.m_arStyles[i].m_strClassName);
std::map<CString, CString>::iterator pPair = oCSS.m_arStyles[i].m_mapSettings.find(_T("font-index"));
if (oCSS.m_arStyles[i].m_mapSettings.end() != pPair)
{
LONG lFontRef = XmlUtils::GetInteger(pPair->second);
size_t nCountEl = m_arElements.size();
for (size_t j = 0; j < nCountEl; ++j)
{
if ((lPhType == m_arElements[j]->m_lPlaceholderType) &&
(etShape == m_arElements[j]->m_etType))
{
CShapeElement* pShapeElement = dynamic_cast<CShapeElement*>(m_arElements[j]);
if (NULL != pShapeElement)
pShapeElement->m_oShape.m_oText.m_lFontRef = lFontRef;
}
}
}
}
}
#endif
}
}
#include "Elements.h"
#pragma once
#include "Base.h"
#include "Element.h"
namespace NSPresentationEditor
{
class CLayout : public IBase
class CLayout
{
public:
std::vector<IElement*> m_arElements;
std::vector<CColor> m_arColorScheme;
std::map<LONG, LONG> m_mapPlaceholders;
bool m_bUseThemeColorScheme;
// ""( ),
......@@ -28,7 +25,7 @@ namespace NSPresentationEditor
CMetricInfo m_oInfo;
bool m_bShowMasterShapes;
CString m_strLayoutType;
std::wstring m_strLayoutType;
public:
CLayout()
......@@ -157,13 +154,8 @@ namespace NSPresentationEditor
return lFound;
}
CString ToXmlEditor(NSPresentationEditor::CTheme* pTheme, const NSPresentationEditor::CMetricInfo& oInfo);
public:
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode);
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
{
}
NSPresentationEditor::CColor GetColor(const LONG& lIndexScheme)
{
......
......@@ -8,18 +8,13 @@
class CProperty
{
public:
NSOfficeDrawing::PropertyId m_ePID;
bool m_bIsBlip;
bool m_bComplex;
//
DWORD m_lValue;
NSOfficeDrawing::PropertyId m_ePID;
bool m_bIsBlip;
bool m_bComplex;
DWORD m_lValue;
BYTE* m_pOptions;
// - value, m_bComplex == true
BYTE* m_pOptions;
bool m_bIsTruncated;
bool m_bIsTruncated;
public:
CProperty()
......@@ -30,7 +25,7 @@ public:
m_lValue = 0;
m_pOptions = NULL;
m_bIsTruncated = false;
m_bIsTruncated = false;
}
~CProperty()
{
......@@ -54,27 +49,27 @@ public:
{
if (m_bComplex && 0 != m_lValue)
{
if (NSOfficeDrawing::dgmConstrainBounds == m_ePID ||
NSOfficeDrawing::fillShadeColors == m_ePID ||
NSOfficeDrawing::lineDashStyle == m_ePID ||
NSOfficeDrawing::pAdjustHandles == m_ePID ||
NSOfficeDrawing::pConnectionSites == m_ePID ||
NSOfficeDrawing::pConnectionSitesDir == m_ePID ||
NSOfficeDrawing::pInscribe == m_ePID ||
NSOfficeDrawing::pSegmentInfo == m_ePID ||
NSOfficeDrawing::pVertices == m_ePID ||
NSOfficeDrawing::pGuides == m_ePID ||
NSOfficeDrawing::pWrapPolygonVertices == m_ePID ||
NSOfficeDrawing::pRelationTbl == m_ePID ||
NSOfficeDrawing::tableRowProperties == m_ePID ||
NSOfficeDrawing::lineLeftDashStyle == m_ePID ||
NSOfficeDrawing::lineTopDashStyle == m_ePID ||
NSOfficeDrawing::lineRightDashStyle == m_ePID ||
NSOfficeDrawing::lineBottomDashStyle == m_ePID)
if (NSOfficeDrawing::dgmConstrainBounds == m_ePID ||
NSOfficeDrawing::fillShadeColors == m_ePID ||
NSOfficeDrawing::lineDashStyle == m_ePID ||
NSOfficeDrawing::pAdjustHandles == m_ePID ||
NSOfficeDrawing::pConnectionSites == m_ePID ||
NSOfficeDrawing::pConnectionSitesDir == m_ePID ||
NSOfficeDrawing::pInscribe == m_ePID ||
NSOfficeDrawing::pSegmentInfo == m_ePID ||
NSOfficeDrawing::pVertices == m_ePID ||
NSOfficeDrawing::pGuides == m_ePID ||
NSOfficeDrawing::pWrapPolygonVertices == m_ePID ||
NSOfficeDrawing::pRelationTbl == m_ePID ||
NSOfficeDrawing::tableRowProperties == m_ePID ||
NSOfficeDrawing::lineLeftDashStyle == m_ePID ||
NSOfficeDrawing::lineTopDashStyle == m_ePID ||
NSOfficeDrawing::lineRightDashStyle == m_ePID ||
NSOfficeDrawing::lineBottomDashStyle == m_ePID)
{
WORD nElems = StreamUtils::ReadWORD(pStream);
WORD nElemsAlloc = StreamUtils::ReadWORD(pStream);
WORD nElemSize = StreamUtils::ReadWORD(pStream);
WORD nElems = StreamUtils::ReadWORD(pStream);
WORD nElemsAlloc = StreamUtils::ReadWORD(pStream);
WORD nElemSize = StreamUtils::ReadWORD(pStream);
if (0xFFF0 == nElemSize)
{
......@@ -86,7 +81,7 @@ public:
if (m_lValue != (dwSize + 6))
{
bool b = false;
bool b = false;
}
m_lValue = dwSize;
......
......@@ -38,6 +38,8 @@ public:
CBrush m_oBrush;
CTextAttributesEx m_oText;
CShadow m_oShadow;
double m_dWidthLogic;
double m_dHeightLogic;
......@@ -53,7 +55,7 @@ public:
CString m_strPPTXShape;
public:
CShape(NSBaseShape::ClassType ClassType, int ShapeType) : m_rcBounds()
CShape(NSBaseShape::ClassType ClassType, int ShapeType_) : m_rcBounds()
{
m_lDrawType = c_ShapeDrawType_All;
......@@ -79,15 +81,19 @@ public:
if (ClassType == NSBaseShape::pptx)
{
m_pShape = new CPPTXShape();
m_pShape->SetType(NSBaseShape::pptx, ShapeType);
m_pShape->SetType(NSBaseShape::pptx, ShapeType_);
}
#endif
#if defined(PPT_DEF)
if (ClassType == NSBaseShape::ppt)
{
m_pShape = new CPPTShape();
m_pShape->SetType(NSBaseShape::ppt, ShapeType);
m_pShape = CPPTShape::CreateByType((PPTShapes::ShapeType)ShapeType_ );
if (m_pShape == NULL)
{
m_pShape = new CPPTShape();
m_pShape->SetType(NSBaseShape::ppt, ShapeType_);
}
m_dTextMarginX = 2.54;
m_dTextMarginY = 1.27;
......@@ -120,14 +126,7 @@ public:
GetTextRect(oGeomInfo);
return m_oText.ToString(oGeomInfo, pInfo, dStartTime, dEndTime, pTheme, pLayout);
}
virtual CString GetTextXHTML(CGeomShapeInfo& oGeomInfo, CMetricInfo& pInfo, double dStartTime, double dEndTime, const CElemInfo& oElemInfo, CTheme* pTheme, CLayout* pLayout)
{
//if (m_oText.IsEmptyText())
// return _T("");
GetTextRect(oGeomInfo);
return m_oText.ToHTML(oGeomInfo, pInfo, dStartTime, dEndTime, oElemInfo, pTheme, pLayout);
}
virtual CString GetBrushXml()
{
......@@ -237,13 +236,13 @@ public:
CPPTShape* pPPTShape = dynamic_cast<CPPTShape*>(m_pShape);
if (NULL != pPPTShape)
{
pPPTShape->CalcTextRectOffsets(dPercentLeft, dPercentTop, dPercentRight, dPercentBottom);
//pPPTShape->CalcTextRectOffsets(dPercentLeft, dPercentTop, dPercentRight, dPercentBottom);
dLeft += (dPercentLeft * dWidth);
dTop += (dPercentTop * dHeight);
//dLeft += (dPercentLeft * dWidth);
//dTop += (dPercentTop * dHeight);
dWidth -= ((dPercentLeft + dPercentRight) * dWidth);
dHeight -= ((dPercentTop + dPercentBottom) * dHeight);
//dWidth -= ((dPercentLeft + dPercentRight) * dWidth);
//dHeight -= ((dPercentTop + dPercentBottom) * dHeight);
}
}
......@@ -324,6 +323,7 @@ public:
{
m_oPen.SetToRenderer(pRenderer);
m_oBrush.SetToRenderer(pRenderer);
//m_oShadow.SetToRenderer(pRenderer);
m_pShape->ToRenderer(pRenderer, oGeomInfo, dStartTime, dEndTime, m_oPen, m_oBrush, pInfo);
}
......@@ -361,8 +361,8 @@ public:
m_pShape = new CPPTShape();
SetCoordSize(root);
SetPen(root);
SetBrush(root);
SetPen (root);
SetBrush (root);
//return m_pShape->LoadFromXML(xml);
return ((CPPTShape*)m_pShape)->LoadFromXML(root);
......@@ -388,6 +388,7 @@ public:
Shape->m_oPen = m_oPen;
Shape->m_oBrush = m_oBrush;
Shape->m_oText = m_oText;
Shape->m_oShadow = m_oShadow;
Shape->m_dWidthLogic = m_dWidthLogic;
Shape->m_dHeightLogic = m_dHeightLogic;
......
......@@ -358,94 +358,6 @@ namespace NSPresentationEditor
{
}
CString ToXmlEditor(NSPresentationEditor::CTheme* pTheme, NSPresentationEditor::CLayout* pLayout, const NSPresentationEditor::CMetricInfo& oInfo)
{
NSPresentationEditor::CStringWriter oWriter;
LONG lWidthPix = (LONG)(96.0 * m_lWidth / 25.4);
LONG lHeightPix = (LONG)(96.0 * m_lHeight / 25.4);
CString XmlSlideSource = _T("");
XmlSlideSource.Format ( _T("<Slide color=\"16777215\" duration=\"%lf\" width=\"%d\" height=\"%d\" themeid=\"%d\" layoutid=\"%d\" themeidsrc=\"%d\" layoutidsrc=\"%d\" usethemeobjects=\"%d\" transition=\"%d\" transition-speed=\"%.2lf\">"),
m_dDuration, lWidthPix, lHeightPix, m_lThemeID, m_lLayoutID, m_lThemeID, m_lLayoutID, m_bShowMasterShapes ? 1 : 0,
m_oSlideShow.m_oTransition.m_nEffectType, m_oSlideShow.m_oTransition.m_dSpeed );
oWriter.WriteString(XmlSlideSource);
if (m_bIsBackground)
{
// background
#ifdef PPT_DEF
CShapeElement oElem(NSPresentationEditor::NSBaseShape::ppt, PPTShapes::sptCRect);
#else
CShapeElement oElem(NSPresentationEditor::NSBaseShape::pptx, OOXMLShapes::sptCRect);
#endif
oElem.m_oMetric = oInfo;
oElem.m_rcBoundsOriginal.left = 0.0;
oElem.m_rcBoundsOriginal.right = (double)oInfo.m_lUnitsHor;
oElem.m_rcBoundsOriginal.top = 0.0;
oElem.m_rcBoundsOriginal.bottom = (double)oInfo.m_lUnitsVer;
double dScaleX = (double)oInfo.m_lMillimetresHor / oInfo.m_lUnitsHor;
double dScaleY = (double)oInfo.m_lMillimetresVer / oInfo.m_lUnitsVer;
oElem.NormalizeCoords(dScaleX, dScaleY);
oElem.m_oShape.m_oBrush = m_oBackground;
oElem.m_bIsBackground = true;
oElem.m_bIsChangeable = false;
oWriter.WriteString(std::wstring(L"<Background>"));
oElem.SetupProperties(this, pTheme, pLayout);
oWriter.WriteString(oElem.ToXmlEditor());
oWriter.WriteString(std::wstring(L"</Background>"));
}
std::wstring strFontRefs = _T("");
// elements
size_t nCount = m_arElements.size();
for (size_t i = 0; i < nCount; ++i)
{
IElement* pElement = m_arElements[i];
CString strElement = _T("");
strElement.Format(_T("<Element type=\"%d\" id=\"%d\" layoutid=\"%d\" phid=\"%d\" phtype=\"%d\" angle=\"%lf\" flipx=\"%d\" flipy=\"%d\">"),
(int)pElement->m_etType, pElement->m_lID, pElement->m_lLayoutID, pElement->m_lPlaceholderID,
pElement->m_lPlaceholderType, pElement->m_dRotate, pElement->m_bFlipH ? 1 : 0, pElement->m_bFlipV ? 1 : 0);
pElement->m_bIsBackground = false;
pElement->m_bIsChangeable = true;
oWriter.WriteString(strElement);
oWriter.WriteString(pElement->ToXmlEditor());
oWriter.WriteString(std::wstring(L"</Element>"));
if (etShape == pElement->m_etType)
{
CShapeElement* pTextElement = dynamic_cast<CShapeElement*>(pElement);
if (NULL != pTextElement)
{
LONG lFontRef = pTextElement->m_oShape.m_oText.m_lFontRef;
if (pTextElement->m_oShape.m_oText.m_bIsSlideFontRef && (0 <= lFontRef) && (lFontRef < (LONG)pTheme->m_arFonts.size()))
{
CString strRef = _T("");
strRef.Format(_T("s_font%d { font-index:%d;font-family:%ls; }\n"),
pTextElement->m_lID, lFontRef, pTheme->m_arFonts[lFontRef].Name);
strFontRefs += string2std_string(strRef);
}
}
}
}
oWriter.WriteString(std::wstring(L"<StylesFontRef>") + strFontRefs + _T("</StylesFontRef>"));
oWriter.WriteString(std::wstring(L"</Slide>"));
return oWriter.GetData();
}
void SetUpPlaceholderStyles(NSPresentationEditor::CLayout* pLayout)
{
size_t nCountElements = m_arElements.size();
......
......@@ -267,7 +267,7 @@ namespace NSPresentationEditor
pColor->m_lSchemeIndex = -1;
if (bSchemeIndex)
if (bSchemeIndex || bSysIndex)
{
pColor->m_lSchemeIndex = R;
CorrectColorPPT(pColor->m_lSchemeIndex);
......
......@@ -180,171 +180,8 @@ namespace NSPresentationEditor
return strText + strTimeLine + _T("</ImagePaint-DrawTextEx>");
}
CString CTextAttributesEx::ToHTML(CGeomShapeInfo& oInfo, CMetricInfo& pMetricInfo, double dStartTime, double dEndTime, const CElemInfo& oElemInfo, CTheme* pTheme, CLayout* pLayout)
void CTextAttributesEx::RecalcParagraphsPPT(CTheme* pTheme)
{
m_oBounds.left = (LONG)oInfo.m_dLeft;
m_oBounds.top = (LONG)oInfo.m_dTop;
m_oBounds.right = (LONG)(oInfo.m_dLeft + oInfo.m_dWidth);
m_oBounds.bottom = (LONG)(oInfo.m_dTop + oInfo.m_dHeight);
double dRight = oInfo.m_dLeft + oInfo.m_dWidth;
double dLeft = oInfo.m_dLeft;
//if (2 == m_lWrapMode)
//{
// LONG lAlign = 0;
// if (m_arPFs.size() > 0)
// lAlign = m_arPFs[0].textAlignment;
// else
// lAlign = m_oAttributes.m_nTextAlignHorizontal;
//
// switch (lAlign)
// {
// case 1:
// {
// // center
// dLeft -= pMetricInfo.m_lMillimetresHor;
// dRight += pMetricInfo.m_lMillimetresHor;
// break;
// }
// default:
// {
// dRight = pMetricInfo.m_lMillimetresHor;
// break;
// }
// };
//}
CString strHTML = _T("");
LONG _lLeft = (LONG)(dLeft * 96 / 25.4);
LONG _lWidth = (LONG)((dRight - dLeft) * 96 / 25.4);
LONG _lTop = (LONG)(oInfo.m_dTop * 96 / 25.4);
LONG _lHeight = (LONG)(oInfo.m_dHeight * 96 / 25.4);
CString strText = _T("");
// add Text Param
strText.Format(_T("<text left='%d' top='%d' width='%d' height='%d' angle='%lf' background='%d' changeable='%d'>"),
_lLeft, _lTop, _lWidth, _lHeight, oInfo.m_dRotate, (int)(oElemInfo.m_bIsBackground ? 1 : 0), (int)(oElemInfo.m_bIsChangeable ? 1 : 0));
strHTML += strText;
strHTML += _T("<body>");
RecalcParagraphs(pTheme);
#ifdef PPT_DEF
#ifndef PPTX_DEF
//
CorrectRuler();
#endif
#endif
size_t nCountPars = m_arParagraphs.size();
for (size_t i = 0; i < nCountPars; ++i)
{
CParagraph* pParagraph = &m_arParagraphs[i];
LONG lLevel = pParagraph->m_lTextLevel;
CString strClass = _T("");
CTextPFRun oPFRun;
bool bIsBullet = (pParagraph->m_oPFRun.hasBullet.is_init() && pParagraph->m_oPFRun.hasBullet.get()) ? true : false;
if (-1 != m_lTextType)
{
CString strClassTheme = _T("");
strClassTheme.Format(_T("s%d_lvl%d_pf"), m_lTextType, lLevel);
strClass += strClassTheme;
}
if (-1 != m_lPlaceholderType)
{
CString strPlaceholderStyle = _T("");
strPlaceholderStyle.Format(_T("t%d_lvl%d_pf"), m_lPlaceholderType, lLevel);
strClass += _T(" ");
strClass += strPlaceholderStyle;
}
if (m_oStyles.m_pLevels[lLevel].is_init())
{
oPFRun.ApplyAfter(m_oStyles.m_pLevels[lLevel]->m_oPFRun);
}
oPFRun.ApplyAfter(pParagraph->m_oPFRun);
//
size_t nSpans = pParagraph->m_arSpans.size();
CString strCFs = _T("");
for (size_t j = 0; j < nSpans; ++j)
{
CSpan* pSpan = &pParagraph->m_arSpans[j];
CString strClassCF = _T("");
CTextCFRun oCFRun;
if (-1 != m_lTextType)
{
CString strClassTheme = _T("");
strClassTheme.Format(_T("s%d_lvl%d_cf"), m_lTextType, lLevel);
strClassCF += strClassTheme;
}
if (-1 != m_lPlaceholderType)
{
LONG lCountThisType = 0;
if (NULL != pLayout)
lCountThisType = pLayout->GetCountPlaceholderWithType(m_lPlaceholderType);
if (1 < lCountThisType)
{
CString strPlaceholderStyle = _T("");
strPlaceholderStyle.Format(_T("l_font%d t%d_lvl%d_id%d_cf"), m_lPlaceholderType, m_lPlaceholderType, lLevel, m_lPlaceholderID);
strClassCF += _T(" ");
strClassCF += strPlaceholderStyle;
}
else
{
CString strPlaceholderStyle = _T("");
strPlaceholderStyle.Format(_T("l_font%d t%d_lvl%d_cf"), m_lPlaceholderType, m_lPlaceholderType, lLevel);
strClassCF += _T(" ");
strClassCF += strPlaceholderStyle;
}
}
if (m_bIsSlideFontRef && -1 != m_lFontRef)
{
CString strClassRef = _T("");
strClassRef.Format(_T(" s_font%d"), oElemInfo.m_lID);
strClassCF += strClassRef;
}
if (m_oStyles.m_pLevels[lLevel].is_init())
{
oCFRun.ApplyAfter(m_oStyles.m_pLevels[lLevel]->m_oCFRun);
}
oCFRun.ApplyAfter(pSpan->m_oRun);
CString strRunText = pSpan->m_strText;
if (oCFRun.Cap.is_init())
{
if (1 == oCFRun.Cap.get())
strRunText.MakeUpper();
else if (2 == oCFRun.Cap.get())
strRunText.MakeLower();
}
NormalizeString(strRunText);
strCFs += oCFRun.ToXmlEditor(strClassCF, strRunText);
}
strHTML += oPFRun.ToXmlEditor(strClass, strCFs, oInfo);
}
strHTML += _T("</body>");
strHTML += _T("</text>");
return strHTML;
}
void CTextAttributesEx::RecalcParagraphs(CTheme* pTheme)
{
#ifdef PPT_FORMAT
for (LONG i = 0; i < (LONG)m_arParagraphs.size(); ++i)
{
bool bIsBreak = true;
......@@ -458,12 +295,110 @@ namespace NSPresentationEditor
}
}
#endif
size_t nCount = m_arParagraphs.size();
for (size_t i = 0; i < nCount; ++i)
{
m_arParagraphs[i].CheckErrors();
}
}
void CTextAttributesEx::RecalcParagraphs(CTheme* pTheme)
{
#ifdef PPT_FORMAT
RecalcParagraphsPPT(pTheme);
#else
size_t nCount = m_arParagraphs.size();
for (size_t i = 0; i < nCount; ++i)
{
m_arParagraphs[i].CheckErrors();
}
#endif
}
void CTextAttributesEx::NormalizeCoordsByMetric(const CMetricInfo & oMetric)
{
double dScaleX = 625 * 2.54 ;//???? /2
//1/576 inch = 72/576 pt = 360000 *72 * 2.54 /(72*576) emu
size_t lCount = m_arParagraphs.size();
for (size_t i = 0; i < lCount; ++i)
{
CTextPFRun* pPar = &m_arParagraphs[i].m_oPFRun;
WORD lIndentLevel = (WORD)m_arParagraphs[i].m_lTextLevel;
switch (lIndentLevel)
{
case 0:
{
if (m_oRuler.LeftMargin1.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin1.get();
if (m_oRuler.Indent1.is_init())
pPar->indent = (LONG)m_oRuler.Indent1.get();
if (pPar->indent.is_init() && pPar->leftMargin.is_init())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 1:
{
if (m_oRuler.LeftMargin2.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin2.get();
if (m_oRuler.Indent2.is_init())
pPar->indent = (LONG)m_oRuler.Indent2.get();
if (pPar->indent.is_init() && pPar->leftMargin.is_init())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 2:
{
if (m_oRuler.LeftMargin3.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin3.get();
if (m_oRuler.Indent3.is_init())
pPar->indent = (LONG)m_oRuler.Indent3.get();
if (pPar->indent.is_init() && pPar->leftMargin.is_init())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 3:
{
if (m_oRuler.LeftMargin4.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin4.get();
if (m_oRuler.Indent4.is_init())
pPar->indent = (LONG)m_oRuler.Indent4.get();
if (pPar->indent.is_init() && pPar->leftMargin.is_init())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 4:
{
if (m_oRuler.LeftMargin5.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin5.get();
if (m_oRuler.Indent5.is_init())
pPar->indent = (LONG)m_oRuler.Indent5.get();
if (pPar->indent.is_init() && pPar->leftMargin.is_init())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
default:
break;
}
if (pPar->leftMargin.is_init())
pPar->leftMargin = pPar->leftMargin.get() * dScaleX;
if (pPar->indent.is_init())
pPar->indent = pPar->indent.get() * dScaleX;
if (pPar->lineSpacing.is_init())
pPar->lineSpacing =- pPar->lineSpacing.get();
if (pPar->spaceAfter.is_init())
pPar->spaceAfter = -pPar->spaceAfter.get() ;
if (pPar->spaceBefore.is_init())
pPar->spaceBefore = -pPar->spaceBefore.get() ;
if (pPar->defaultTabSize.is_init())
pPar->defaultTabSize = pPar->defaultTabSize.get()* dScaleX;
}
}
}
......@@ -29,8 +29,9 @@ namespace NSPresentationEditor
std::vector<CParagraph> m_arParagraphs;
// ( )
bool m_bVertical;
bool m_bRightToLeft;
bool m_bVertical;
bool m_bRightToLeft;
LONG m_lWrapMode; // 0 - square, default; 1 - none wrap
// .
......@@ -107,7 +108,6 @@ namespace NSPresentationEditor
}
CString ToString(CGeomShapeInfo& oInfo, CMetricInfo& pMetricInfo, double dStartTime, double dEndTime, CTheme* pTheme, CLayout* pLayout);
CString ToHTML(CGeomShapeInfo& oInfo, CMetricInfo& pMetricInfo, double dStartTime, double dEndTime, const CElemInfo& oElemInfo, CTheme* pTheme, CLayout* pLayout);
public:
inline void NormalizeString(CString& strText)
......@@ -124,94 +124,10 @@ namespace NSPresentationEditor
//SysFreeString(bsText);
}
void RecalcParagraphs(CTheme* pTheme = NULL);
void RecalcParagraphs (CTheme* pTheme = NULL);
void RecalcParagraphsPPT(CTheme* pTheme = NULL);
void NormalizeCoordsByMetric(const CMetricInfo & oMetric)
{
double dScaleX = (double)oMetric.m_lUnitsHor / oMetric.m_lMillimetresHor / 24.;
double dScaleY = (double)oMetric.m_lUnitsVer / oMetric.m_lMillimetresVer / 24.;
size_t lCount = m_arParagraphs.size();
for (size_t i = 0; i < lCount; ++i)
{
CTextPFRun* pPar = &m_arParagraphs[i].m_oPFRun;
WORD lIndentLevel = (WORD)m_arParagraphs[i].m_lTextLevel;
switch (lIndentLevel)
{
case 0:
{
if (m_oRuler.LeftMargin1.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin1.get();
if (m_oRuler.Indent1.is_init())
pPar->indent = (LONG)m_oRuler.Indent1.get();
if (pPar->indent.is_init() && pPar->leftMargin.get())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 1:
{
if (m_oRuler.LeftMargin2.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin2.get();
if (m_oRuler.Indent2.is_init())
pPar->indent = (LONG)m_oRuler.Indent2.get();
if (pPar->indent.is_init() && pPar->leftMargin.get())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 2:
{
if (m_oRuler.LeftMargin3.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin3.get();
if (m_oRuler.Indent3.is_init())
pPar->indent = (LONG)m_oRuler.Indent3.get();
if (pPar->indent.is_init() && pPar->leftMargin.get())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 3:
{
if (m_oRuler.LeftMargin4.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin4.get();
if (m_oRuler.Indent4.is_init())
pPar->indent = (LONG)m_oRuler.Indent4.get();
if (pPar->indent.is_init() && pPar->leftMargin.get())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
case 4:
{
if (m_oRuler.LeftMargin5.is_init())
pPar->leftMargin = (LONG)m_oRuler.LeftMargin5.get();
if (m_oRuler.Indent5.is_init())
pPar->indent = (LONG)m_oRuler.Indent5.get();
if (pPar->indent.is_init() && pPar->leftMargin.get())
pPar->indent.get() -= pPar->leftMargin.get();
break;
}
default:
break;
}
if (pPar->leftMargin.is_init())
pPar->leftMargin = pPar->leftMargin.get() * dScaleX;
if (pPar->indent.is_init())
pPar->indent = pPar->indent.get() * dScaleX;
if (pPar->lineSpacing.is_init())
pPar->lineSpacing =- pPar->lineSpacing.get();// * dScaleY;
if (pPar->spaceAfter.is_init())
pPar->spaceAfter = -pPar->spaceAfter.get() ;//* dScaleY;
if (pPar->spaceBefore.is_init())
pPar->spaceBefore = -pPar->spaceBefore.get() ;//* dScaleY;
if (pPar->defaultTabSize.is_init())
pPar->defaultTabSize = pPar->defaultTabSize.get()* dScaleX;
}
}
void NormalizeCoordsByMetric(const CMetricInfo & oMetric);
void CorrectRuler()
{
......
......@@ -349,129 +349,6 @@ namespace NSPresentationEditor
return oWriter.GetXmlString();
}
CString ToXmlEditor(CString& strClass, CString& strText)
{
CString strStyle = _T("");
if (FontBold.is_init())
{
if (FontBold.get())
{
strStyle += _T("font-weight: bold;");
}
else
{
strStyle += _T("font-weight: normal;");
}
}
if (FontItalic.is_init())
{
if (FontItalic.get())
{
strStyle += _T("font-style: italic;");
}
else
{
strStyle += _T("font-style: normal;");
}
}
if (FontUnderline.is_init())
{
if (FontUnderline.get())
{
strStyle += _T("text-decoration: underline;");
}
else
{
strStyle += _T("text-decoration: none;");
}
}
/*if (FontStrikeout.is_init())
{
if (FontStrikeout.get())
{
strStyle += _T("text-decoration: line-through;");
}
else
{
strStyle += _T("text-decoration: normal;");
}
}*/
if (FontShadow.is_init())
{
if (FontShadow.get())
{
strStyle += _T("text-shadow: black 1px 1px 2px;");
}
else
{
strStyle += _T("text-shadow: none;");
}
}
if (Cap.is_init())
{
WORD lCap = Cap.get();
if (1 == lCap)
strStyle += _T("text-transform: uppercase;");
else if (2 == lCap)
strStyle += _T("text-transform: lowercase;");
else
strStyle += _T("text-transform: none;");
}
if (Size.is_init())
{
CString strFontSize = _T("");
strFontSize.Format(_T("font-size: %dpt;"), (int)Size.get());
strStyle += strFontSize;
}
if (Color.is_init())
{
if (-1 != Color->m_lSchemeIndex)
{
CString strTMColor = _T("");
strTMColor.Format(_T("tm_color:%d;"), Color->m_lSchemeIndex + 1);
strStyle += strTMColor;
CString strColor = _T("");
strColor.Format(_T(" color%d"), Color->m_lSchemeIndex + 1);
strClass += strColor;
}
else
{
CString strColor = _T("");
strColor.Format(_T("color: #%06x;"), (int)Color->GetLONG_RGB());
strStyle += strColor;
}
}
bool bIsFontNamPres = (FontProperties.is_init() && (_T("") != FontProperties->strFontName));
if (Typeface.is_init() && !bIsFontNamPres)
{
CString strFont = _T("");
strFont.Format(_T(" font_d%d"), (long)Typeface.get() + 1);
strClass += strFont;
}
else if (bIsFontNamPres)
{
strStyle += _T("font-family: ");
strStyle += std_string2string(FontProperties->strFontName);
strStyle += _T(";");
}
strText.Replace((WCHAR)(11), '\n');
//strText.Replace(_T("\n"), _T("VVODbryakVVOD"));//xml2_reader
//strText.Replace(_T("\n"), _T("<br\>"));
if (_T("\n") == strText)
{
//return _T("<br class=\"") + strClass + _T("\" style=\"") + strStyle + _T("\" />");
return _T("<span class=\"") + strClass + _T("\" style=\"") + strStyle + _T("\"><br/></span>");
}
return _T("<span class=\"") + strClass + _T("\" style=\"") + strStyle + _T("\">") + strText + _T("</span>");
}
};
class CTextPFRun
......@@ -699,124 +576,6 @@ namespace NSPresentationEditor
return oWriter.GetXmlString();
}
CString ToXmlEditor(CString& strClass, CString& strSpans, CGeomShapeInfo& oInfo)
{
CString strStyle = _T("margin-top:0px;margin-bottom:0px;margin-right:0px;");
int nAlign = 0;
if (textAlignment.is_init())
{
nAlign = (int)textAlignment.get();
CString strAlign = _T("text-align:center;");
if (0 == nAlign)
strAlign = _T("text-align:left;");
else if (2 == nAlign)
strAlign = _T("text-align:right;");
else if (3 == nAlign)
strAlign = _T("text-align:justify;");
strStyle += strAlign;
}
if (lineSpacing.is_init() && 0 != oInfo.m_lOriginalWidth)
{
int lnSpc = (int)lineSpacing.get();
if (lnSpc < 0)
{
CString strSpc = _T("");
strSpc.Format(_T("lnspc:%d;"), (int)((-1000 * oInfo.m_dWidth * lnSpc) / oInfo.m_lOriginalWidth));
strStyle += strSpc;
}
else
{
CString strSpc = _T("");
strSpc.Format(_T("lnspc:%d;"), -lnSpc);
strStyle += strSpc;
}
}
if (spaceAfter.is_init() && 0 != oInfo.m_lOriginalWidth)
{
int lnSpc = (int)spaceAfter.get();
if (lnSpc < 0)
{
CString strSpc = _T("");
strSpc.Format(_T("spcafter:%d;"), (int)((-1000 * oInfo.m_dWidth * lnSpc) / oInfo.m_lOriginalWidth));
strStyle += strSpc;
}
else
{
CString strSpc = _T("");
strSpc.Format(_T("spcafter:%d;"), -lnSpc);
strStyle += strSpc;
}
}
if (spaceBefore.is_init() && 0 != oInfo.m_lOriginalWidth)
{
int lnSpc = (int)spaceBefore.get();
if (lnSpc < 0)
{
CString strSpc = _T("");
strSpc.Format(_T("spcbefore:%d;"), (int)((-1000 * oInfo.m_dWidth * lnSpc) / oInfo.m_lOriginalWidth));
strStyle += strSpc;
}
else
{
CString strSpc = _T("");
strSpc.Format(_T("spcbefore:%d;"), -lnSpc);
strStyle += strSpc;
}
}
int nIndent = 0;
if (indent.is_init() && 0 != oInfo.m_lOriginalWidth)
{
nIndent = (int)(oInfo.m_dWidth * indent.get() * 96.0 / (oInfo.m_lOriginalWidth * 25.4));
// html , :
//nIndent = 0;
CString strIndent = _T("");
strIndent.Format(_T("text-indent:%dpx;"), (int)nIndent);
strStyle += strIndent;
}
int nMargin = 0;
if (leftMargin.is_init() && 0 != oInfo.m_lOriginalWidth)
{
nMargin = (int)(oInfo.m_dWidth * leftMargin.get() * 96.0 / (oInfo.m_lOriginalWidth * 25.4));
CString strMargin = _T("");
strMargin.Format(_T("margin-left:%dpx;"), (int)nMargin);
strStyle += strMargin;
}
if (bulletColor.is_init())
{
if (-1 != bulletColor->m_lSchemeIndex)
{
CString strTMColor = _T("");
strTMColor.Format(_T("color:"), bulletColor->m_lSchemeIndex + 1);
strStyle += (_T("tm_") + strTMColor);
CString strClassColor = _T("");
strClassColor.Format(_T(" color%d"), bulletColor->m_lSchemeIndex + 1);
strClass += strClassColor;
}
else
{
CString strColor = _T("");
strColor.Format(_T("color: #%06x;"), (int)bulletColor->GetLONG_RGB());
strStyle += strColor;
}
}
if (hasBullet.is_init() && (hasBullet.get() == true))
{
return _T("<ul style=\"padding:0px;margin:0px 0px 0px 20px;list-style-position:outside;\"><li class=\"" + strClass + "\" style=\"") +
strStyle + _T("\">") + strSpans + _T("</li></ul>\n");
}
return _T("<p class=\"") + strClass + _T("\" style=\"padding: 0px;") + strStyle + _T("\">") + strSpans + _T("</p>\n");
}
};
class CTextRuler
......@@ -1208,241 +967,6 @@ namespace NSPresentationEditor
m_oPFRun.ApplyBefore(oSrc.m_oPFRun);
m_oCFRun.ApplyBefore(oSrc.m_oCFRun);
}
CString ToXmlEditor(const CMetricInfo& oInfo, bool bIsLayout, LONG lTextOrPlaceholderType, LONG lID, LONG lNumLevel)
{
NSPresentationEditor::CStringWriter oWriter;
// - PF -------------------------------------------
CString strStylePF = _T("");
if (!bIsLayout)
strStylePF.Format(_T(".s%d_lvl%u_pf { "), lTextOrPlaceholderType, lNumLevel);
else
{
if (-1 == lID)
{
strStylePF.Format(_T(".t%d_lvl%u_pf { "), lTextOrPlaceholderType, lNumLevel);
}
else
{
strStylePF.Format(_T(".t%d_lvl%u_id%d_pf { "), lTextOrPlaceholderType, lNumLevel, lID);
}
}
oWriter.WriteString(strStylePF);
if (m_oPFRun.textAlignment.is_init())
{
int nAlign = (int)m_oPFRun.textAlignment.get();
if (0 == nAlign)
oWriter.WriteString(std::wstring(L"text-align:left;"));
else if (2 == nAlign)
oWriter.WriteString(std::wstring(L"text-align:right;"));
else if (3 == nAlign)
oWriter.WriteString(std::wstring(L"text-align:justify;"));
else
oWriter.WriteString(std::wstring(L"text-align:center;"));
}
int nMargin = 0;
int nIndent = 0;
if (m_oPFRun.leftMargin.is_init() && (0 != oInfo.m_lUnitsHor))
{
double dKoef = (double)m_oPFRun.leftMargin.get() / oInfo.m_lUnitsHor;
nMargin = (int)(oInfo.m_lMillimetresHor * dKoef * 96.0 / 25.4);
}
if (m_oPFRun.indent.is_init() && (0 != oInfo.m_lUnitsHor))
{
double dKoef = (double)m_oPFRun.indent.get() / oInfo.m_lUnitsHor;
// html , :
nIndent = (int)(oInfo.m_lMillimetresHor * dKoef * 96.0 / 25.4);
}
CString strPaddings = _T("");
strPaddings.Format(_T("margin-left: %dpx;text-indent: %dpx;"), nMargin, nIndent);
if (m_oPFRun.lineSpacing.is_init() && 0 != oInfo.m_lUnitsHor)
{
int lnSpc = (int)m_oPFRun.lineSpacing.get();
if (lnSpc < 0)
{
CString strSpc = _T("");
strSpc.Format(_T("lnspc:%d;"), (int)((-1000 * oInfo.m_lMillimetresHor * lnSpc) / oInfo.m_lUnitsHor));
strPaddings += strSpc;
}
else
{
CString strSpc = _T("");
strSpc.Format(_T("lnspc:%d;"), -lnSpc);
strPaddings += strSpc;
}
}
if (m_oPFRun.spaceAfter.is_init() && 0 != oInfo.m_lUnitsHor)
{
int lnSpc = (int)m_oPFRun.spaceAfter.get();
if (lnSpc < 0)
{
CString strSpc = _T("");
strSpc.Format(_T("spcafter:%d;"), (int)((-1000 * oInfo.m_lMillimetresHor * lnSpc) / oInfo.m_lUnitsHor));
strPaddings += strSpc;
}
else
{
CString strSpc = _T("");
strSpc.Format(_T("spcafter:%d;"), -lnSpc);
strPaddings += strSpc;
}
}
if (m_oPFRun.spaceBefore.is_init() && 0 != oInfo.m_lUnitsHor)
{
int lnSpc = (int)m_oPFRun.spaceBefore.get();
if (lnSpc < 0)
{
CString strSpc = _T("");
strSpc.Format(_T("spcbefore:%d;"), (int)((-1000 * oInfo.m_lMillimetresHor * lnSpc) / oInfo.m_lUnitsHor));
strPaddings += strSpc;
}
else
{
CString strSpc = _T("");
strSpc.Format(_T("spcbefore:%d;"), -lnSpc);
strPaddings += strSpc;
}
}
oWriter.WriteString(strPaddings);
// bulletColor
if (m_oPFRun.bulletColor.is_init())
{
CString strBulletColor = _T("");
strBulletColor.Format(_T("color: #%06x;"), m_oPFRun.bulletColor->GetLONG_RGB());
oWriter.WriteString(strBulletColor);
}
CString strEndPF = _T(" }\n");
oWriter.WriteString(strEndPF);
// -------------------------------------------------------------
// - CF -------------------------------------------
CString strStyleCF = _T("");
if (!bIsLayout)
strStyleCF.Format(_T(".s%d_lvl%u_cf { "), lTextOrPlaceholderType, lNumLevel);
else
{
if (-1 == lID)
{
strStyleCF.Format(_T(".t%d_lvl%u_cf { "), lTextOrPlaceholderType, lNumLevel);
}
else
{
strStyleCF.Format(_T(".t%d_lvl%u_id%d_cf { "), lTextOrPlaceholderType, lNumLevel, lID);
}
}
oWriter.WriteString(strStyleCF);
// -------------------------------------------------------------
// run
if (m_oCFRun.FontBold.is_init())
{
if (m_oCFRun.FontBold.get())
{
oWriter.WriteString(std::wstring(L"font-weight: bold;"));
}
else
{
oWriter.WriteString(std::wstring(L"font-weight: normal;"));
}
}
if (m_oCFRun.FontItalic.is_init())
{
if (m_oCFRun.FontItalic.get())
{
oWriter.WriteString(std::wstring(L"font-style: italic;"));
}
else
{
oWriter.WriteString(std::wstring(L"font-style: normal;"));
}
}
if (m_oCFRun.FontUnderline.is_init())
{
if (m_oCFRun.FontUnderline.get())
{
oWriter.WriteString(std::wstring(L"text-decoration: underline;"));
}
else
{
oWriter.WriteString(std::wstring(L"text-decoration: none;"));
}
}
/*if (m_oCFRun.FontStrikeout.is_init())
{
if (m_oCFRun.FontStrikeout.get())
{
oWriter.WriteString(std::wstring(L"text-decoration: line-through;"));
}
else
{
oWriter.WriteString(std::wstring(L"text-decoration: normal;"));
}
}*/
if (m_oCFRun.FontShadow.is_init())
{
if (m_oCFRun.FontShadow.get())
{
oWriter.WriteString(std::wstring(L"text-shadow: black 1px 1px 2px;"));
}
else
{
oWriter.WriteString(std::wstring(L"text-shadow: none;"));
}
}
if (m_oCFRun.Size.is_init())
{
CString strFontSize = _T("");
strFontSize.Format(_T("font-size: %dpt;"), (int)m_oCFRun.Size.get());
oWriter.WriteString(strFontSize);
}
if (m_oCFRun.Color.is_init())
{
if (-1 != m_oCFRun.Color->m_lSchemeIndex)
{
CString strColorScheme = _T("");
strColorScheme.Format(_T("tm_color:%d;"), m_oCFRun.Color->m_lSchemeIndex + 1);
oWriter.WriteString(strColorScheme);
}
CString strColor = _T("");
strColor.Format(_T("color: #%06x;"), m_oCFRun.Color->GetLONG_RGB());
oWriter.WriteString(strColor);
}
if (m_oCFRun.Typeface.is_init())
{
CString strFontScheme = _T("");
strFontScheme.Format(_T("tm_font:%d;"), (int)m_oCFRun.Typeface.get() + 1);
oWriter.WriteString(strFontScheme);
}
if (m_oCFRun.FontProperties.is_init())
{
oWriter.WriteString(std::wstring(L"font-family: "));
oWriter.WriteString(m_oCFRun.FontProperties->strFontName);
oWriter.WriteString(std::wstring(L"; }\n"));
}
else
{
oWriter.WriteString(std::wstring(L" }\n"));
}
return oWriter.GetData();
}
};
class CTextFullInfo
......@@ -1522,28 +1046,6 @@ namespace NSPresentationEditor
}
}
CString ToXmlEditor(const CMetricInfo& oInfo, bool bIsLayout, LONG lTextOrPlaceholderType, LONG lID)
{
NSPresentationEditor::CStringWriter oWriter;
CString strTypeStyle = _T("");
strTypeStyle.Format(_T("<Style type=\"%u\">"), lTextOrPlaceholderType);
oWriter.WriteString(strTypeStyle);
for (size_t i = 0; i < 10; ++i)
{
// .
// , .
// . ( )
if (m_pLevels[i].is_init())
oWriter.WriteString(m_pLevels[i]->ToXmlEditor(oInfo, bIsLayout, lTextOrPlaceholderType, lID, (LONG)i));
}
oWriter.WriteString(std::wstring(L"</Style>"));
return oWriter.GetData();
}
};
class CParagraph
......
......@@ -2,276 +2,4 @@
namespace NSPresentationEditor
{
CString NSPresentationEditor::CTheme::ToXmlEditor(const CMetricInfo& oInfo)
{
NSPresentationEditor::CStringWriter oWriter;
oWriter.WriteString(std::wstring(L"<Theme name=\""));
oWriter.WriteString(m_sThemeName);
oWriter.WriteString(std::wstring(L"\">"));
// colors ----
oWriter.WriteString(std::wstring(L"<Colors>"));
size_t nCountColors = m_arColorScheme.size();
for (size_t i = 0; i < nCountColors; ++i)
{
CString strFormat = _T("");
LONG lColorValue = m_arColorScheme[i].GetLONG_RGB();
strFormat.Format(_T(".color%u { color: #%06x; } .stroke%u { stroke:#%06x; } .fill%u { fill:#%06x; }\n"),
i + 1, lColorValue, i + 1, lColorValue, i + 1, lColorValue);
oWriter.WriteString(strFormat);
}
oWriter.WriteString(std::wstring(L"</Colors>"));
// -----------
// fonts -----
oWriter.WriteString(std::wstring(L"<Fonts>"));
size_t nCountFonts = m_arFonts.size();
//if (nCountFonts > 1)
// nCountFonts = 1;
for (size_t i = 0; i < nCountFonts; ++i)
{
CString strFormat = _T("");
strFormat.Format(_T(".font%u { font-family:%ls;tmdocs_charset:%d;tmdocs_monospace:%d;tmdocs_panose:%ls; }\n"),
i + 1, m_arFonts[i].Name, m_arFonts[i].Charset, m_arFonts[i].Monospace, m_arFonts[i].Panose);
oWriter.WriteString(strFormat);
}
oWriter.WriteString(std::wstring(L"</Fonts>"));
// -----------
// fonts dublicate
oWriter.WriteString(std::wstring(L"<FontsDublicate>"));
for (size_t i = 0; i < nCountFonts; ++i)
{
CString strFormat = _T("");
strFormat.Format(_T(".font_d%u { font-family:%ls; }\n"), i + 1, m_arFonts[i].Name);
oWriter.WriteString(strFormat);
}
oWriter.WriteString(std::wstring(L"</FontsDublicate>"));
// -----------
// textstyles ------
oWriter.WriteString(std::wstring(L"<TextStyles>"));
for (long i = 0; i < g_ThemeTextStylesCount; ++i)
{
oWriter.WriteString(m_pStyles[i].ToXmlEditor(oInfo, false, i, -1));
}
oWriter.WriteString(std::wstring(L"</TextStyles>"));
// -----------------
// background
#ifndef ENABLE_PPT_TO_PPTX_CONVERT
#ifdef PPT_DEF
CShapeElement oElem(NSPresentationEditor::NSBaseShape::ppt, PPTShapes::sptCRect);
#else
CShapeElement oElem(NSPresentationEditor::NSBaseShape::pptx, OOXMLShapes::sptCRect);
#endif
#else
CShapeElement oElem(NSPresentationEditor::NSBaseShape::pptx, OOXMLShapes::sptCRect);
#endif
oElem.m_oMetric = oInfo;
oElem.m_rcBoundsOriginal.left = 0.0;
oElem.m_rcBoundsOriginal.right = (double)oInfo.m_lUnitsHor;
oElem.m_rcBoundsOriginal.top = 0.0;
oElem.m_rcBoundsOriginal.bottom = (double)oInfo.m_lUnitsVer;
double dScaleX = (double)oInfo.m_lMillimetresHor / oInfo.m_lUnitsHor;
double dScaleY = (double)oInfo.m_lMillimetresVer / oInfo.m_lUnitsVer;
oElem.m_bIsBackground = true;
oElem.m_bIsChangeable = false;
oElem.NormalizeCoords(dScaleX, dScaleY);
oElem.m_oShape.m_oBrush = m_oBackground;
oWriter.WriteString(std::wstring(L"<Background>"));
oElem.SetupProperties(NULL, this, NULL);
oWriter.WriteString(oElem.ToXmlEditor());
oWriter.WriteString(std::wstring(L"</Background>"));
// -----------
// elements
oWriter.WriteString(std::wstring(L"<Elements>"));
size_t nCountElems = m_arElements.size();
for (size_t i = 0; i < nCountElems; ++i)
{
m_arElements[i]->m_bIsBackground = false;
m_arElements[i]->m_bIsChangeable = false;
oWriter.WriteString(m_arElements[i]->ToXmlEditor());
}
oWriter.WriteString(std::wstring(L"</Elements>"));
// ----------------
// layouts
oWriter.WriteString(std::wstring(L"<Layouts>"));
size_t nCountLayouts = m_arLayouts.size();
for (size_t i = 0; i < nCountLayouts; ++i)
{
oWriter.WriteString(m_arLayouts[i].ToXmlEditor(this, oInfo));
}
oWriter.WriteString(std::wstring(L"</Layouts>"));
oWriter.WriteString(std::wstring(L"</Theme>"));
return oWriter.GetData();
}
void NSPresentationEditor::CTheme::ReadFromXml(XmlUtils::CXmlNode& oNode)
{
#ifdef _PRESENTATION_WRITER_
//colors
m_sThemeName = oNode.GetAttribute(L"name", L"default");
m_arColorScheme.clear();
XmlUtils::CXmlNode oNodeColors;
if (oNode.GetNode(_T("Colors"), oNodeColors))
{
CString strNodeColor = oNodeColors.GetText();
CStylesCSS oStyles;
oStyles.LoadStyles(strNodeColor);
size_t nCount = oStyles.m_arStyles.size();
LONG lColor = 0;
for (size_t i = 0; i < nCount; i += 3)
{
CColor elem;
m_arColorScheme.push_back(elem);
oStyles.m_arStyles[i].LoadColor(m_arColorScheme[lColor]);
++lColor;
}
}
XmlUtils::CXmlNode oNodeFonts;
if (oNode.GetNode(_T("Fonts"), oNodeFonts))
{
CString strNodeFonts = oNodeFonts.GetText();
CStylesCSS oStyles;
oStyles.LoadStyles(strNodeFonts);
size_t nCount = oStyles.m_arStyles.size();
for (size_t i = 0; i < nCount; ++i)
{
CFont elem;
m_arFonts.push_back(elem);
oStyles.m_arStyles[i].LoadFont(m_arFonts[i]);
}
}
XmlUtils::CXmlNode oNodeTextStyles;
if (oNode.GetNode(_T("TextStyles"), oNodeTextStyles))
{
XmlUtils::CXmlNodes oStyles;
if (oNodeTextStyles.GetNodes(_T("Style"), oStyles))
{
int nCount = oStyles.GetCount();
if (nCount >= g_ThemeTextStylesCount)
{
for (int i = 0; i < g_ThemeTextStylesCount; ++i)
{
XmlUtils::CXmlNode oNodeStyle;
oStyles.GetAt(i, oNodeStyle);
int nNumberStyle = oNodeStyle.ReadAttributeInt(_T("type"));
CString strNodeStyle = oNodeStyle.GetText();
CStylesCSS oCSS;
oCSS.LoadStyles(strNodeStyle);
if (20 != oCSS.m_arStyles.size())
continue;
for (int nIndexStyle = 0; nIndexStyle < 10; ++nIndexStyle)
{
m_pStyles[i].m_pLevels[nIndexStyle] = new CTextStyleLevel();
oCSS.m_arStyles[2 * nIndexStyle].LoadStylePF(m_pStyles[i].m_pLevels[nIndexStyle]->m_oPFRun, m_oInfo);
oCSS.m_arStyles[2 * nIndexStyle + 1].LoadStyleCF(m_pStyles[i].m_pLevels[nIndexStyle]->m_oCFRun, m_oInfo);
}
}
}
}
}
// background
m_bIsBackground = false;
XmlUtils::CXmlNode oNodeBackround;
if (oNode.GetNode(_T("Background"), oNodeBackround))
{
m_bIsBackground = true;
XmlUtils::CXmlNode oNodeMem;
if (oNodeBackround.GetNode(_T("shape"), oNodeMem))
{
CShapeElement oElem;
oElem.m_oMetric = m_oInfo;
oElem.LoadFromXmlNode2(oNodeMem);
m_oBackground = oElem.m_oShape.m_oBrush;
}
}
// Elements
XmlUtils::CXmlNode oNodeElements;
if (oNode.GetNode(_T("Elements"), oNodeElements))
{
XmlUtils::CXmlNodes oNodes;
if (oNodeElements.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNodeMem;
oNodes.GetAt(i, oNodeMem);
CShapeElement* pShapeEl = new CShapeElement();
pShapeEl->m_oMetric = m_oInfo;
pShapeEl->LoadFromXmlNode2(oNodeMem);
pShapeEl->m_pTheme = this;
m_arElements.push_back(pShapeEl);
}
}
}
XmlUtils::CXmlNode oNodeLayouts;
if (oNode.GetNode(_T("Layouts"), oNodeLayouts))
{
XmlUtils::CXmlNodes oLayouts;
if (oNodeLayouts.GetNodes(_T("Layout"), oLayouts))
{
int nCountLayouts = oLayouts.GetCount();
for (int nL = 0; nL < nCountLayouts; ++nL)
{
XmlUtils::CXmlNode oNodeL;
oLayouts.GetAt(nL, oNodeL);
CLayout elem;
m_arLayouts.push_back(elem);
m_arLayouts.back().SetMetricInfo(m_oInfo);
m_arLayouts.back().ReadFromXml(oNodeL);
}
}
}
#endif
}
}
......@@ -7,9 +7,10 @@ namespace NSPresentationEditor
{
const long g_ThemeTextStylesCount = 4;
class CTheme : public IBase
class CTheme
{
public:
std::map<std::wstring, LONG> m_mapGeomToLayout;
std::vector<CColor> m_arColorScheme;
std::vector<CFont> m_arFonts;
std::vector<CBrush> m_arBrushes;
......@@ -30,11 +31,14 @@ namespace NSPresentationEditor
std::vector<std::vector<CColor>>m_arExtraColorScheme;
long m_lOriginalWidth;
long m_lOriginalHeight;
//------------------------------------------------------------------------------------
CTheme() : m_arColorScheme(), m_arFonts(), m_arBrushes(),
m_arPens(), m_arEffects(), m_arLayouts()
{
m_sThemeName = L"Default";
m_lOriginalWidth = m_lOriginalHeight = 0;
}
CTheme(const CTheme& oSrc)
......@@ -52,6 +56,15 @@ namespace NSPresentationEditor
m_sThemeName = oSrc.m_sThemeName;
m_lOriginalWidth = oSrc.m_lOriginalWidth ;
m_lOriginalHeight = oSrc.m_lOriginalHeight;
for (int i = 0; i < oSrc.m_arExtraColorScheme.size(); ++i)
{
m_arExtraColorScheme.push_back(oSrc.m_arExtraColorScheme[i]);
}
for (int i = 0; i < g_ThemeTextStylesCount; ++i)
m_pStyles[i] = oSrc.m_pStyles[i];
......@@ -108,6 +121,10 @@ namespace NSPresentationEditor
}
m_arElements.clear();
m_lOriginalWidth = m_lOriginalHeight = 0;
m_sThemeName = L"Default";
}
~CTheme()
......@@ -115,12 +132,6 @@ namespace NSPresentationEditor
}
public:
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode);
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
{
}
CString ToXmlEditor(const CMetricInfo& oInfo);
NSPresentationEditor::CColor GetColor(const LONG& lIndexScheme)
{
......
......@@ -106,6 +106,26 @@ namespace NSPresentationEditor
WriteString(bsString.GetBSTR(), nLen);
}
#endif // #if defined(_WIN32) || defined(_WIN64)
AVSINLINE void WriteStringXML(const std::wstring & wString)
{
std::wstring buffer;
buffer.reserve(wString.size());
for(size_t pos = 0; pos != wString.size(); ++pos)
{
switch(wString[pos])
{
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
default: buffer.append(&wString[pos], 1); break;
}
}
WriteString(buffer);
}
AVSINLINE void WriteString(const std::wstring & wString)
{
size_t nLen = wString.length();
......
......@@ -158,6 +158,7 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
{
CString strContentTypes = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\
<Default Extension=\"bmp\" ContentType=\"image/bmp\" />\
<Default Extension=\"png\" ContentType=\"image/png\" />\
<Default Extension=\"jpeg\" ContentType=\"image/jpeg\" />\
<Default Extension=\"wmf\" ContentType=\"image/x-wmf\" />\
......@@ -165,6 +166,7 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xml\" ContentType=\"application/xml\" />\
<Default Extension=\"gif\" ContentType=\"image/gif\"/>\
<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
<Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>");
strContentTypes += _T("<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\" />\
......@@ -478,19 +480,19 @@ void NSPresentationEditor::CPPTXWriter::WriteThemes()
NSPresentationEditor::CStringWriter oStringWriter;
oStringWriter.WriteString(std::wstring(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\""));
oStringWriter.WriteString(pTheme->m_sThemeName);
oStringWriter.WriteStringXML(pTheme->m_sThemeName);
oStringWriter.WriteString(std::wstring(L"\"><a:themeElements>"));
WriteColorScheme(oStringWriter, L"Default", pTheme->m_arColorScheme);
oStringWriter.WriteString(std::wstring(L"<a:fontScheme name=\"default\"><a:majorFont><a:latin typeface=\""));
oStringWriter.WriteString(pTheme->m_arFonts[0].Name);
oStringWriter.WriteStringXML(pTheme->m_arFonts[0].Name);
oStringWriter.WriteString(std::wstring(L"\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/></a:majorFont>"));
oStringWriter.WriteString(std::wstring(L"<a:minorFont><a:latin typeface=\""));
if (pTheme->m_arFonts.size() >1 ) oStringWriter.WriteString(pTheme->m_arFonts[1].Name);
else oStringWriter.WriteString(pTheme->m_arFonts[0].Name);
else oStringWriter.WriteStringXML(pTheme->m_arFonts[0].Name);
oStringWriter.WriteString(std::wstring(L"\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/></a:minorFont>"));
oStringWriter.WriteString(std::wstring(L"</a:fontScheme>"));
......@@ -620,14 +622,23 @@ void NSPresentationEditor::CPPTXWriter::WriteThemes()
void NSPresentationEditor::CPPTXWriter::WriteColorScheme(CStringWriter& oStringWriter, const std::wstring & name, const std::vector<CColor> & colors, bool extra)
{
if (colors.size() < 1) return;
if (colors.size() < 1)
{
oStringWriter.WriteString(std::wstring(L"<a:clrScheme name=\"Default\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/>\
</a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"1F497D\"/></a:dk2><a:lt2>\
<a:srgbClr val=\"EEECE1\"/></a:lt2><a:accent1><a:srgbClr val=\"4F81BD\"/></a:accent1><a:accent2><a:srgbClr val=\"C0504D\"/>\
</a:accent2><a:accent3><a:srgbClr val=\"9BBB59\"/></a:accent3><a:accent4><a:srgbClr val=\"8064A2\"/></a:accent4><a:accent5>\
<a:srgbClr val=\"4BACC6\"/></a:accent5><a:accent6><a:srgbClr val=\"F79646\"/></a:accent6><a:hlink><a:srgbClr val=\"0000FF\"/>\
</a:hlink><a:folHlink><a:srgbClr val=\"800080\"/></a:folHlink></a:clrScheme>"));
return;
}
if (extra)
oStringWriter.WriteString(std::wstring(L"<a:extraClrScheme>"));
oStringWriter.WriteString(std::wstring(L"<a:clrScheme name=\""));
oStringWriter.WriteString(name);
oStringWriter.WriteStringXML(name);
oStringWriter.WriteString(std::wstring(L"\">"));
CString strVal;
......@@ -679,57 +690,36 @@ accent2=\"accent2\" accent3=\"accent3\" accent4=\"accent4\" accent5=\"accent5\"
void NSPresentationEditor::CPPTXWriter::WriteBackground(CStringWriter& oWriter, CRelsGenerator& oRels, CBrush& oBackground)
{
oWriter.WriteString(std::wstring(L"<p:bg><p:bgPr>"));
if (oBackground.Type == c_BrushTypeTexture)
{
CString strRid = oRels.WriteImage(oBackground.TexturePath);
oWriter.WriteString(std::wstring(L"<a:blipFill dpi=\"0\" rotWithShape=\"0\"><a:blip r:embed=\""));
oWriter.WriteString(strRid + _T("\">"));
if (oBackground.TextureAlpha != 255)
{
CString strAlpha;
strAlpha.Format(L"%d", (int)(oBackground.TextureAlpha * 100000. / 255));
oWriter.WriteString(std::wstring(L"<a:alphaModFix amt=\"") + string2std_string(strAlpha) + L"\"/>");
}
oWriter.WriteString(std::wstring(L"</a:blip><a:srcRect/>"));
if (oBackground.TextureMode == 1)
oWriter.WriteString(std::wstring(L"<a:tile algn=\"tl\"/>"));
else
oWriter.WriteString(std::wstring(L"<a:stretch><a:fillRect/></a:stretch>"));
oWriter.WriteString(std::wstring(L"</a:blipFill><a:effectLst/>"));
oWriter.WriteString(std::wstring(L"</p:bgPr></p:bg>"));
return;
}
if (oBackground.Color1.m_lSchemeIndex == -1)
//if (oBackground.Type == c_BrushTypeTexture)
//{
// CString strRid = oRels.WriteImage(oBackground.TexturePath);
// oWriter.WriteString(std::wstring(L"<a:blipFill dpi=\"0\" rotWithShape=\"0\"><a:blip r:embed=\""));
// oWriter.WriteString(strRid + _T("\">"));
// if (oBackground.TextureAlpha != 255)
// {
// CString strAlpha;
// strAlpha.Format(L"%d", (int)(oBackground.TextureAlpha * 100000. / 255));
// oWriter.WriteString(std::wstring(L"<a:alphaModFix amt=\"") + string2std_string(strAlpha) + L"\"/>");
// }
// oWriter.WriteString(std::wstring(L"</a:blip><a:srcRect/>"));
// if (oBackground.TextureMode == 1)
// oWriter.WriteString(std::wstring(L"<a:tile algn=\"tl\"/>"));
// else
// oWriter.WriteString(std::wstring(L"<a:stretch><a:fillRect/></a:stretch>"));
//
// oWriter.WriteString(std::wstring(L"</a:blipFill><a:effectLst/>"));
//
// oWriter.WriteString(std::wstring(L"</p:bgPr></p:bg>"));
// return;
//}
//else
{
CString strColor;
strColor.Format(L"%06x", oBackground.Color1.GetLONG_RGB());
oWriter.WriteString(std::wstring(L"<a:solidFill><a:srgbClr val=\"") + string2std_string(strColor) + _T("\">"));
if (oBackground.Alpha1 != 255)
{
CString strAlpha;
strAlpha.Format(L"%d", (int)(oBackground.Alpha1 * 100000. / 255));
oWriter.WriteString(std::wstring(L"<a:alpha val=\"") + string2std_string(strAlpha) + _T("\"/>"));
}
oWriter.WriteString(std::wstring(L"</a:srgbClr></a:solidFill>"));
}
else
{
oWriter.WriteString(std::wstring(L"<a:solidFill><a:schemeClr val=\""));
oWriter.WriteString(CStylesWriter::GetColorInScheme(oBackground.Color1.m_lSchemeIndex) + _T("\"/>"));
if (oBackground.Alpha1 != 255)
{
CString strAlpha;
strAlpha.Format(L"%d", (int)(oBackground.Alpha1 * 100000 / 255));
oWriter.WriteString(std::wstring(L"<a:alpha val=\"") + string2std_string(strAlpha) + _T("\"/>"));
}
oWriter.WriteString(std::wstring(L"</a:solidFill>"));
oWriter.WriteString(m_pShapeWriter->ConvertBrush(oBackground));
}
oWriter.WriteString(std::wstring(L"</p:bgPr></p:bg>"));
}
......@@ -751,7 +741,7 @@ void NSPresentationEditor::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRe
pShapeElem->m_oMetric = m_pDocument->m_oInfo;
pShapeElem->NormalizeCoordsByMetric();
pShapeElem->m_oShape.m_oText.RecalcParagraphs(pShapeElem->m_pTheme);
pShapeElem->m_oShape.m_oText.RecalcParagraphsPPT(pShapeElem->m_pTheme);
pShapeElem->m_oShape.m_oText.NormalizeCoordsByMetric(m_pDocument->m_oInfo);
m_pShapeWriter->SetShape(pShapeElem);
......@@ -796,15 +786,12 @@ void NSPresentationEditor::CPPTXWriter::WriteLayout(CLayout& oLayout, int nIndex
CRelsGenerator oRels(&m_oManager);
oRels.StartLayout(nIndexTheme);
CString str1 = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
str1 += _T("<p:sldLayout xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"");
str1 += _T(" type=\"") + oLayout.m_strLayoutType + _T("\"");
str1 += _T(" showMasterSp=\"");
str1 += (oLayout.m_bShowMasterShapes ? _T("0") : _T("1"));
str1 += + _T("\" preserve=\"1\"><p:cSld>");
oWriter.WriteString(std::wstring(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
oWriter.WriteString(str1);
oWriter.WriteString(std::wstring(L"<p:sldLayout xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\""));
oWriter.WriteString(std::wstring(L" type=\"") + oLayout.m_strLayoutType + _T("\""));
oWriter.WriteString(std::wstring(L" showMasterSp=\"") + (oLayout.m_bShowMasterShapes ? _T("1") : _T("0")));
oWriter.WriteString(std::wstring(L"\" preserve=\"1\"><p:cSld>"));
if (oLayout.m_bIsBackground)
{
......
......@@ -10,11 +10,12 @@ namespace NSPresentationEditor
{
private:
std::map<std::wstring, std::wstring> m_mapImages;
LONG m_lIndexNextImage;
std::wstring m_strDstMedia;
public:
CImageManager() : m_mapImages(), m_lIndexNextImage(0)
CImageManager() : m_lIndexNextImage(0)
{
}
~CImageManager()
......@@ -95,13 +96,14 @@ namespace NSPresentationEditor
class CRelsGenerator
{
private:
NSPresentationEditor::CStringWriter m_oWriter;
int m_lNextRelsID;
std::map<std::wstring, int> m_mapImages;
CImageManager* m_pManager;
NSPresentationEditor::CStringWriter m_oWriter;
int m_lNextRelsID;
std::map<std::wstring, int> m_mapImages;
CImageManager* m_pManager;
std::map<std::wstring, std::wstring> m_mapHyperlinks;
public:
CRelsGenerator(CImageManager* pManager) : m_oWriter(), m_lNextRelsID(1), m_mapImages()
CRelsGenerator(CImageManager* pManager) : m_oWriter(), m_lNextRelsID(1)
{
m_pManager = pManager;
}
......@@ -113,6 +115,7 @@ namespace NSPresentationEditor
m_oWriter.ClearNoAttack();
m_lNextRelsID = 1;
m_mapImages.clear();
m_mapHyperlinks.clear();
}
AVSINLINE void StartMaster(int nIndexTheme, int nStartLayoutIndex, int nCountLayouts)
......@@ -219,7 +222,28 @@ namespace NSPresentationEditor
oFile.WriteStringUTF8(strMem);
oFile.CloseFile();
}
AVSINLINE CString WriteHyperlink(const std::wstring& strHyperlink)
{
std::map<std::wstring, std::wstring>::iterator pPair = m_mapHyperlinks.find(strHyperlink);
if (m_mapHyperlinks.end() != pPair)
{
CString strRid = _T("");
strRid.Format(_T("rId%d"), pPair->second);
return strRid;
}
m_mapHyperlinks[strHyperlink] = m_lNextRelsID;
CString strRid = _T("");
strRid.Format(_T("rId%d"), m_lNextRelsID++);
std::wstring strRels = _T("<Relationship Id=\"") ;
strRels += string2std_string(strRid) + _T("\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"");
strRels += strHyperlink + _T("\"/>");
m_oWriter.WriteString(strRels);
}
AVSINLINE CString WriteImage(const std::wstring& strImagePath)
{
std::wstring strImage = m_pManager->GenerateImage(strImagePath);
......
#include "ShapeWriter.h"
#include "../../ASCOfficeXlsFile2/source/XlsXlsxConverter/ShapeType.h"
const double EMU_MM = 36000;
NSPresentationEditor::CShapeWriter::CShapeWriter()
{
m_pRels = NULL;
m_lNextShapeID = 1000;
m_bIsWriteGeom = true;
m_bIsWriteGeom = true;
m_bWordArt = false;
m_bTextBox = false;
//////////////////////////////////////////////////////////////////////
m_dDpiX = 96.0;
m_dDpiY = 96.0;
......@@ -26,6 +32,621 @@ NSPresentationEditor::CShapeWriter::CShapeWriter()
m_pImageElement = NULL;
m_pShapeElement = NULL;
}
CString NSPresentationEditor::CShapeWriter::ConvertLine()
{
if (m_pShapeElement->m_bLine == false) return _T("");
NSPresentationEditor::CStringWriter line_writer;
CPen* pPen = &m_pShapeElement->m_oShape.m_oPen;
CString strLine = _T("");
strLine.Format(_T("<a:ln w=\"%d\">"), (int)(pPen->Size * 36000));
line_writer.WriteString(strLine);
if (m_bWordArt)
{
line_writer.WriteString(std::wstring(L"<a:noFill/>"));
}
else
{
line_writer.WriteString(std::wstring(L"<a:solidFill>"));
line_writer.WriteString(ConvertColor(pPen->Color, pPen->Alpha));
line_writer.WriteString(std::wstring(L"</a:solidFill>"));
}
line_writer.WriteString(std::wstring(L"<a:round/><a:headEnd/><a:tailEnd/></a:ln>"));
return line_writer.GetData();
}
CString NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush)
{
NSPresentationEditor::CStringWriter brush_writer;
if (brush.Type == c_BrushTypeTexture)
{
CString strRid = m_pRels->WriteImage(brush.TexturePath);
brush_writer.WriteString(std::wstring(L"<a:blipFill dpi=\"0\" rotWithShape=\"1\"><a:blip r:embed=\"") + string2std_string(strRid) + _T("\"/><a:srcRect/>"));
if ( brush.TextureMode == c_BrushTextureModeTile)
brush_writer.WriteString(std::wstring(L"<a:tile/>"));
else
brush_writer.WriteString(std::wstring(L"<a:stretch><a:fillRect/></a:stretch>"));
brush_writer.WriteString(std::wstring(L"</a:blipFill>"));
}
else if ( brush.Type == c_BrushTypeNoFill)
{
brush_writer.WriteString(std::wstring(L"<a:noFill/>"));
}
else if ( brush.Type == c_BrushTypePathGradient1 ||
brush.Type == c_BrushTypePathGradient2 ||
brush.Type == c_BrushTypeCenter ||
brush.Type == c_BrushTypeHorizontal ||
brush.Type == c_BrushTypeVertical )
{
brush_writer.WriteString(std::wstring(L"<a:gradFill>"));
brush_writer.WriteString(std::wstring(L"<a:gsLst><a:gs pos=\"0\">"));
brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1));
brush_writer.WriteString(std::wstring(L"</a:gs><a:gs pos=\"100000\">"));
brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2));
brush_writer.WriteString(std::wstring(L"</a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"1\"/>"));
brush_writer.WriteString(std::wstring(L"</a:gradFill>"));
}
else if(brush.Type == c_BrushTypePattern)
{// - -
brush_writer.WriteString(std::wstring(L"<a:pattFill prst=\"pct80\">"));
brush_writer.WriteString(std::wstring(L"<a:fgClr>"));
brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1));
brush_writer.WriteString(std::wstring(L"</a:fgClr>"));
brush_writer.WriteString(std::wstring(L"<a:bgClr>"));
brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2));
brush_writer.WriteString(std::wstring(L"</a:bgClr>"));
brush_writer.WriteString(std::wstring(L"</a:pattFill>"));
}
else
{
brush_writer.WriteString(std::wstring(L"<a:solidFill>"));
brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1));
brush_writer.WriteString(std::wstring(L"</a:solidFill>"));
}
return brush_writer.GetData();
}
CString NSPresentationEditor::CShapeWriter::ConvertShadow()
{
if (m_pShapeElement->m_oShape.m_oShadow.Visible == false) return _T("");
double dist = sqrt(m_pShapeElement->m_oShape.m_oShadow.DistanceY * m_pShapeElement->m_oShape.m_oShadow.DistanceY +
m_pShapeElement->m_oShape.m_oShadow.DistanceX * m_pShapeElement->m_oShape.m_oShadow.DistanceX);
double dir = 180 * atan(m_pShapeElement->m_oShape.m_oShadow.DistanceX / m_pShapeElement->m_oShape.m_oShadow.DistanceY) / 3.1415926;
if (dir < 0) dir += 360;
CString strDir = _T("");
strDir.Format(_T(" dir=\"%d\""), (int)(dir * 60000));
CString strDist = _T("");
strDist.Format(_T(" dist=\"%d\""), (int)(dist * 36000));
NSPresentationEditor::CStringWriter shadow_writer;
shadow_writer.WriteString(std::wstring(L"<a:effectLst>"));
shadow_writer.WriteString(std::wstring(L"<a:outerShdw"));
shadow_writer.WriteString(std::wstring(L" rotWithShape=\"0\" algn=\"ctr\""));
shadow_writer.WriteString(strDir);
shadow_writer.WriteString(strDist);
shadow_writer.WriteString(std::wstring(L">"));
shadow_writer.WriteString(ConvertColor(m_pShapeElement->m_oShape.m_oShadow.Color,m_pShapeElement->m_oShape.m_oShadow.Alpha));
shadow_writer.WriteString(std::wstring(L"</a:outerShdw>"));
shadow_writer.WriteString(std::wstring(L"</a:effectLst>"));
return shadow_writer.GetData();
}
CString NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, long alpha)
{
NSPresentationEditor::CStringWriter color_writer;
if (color.m_lSchemeIndex == -1)
{
if (255 == alpha)
{
CString str = _T("");
str.Format(_T("<a:srgbClr val=\"%06X\"/>"), color.GetLONG_RGB());
color_writer.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:srgbClr val=\"%06X\"><a:alpha val=\"%d\"/></a:srgbClr>"), color.GetLONG_RGB(), (int)(alpha * 100000 / 255));
color_writer.WriteString(str);
}
}
else
{
if (255 == alpha)
{
CString str = _T("<a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(color.m_lSchemeIndex) + _T("\"/>");
color_writer.WriteString(str);
}
else
{
CString strAlpha; strAlpha.Format(_T("%d"), (int)(alpha * 100000 / 255));
CString str = _T("<a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(color.m_lSchemeIndex) + _T("\"><a:alpha val=\"") + strAlpha + _T("\"/></a:schemeClr>");
color_writer.WriteString(str);
}
}
return color_writer.GetData();
}
void NSPresentationEditor::CShapeWriter::WriteImageInfo()
{
m_oWriter.WriteString(std::wstring(L"<p:nvPicPr>"));
CString strShapeID;
strShapeID.Format(_T("%d"), m_lNextShapeID);
m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") +string2std_string(strShapeID) + L"\"" );
if (m_pImageElement->m_sName.empty()) m_pImageElement->m_sName = std::wstring(L"Image ") + string2std_string(strShapeID);
m_oWriter.WriteString(std::wstring(L" name=\""));
m_oWriter.WriteStringXML(m_pImageElement->m_sName);
m_oWriter.WriteString(std::wstring(L"\""));
if (!m_pImageElement->m_sDescription.empty())
{
m_oWriter.WriteString(std::wstring(L" descr=\""));
m_oWriter.WriteStringXML(m_pImageElement->m_sDescription);
m_oWriter.WriteString(std::wstring(L"\""));
}
m_oWriter.WriteString(std::wstring(L"></p:cNvPr><p:cNvPicPr><a:spLocks noGrp=\"1\" noChangeAspect=\"1\"/></p:cNvPicPr>"));
++m_lNextShapeID;
if (-1 != m_pImageElement->m_lPlaceholderType)
{
if (15 == m_pImageElement->m_lPlaceholderType)
m_pImageElement->m_lPlaceholderID = -1;
if (0 == m_pImageElement->m_lPlaceholderType)
m_pImageElement->m_lPlaceholderID = 1;
if (-1 == m_pImageElement->m_lPlaceholderID)
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) +_T("\"/></p:nvPr>"));
}
else
{
CString strIdx; strIdx.Format(_T("%d"), m_pImageElement->m_lPlaceholderID);
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + _T("\" idx=\"") + string2std_string(strIdx) + _T("\"/></p:nvPr>"));
}
}
else
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr/>"));
}
CString str2 = _T("</p:nvPicPr>");
m_oWriter.WriteString(str2);
}
void NSPresentationEditor::CShapeWriter::WriteShapeInfo()
{
m_oWriter.WriteString(std::wstring(L"<p:nvSpPr>"));
CString strShapeID = _T("");
if (m_pShapeElement->m_lID < 0)
m_pShapeElement->m_lID = m_lNextShapeID;
strShapeID.Format(L"%d", m_pShapeElement->m_lID);
m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") + string2std_string(strShapeID) + L"\"");
if (m_pShapeElement->m_sName.empty()) m_pShapeElement->m_sName = std::wstring(L"Shape ") + string2std_string(strShapeID);
m_oWriter.WriteString(std::wstring(L" name=\""));
m_oWriter.WriteStringXML(m_pShapeElement->m_sName);
m_oWriter.WriteString(std::wstring(L"\""));
if (!m_pShapeElement->m_sDescription.empty())
{
m_oWriter.WriteString(std::wstring(L" descr=\""));
m_oWriter.WriteStringXML(m_pShapeElement->m_sDescription);
m_oWriter.WriteString(std::wstring(L"\""));
}
m_oWriter.WriteString(std::wstring(L">"));
if (!m_pShapeElement->m_sHyperlink.empty())
{
std::wstring rId = (m_pRels->WriteHyperlink(m_pShapeElement->m_sHyperlink)).GetBuffer();
m_oWriter.WriteString(std::wstring(L"<a:hlinkClick"));
m_oWriter.WriteString(std::wstring(L" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""));
m_oWriter.WriteString(std::wstring(L" r:id=\"" + rId ));
m_oWriter.WriteString(std::wstring(L"\"></a:hlinkClick>"));
}
m_oWriter.WriteString(std::wstring(L"</p:cNvPr>"));
m_oWriter.WriteString(std::wstring(L"<p:cNvSpPr"));
if (m_bTextBox)
m_oWriter.WriteString(std::wstring(L" txBox=\"1\""));
m_oWriter.WriteString(std::wstring(L"><a:spLocks noGrp=\"1\" noChangeArrowheads=\"1\"/>"));
m_oWriter.WriteString(std::wstring(L"</p:cNvSpPr>"));
++m_lNextShapeID;
if (-1 != m_pShapeElement->m_lPlaceholderType)
{
if (15 == m_pShapeElement->m_lPlaceholderType)
m_pShapeElement->m_lPlaceholderID = -1;
if (0 == m_pShapeElement->m_lPlaceholderType)
m_pShapeElement->m_lPlaceholderID = 1;
if (-1 == m_pShapeElement->m_lPlaceholderID)
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pShapeElement->m_lPlaceholderType) + _T("\""));
if (5 == m_pShapeElement->m_lPlaceholderType)
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
if (12 == m_pShapeElement->m_lPlaceholderType)
m_oWriter.WriteString(std::wstring(L" size=\"quarter\""));
//else
// m_oWriter.WriteString(std::wstring(L" size=\"half\""));
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
}
else
{
CString strIdx; strIdx.Format(_T("%d"), m_pShapeElement->m_lPlaceholderID);
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pShapeElement->m_lPlaceholderType) + _T("\" idx=\"") + string2std_string(strIdx) + _T("\""));
if (5 == m_pShapeElement->m_lPlaceholderType)
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
if (12 == m_pShapeElement->m_lPlaceholderType)
m_oWriter.WriteString(std::wstring(L" size=\"quarter\""));
//else
// m_oWriter.WriteString(std::wstring(L" size=\"half\""));
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
}
}
else
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr/>"));
}
CString str2 = _T("</p:nvSpPr>");
m_oWriter.WriteString(str2);
}
void NSPresentationEditor::CShapeWriter::WriteTextInfo()
{
size_t nCount = m_pShapeElement->m_oShape.m_oText.m_arParagraphs.size();
if (/*0 == nCount || */(0x00 == (m_pShapeElement->m_oShape.m_lDrawType & c_ShapeDrawType_Text)))
return;
m_oWriter.WriteString(std::wstring(L"<p:txBody>"));
m_oWriter.WriteString(std::wstring(L"<a:bodyPr" ));
// int __l = (int)((m_oBounds.left + m_oTextRect.left) * EMU_MM);
//int __t = (int)((m_oBounds.top + m_oTextRect.top) * EMU_MM);
//int __r = (int)((m_oBounds.right - m_oTextRect.right)* EMU_MM);
//int __b = (int)((m_oBounds.bottom - m_oTextRect.bottom)* EMU_MM);
//if (true)
//{
// CString str;
// str.Format(L" lIns=\"%d\" tIns=\"%d\" rIns=\"%d\" bIns=\"%d\"",__l, __t, __r, __b);
// m_oWriter.WriteString(str);
//}
//else
m_oWriter.WriteString(std::wstring(L" lIns=\"0\" tIns=\"0\" rIns=\"0\" bIns=\"0\""));
if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 0 )
m_oWriter.WriteString(" anchor=\"t\"");
else if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 2 )
m_oWriter.WriteString(" anchor=\"b\"");
else if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 1 )
m_oWriter.WriteString(" anchor=\"ctr\"");
m_oWriter.WriteString(std::wstring(L">"));
if (m_bWordArt)
{
std::wstring prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)m_pShapeElement->m_lShapeType);
m_oWriter.WriteString(std::wstring(L"<a:prstTxWarp"));
m_oWriter.WriteString(std::wstring(L" prst=\"") + prstTxWarp + _T("\">"));
m_oWriter.WriteString(std::wstring(L"<a:avLst/>"));//
m_oWriter.WriteString(std::wstring(L"</a:prstTxWarp>"));
}
m_oWriter.WriteString(std::wstring(L"</a:bodyPr>"));
if (0 == nCount)
{
m_oWriter.WriteString(std::wstring(L"<a:lstStyle/><a:p><a:endParaRPr dirty=\"0\"/></a:p></p:txBody>"));
return;
}
m_oWriter.WriteString(std::wstring(L"<a:lstStyle>"));
CStylesWriter::ConvertStyles(m_pShapeElement->m_oShape.m_oText.m_oStyles, m_oMetricInfo, m_oWriter);
m_oWriter.WriteString(std::wstring(L"</a:lstStyle>"));
for (size_t nIndexPar = 0; nIndexPar < nCount; ++nIndexPar)
{
NSPresentationEditor::CParagraph* pParagraph = &m_pShapeElement->m_oShape.m_oText.m_arParagraphs[nIndexPar];
CString _str1 = _T("");
_str1.Format(_T("<a:p><a:pPr lvl=\"%d\""), pParagraph->m_lTextLevel);
m_oWriter.WriteString(_str1);
NSPresentationEditor::CTextPFRun* pPF = &pParagraph->m_oPFRun;
if (pPF->fontAlign.is_init())
{
CString strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get());
m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + string2std_string(strProp) + _T("\""));
}
if (pPF->leftMargin.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" marL=\"%d\""), pPF->leftMargin.get());
m_oWriter.WriteString(strProp);
if (pPF->indent.is_init() == false)
pPF->indent = (LONG)0;
}
if (pPF->indent.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" indent=\"%d\""), pPF->indent.get());
m_oWriter.WriteString(strProp);
}
if (pPF->textAlignment.is_init())
{
CString strProp = CStylesWriter::GetTextAlign(pPF->textAlignment.get());
m_oWriter.WriteString(std::wstring(L" algn=\"") + string2std_string(strProp) + _T("\""));
}
if (pPF->defaultTabSize.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" defTabSz=\"%d\""), pPF->defaultTabSize.get());
m_oWriter.WriteString(strProp);
}
CString _str2 = _T(">");
m_oWriter.WriteString(_str2);
double dKoef1 = 3.52777778;
if (pPF->lineSpacing.is_init())
{
LONG val = pPF->lineSpacing.get();
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:lnSpc><a:spcPts val=\"%d\"/></a:lnSpc>"), (int)(val / dKoef1 * 100));
m_oWriter.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:lnSpc><a:spcPct val=\"%d\"/></a:lnSpc>"), -val * 1000);
m_oWriter.WriteString(str);
}
}
if (pPF->spaceAfter.is_init())
{
LONG val = pPF->spaceAfter.get();
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:spcAft><a:spcPts val=\"%d\"/></a:spcAft>"), (int)(val / dKoef1 * 100));
m_oWriter.WriteString(str);
}
else if (val < 0)
{
CString str = _T("");
str.Format(_T("<a:spcAft><a:spcPct val=\"%d\"/></a:spcAft>"), -val * 1000);
m_oWriter.WriteString(str);
}
}
if (pPF->spaceBefore.is_init())
{
LONG val = pPF->spaceBefore.get();
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:spcBef><a:spcPts val=\"%d\"/></a:spcBef>"), (int)(val / dKoef1 * 100));
m_oWriter.WriteString(str);
}
else if (val < 0)
{
CString str = _T("");
str.Format(_T("<a:spcBef><a:spcPct val=\"%d\"/></a:spcBef>"), -val * 1000);
m_oWriter.WriteString(str);
}
}
if (pPF->hasBullet.is_init())
{
if (pPF->hasBullet.get())
{
wchar_t bu = 0x2022;
m_oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
if (pPF->bulletChar.is_init())
{
bu = pPF->bulletChar.get();
}
m_oWriter.WriteString(std::wstring(&bu, 1));
m_oWriter.WriteString(std::wstring(L"\"/>"));
}
else
{
m_oWriter.WriteString(std::wstring(L"<a:buNone/>"));
}
}
m_oWriter.WriteString(std::wstring(L"</a:pPr>"));
std::wstring typeRun = L"a:r";
//if (m_pShapeElement->m_lPlaceholderType == 12)
//{
// m_oWriter.WriteString(std::wstring(L"<a:fld id=\"{D038279B-FC19-497E-A7D1-5ADD9CAF016F}\" type=\"slidenum\">"));
// m_oWriter.WriteString(std::wstring(L"<a:rPr/><a:t>#</a:t></a:fld>"));
//}
//else
size_t nCountSpans = pParagraph->m_arSpans.size();
for (size_t nSpan = 0; nSpan < nCountSpans; ++nSpan)
{
if (TRUE)
{
if ((nSpan == (nCountSpans - 1)) && (_T("\n") == pParagraph->m_arSpans[nSpan].m_strText))
{
NSPresentationEditor::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun;
if (pCF->Size.is_init())
{
CString strProp = _T("");
strProp.Format(_T("<a:endParaRPr lang=\"en-US\" sz=\"%d\"/>"), (int)(100 * pCF->Size.get()));
m_oWriter.WriteString(strProp);
}
else
{
m_oWriter.WriteString(std::wstring(L"<a:endParaRPr lang=\"en-US\"/>"));
}
continue;
}
}
if (pParagraph->m_arSpans[nSpan].m_strText.IsEmpty()) continue;
NSPresentationEditor::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun;
bool bIsBr = false;
if (pParagraph->m_arSpans[nSpan].m_strText.GetLength() >0)
{
if(_T("\n") == pParagraph->m_arSpans[nSpan].m_strText) bIsBr=true;
}
if (bIsBr)
{
CString strRun1 = _T("<a:br><a:rPr");
m_oWriter.WriteString(strRun1);
}
else
{
if (m_pShapeElement->m_lPlaceholderType == 12)//todooo + date
{
m_oWriter.WriteString(std::wstring(L"<a:fld id=\"{D038279B-FC19-497E-A7D1-5ADD9CAF016F}\" type=\"slidenum\"><a:rPr"));
}
else
{
m_oWriter.WriteString(std::wstring(L"<a:r><a:rPr"));
}
}
if (pCF->Size.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" sz=\"%d\""), (int)(100 * pCF->Size.get()));
m_oWriter.WriteString(strProp);
}
if (pCF->FontBold.is_init())
{
if (pCF->FontBold.get())
m_oWriter.WriteString(std::wstring(L" b=\"1\""));
else
m_oWriter.WriteString(std::wstring(L" b=\"0\""));
}
if (pCF->FontItalic.is_init())
{
if (pCF->FontItalic.get())
m_oWriter.WriteString(std::wstring(L" i=\"1\""));
else
m_oWriter.WriteString(std::wstring(L" i=\"0\""));
}
m_oWriter.WriteString(std::wstring(L">"));
if (m_bWordArt)
{
m_oWriter.WriteString(ConvertBrush(m_pShapeElement->m_oShape.m_oBrush));
}
else
{
if (pCF->Color.is_init())
{
if (pCF->Color->m_lSchemeIndex != -1)
{
CString strProp = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pCF->Color->m_lSchemeIndex) + _T("\"/></a:solidFill>");
m_oWriter.WriteString(strProp);
}
else
{
CString strColor = _T("");
strColor.Format(_T("%06x"), pCF->Color->GetLONG_RGB());
CString strProp = _T("<a:solidFill><a:srgbClr val=\"") + strColor + _T("\"/></a:solidFill>");
m_oWriter.WriteString(strProp);
}
}
}
if (pCF->Typeface.is_init())
{
if (0 == pCF->Typeface.get())
{
CString strProp = _T("<a:latin typeface=\"+mj-lt\"/>");
m_oWriter.WriteString(strProp);
}
else
{
CString strProp = _T("<a:latin typeface=\"+mn-lt\"/>");
m_oWriter.WriteString(strProp);
}
}
else if (pCF->FontProperties.is_init())
{
m_oWriter.WriteString(std::wstring(L"<a:latin typeface=\"") + pCF->FontProperties->strFontName + _T("\"/>"));
}
m_oWriter.WriteString(std::wstring(L"</a:rPr>"));
if (!bIsBr)
{
CString strT1 = _T("<a:t>");
m_oWriter.WriteString(strT1);
CString strT = pParagraph->m_arSpans[nSpan].m_strText;
NSPresentationEditor::CorrectXmlString(strT);
m_oWriter.WriteString(strT);
CString strT2 = _T("</a:t>");
m_oWriter.WriteString(strT2);
if (m_pShapeElement->m_lPlaceholderType == 12)
m_oWriter.WriteString(std::wstring(L"</a:fld>"));
else
m_oWriter.WriteString(std::wstring(L"</a:r>"));
}
else
{
m_oWriter.WriteString(std::wstring(L"</a:br>"));
}
}
CString strEndPar = _T("</a:p>");
m_oWriter.WriteString(strEndPar);
}
CString str5 = _T("</p:txBody>");
m_oWriter.WriteString(str5);
}
CString NSPresentationEditor::CShapeWriter::ConvertShape()
{
......@@ -33,6 +654,32 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
if (m_pShapeElement == NULL) return _T("");
bool bPath = false;
std::wstring prstTxWarp;
std::wstring prstGeom = oox::Spt2ShapeType((oox::MSOSPT)m_pShapeElement->m_lShapeType);
if (prstGeom.empty())
{
prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)m_pShapeElement->m_lShapeType);
if (prstTxWarp.empty() == false)
{
m_bWordArt = true;
m_bTextBox = true;
prstGeom = L"rect";
m_oBrush.Type = c_BrushTypeNoFill;
}
else bPath = true;
}
else
{
if (oox::msosptTextBox == (oox::MSOSPT)m_pShapeElement->m_lShapeType)
m_bTextBox = true;
if (m_pShapeElement->m_oShape.m_pShape->m_arAdjustments.size() > 0)
bPath = true;
}
m_oWriter.WriteString(std::wstring(L"<p:sp>"));
WriteShapeInfo();
......@@ -51,45 +698,58 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
if (m_bIsWriteGeom)
{
CString strPosition = _T("");
if (0 == m_pShapeElement->m_dRotate)
CString str;
m_oWriter.WriteString(std::wstring(L"<a:xfrm"));
if (0 != m_pShapeElement->m_dRotate)
{
str.Format(L" rot=\"%d\"", (int)(m_pShapeElement->m_dRotate * 60000));
m_oWriter.WriteString(str);
}
if (m_pShapeElement->m_bFlipH)
{
m_oWriter.WriteString(std::wstring(L" flipH=\"1\""));
}
if (m_pShapeElement->m_bFlipV)
{
m_oWriter.WriteString(std::wstring(L" flipV=\"1\""));
}
m_oWriter.WriteString(std::wstring(L">"));
if (m_pShapeElement->m_rcBoundsOriginal.left >= 0 && m_pShapeElement->m_rcBoundsOriginal.top >=0 )
{
strPosition.Format(_T("<a:xfrm><a:off x=\"%d\" y=\"%d\"/><a:ext cx=\"%d\" cy=\"%d\"/></a:xfrm>"),
(size_t) m_pShapeElement->m_rcBoundsOriginal.left,
(size_t) m_pShapeElement->m_rcBoundsOriginal.top,
(size_t)(m_pShapeElement->m_rcBoundsOriginal.right - m_pShapeElement->m_rcBoundsOriginal.left),
(size_t)(m_pShapeElement->m_rcBoundsOriginal.bottom - m_pShapeElement->m_rcBoundsOriginal.top));
str.Format(_T("<a:off x=\"%d\" y=\"%d\"/>"), (int)m_pShapeElement->m_rcBoundsOriginal.left, (int)m_pShapeElement->m_rcBoundsOriginal.top);
m_oWriter.WriteString(str);
}
else
if (m_pShapeElement->m_rcBoundsOriginal.right - m_pShapeElement->m_rcBoundsOriginal.left > 0 ||
m_pShapeElement->m_rcBoundsOriginal.bottom - m_pShapeElement->m_rcBoundsOriginal.top >0 )
{
strPosition.Format(_T("<a:xfrm rot=\"%d\" flipH=\"%d\" flipV=\"%d\"><a:off x=\"%d\" y=\"%d\"/><a:ext cx=\"%d\" cy=\"%d\"/></a:xfrm>"),
(int)(m_pShapeElement->m_dRotate * 60000), m_pShapeElement->m_bFlipH ? 1 : 0, m_pShapeElement->m_bFlipV ? 1 : 0,
(int) m_pShapeElement->m_rcBoundsOriginal.left,
(int) m_pShapeElement->m_rcBoundsOriginal.top,
(int)(m_pShapeElement->m_rcBoundsOriginal.right - m_pShapeElement->m_rcBoundsOriginal.left),
(int)(m_pShapeElement->m_rcBoundsOriginal.bottom - m_pShapeElement->m_rcBoundsOriginal.top));
str.Format(_T("<a:ext cx=\"%d\" cy=\"%d\"/>"), (int)(m_pShapeElement->m_rcBoundsOriginal.right - m_pShapeElement->m_rcBoundsOriginal.left),
(int)(m_pShapeElement->m_rcBoundsOriginal.bottom - m_pShapeElement->m_rcBoundsOriginal.top));
m_oWriter.WriteString(str);
}
m_oWriter.WriteString(strPosition);
m_oWriter.WriteString(std::wstring(L"</a:xfrm>"));
}
if (m_pShapeElement->m_oShape.m_lDrawType & c_ShapeDrawType_Graphic)
{
m_pShapeElement->m_oShape.ToRenderer(dynamic_cast<IRenderer*>(this), oInfo, m_oMetricInfo, 0.0, 1.0);
}
if (m_oWriterVML.GetCurSize() >= 10)
if (bPath && m_oWriterVML.GetCurSize() >= 10)
{
if (_T("") == m_pShapeElement->m_oShape.m_strPPTXShape)
if (m_pShapeElement->m_oShape.m_strPPTXShape.IsEmpty())
{
m_oWriter.WriteString(std::wstring(L"<a:custGeom>"));
double dW = (std::max)(m_oBounds.GetWidth(), 0.1);
double dH = (std::max)(m_oBounds.GetHeight(), 0.1);
int __l = (int)((m_oTextRect.left - m_oBounds.left) * 100000 / dW);
int __t = (int)((m_oTextRect.top - m_oBounds.top) * 100000 / dH);
int __r = (int)((m_oTextRect.right - m_oBounds.left) * 100000 / dW);
int __b = (int)((m_oTextRect.bottom - m_oBounds.top) * 100000 / dH);
int __l = (int)((m_oTextRect.left - m_oBounds.left) * 100000 / dW);
int __t = (int)((m_oTextRect.top - m_oBounds.top) * 100000 / dH);
int __r = (int)((m_oTextRect.right - m_oBounds.left) * 100000 / dW);
int __b = (int)((m_oTextRect.bottom - m_oBounds.top) * 100000 / dH);
size_t __nCount = m_pShapeElement->m_oShape.m_oText.m_arParagraphs.size();
if (0 == __nCount || (0x00 == (m_pShapeElement->m_oShape.m_lDrawType & c_ShapeDrawType_Text)))
......@@ -100,7 +760,8 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
{
CString strGuides = _T("");
strGuides.Format(_T("<a:gdLst><a:gd name=\"_l\" fmla=\"*/ w %d 100000\"/><a:gd name=\"_t\" fmla=\"*/ h %d 100000\"/>\
<a:gd name=\"_r\" fmla=\"*/ w %d 100000\"/><a:gd name=\"_b\" fmla=\"*/ h %d 100000\"/></a:gdLst>"), __l, __t, __r, __b);
<a:gd name=\"_r\" fmla=\"*/ w %d 100000\"/><a:gd name=\"_b\" fmla=\"*/ h %d 100000\"/></a:gdLst>"),
__l, __t, __r, __b);
m_oWriter.WriteString(strGuides);
m_oWriter.WriteString(std::wstring(L"<a:rect l=\"_l\" t=\"_t\" r=\"_r\" b=\"_b\"/>"));
......@@ -115,91 +776,34 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
{
m_oWriter.WriteString(m_pShapeElement->m_oShape.m_strPPTXShape);
}
}/*else
m_oWriter.WriteString(std::wstring(L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>"));*/
CBrush* pBrush = &m_pShapeElement->m_oShape.m_oBrush;
if (pBrush->Type == c_BrushTypeTexture)
{
CString strRid = m_pRels->WriteImage(pBrush->TexturePath);
m_oWriter.WriteString(std::wstring(L"<a:blipFill dpi=\"0\" rotWithShape=\"1\"><a:blip r:embed=\"") + string2std_string(strRid) +
_T("\"/><a:srcRect/><a:stretch><a:fillRect/></a:stretch></a:blipFill>"));
}
else if (pBrush->Type == c_BrushTypeNoFill)
{
m_oWriter.WriteString(std::wstring(L"<a:noFill/>"));
}
else if (pBrush->Color1.m_lSchemeIndex == -1)
{
if (255 == pBrush->Alpha1)
{
CString str = _T("");
str.Format(_T("<a:solidFill><a:srgbClr val=\"%06x\"/></a:solidFill>"), pBrush->Color1.GetLONG_RGB());
m_oWriter.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:solidFill><a:srgbClr val=\"%06x\"><a:alpha val=\"%d\"/></a:srgbClr></a:solidFill>"), pBrush->Color1.GetLONG_RGB(), (int)(pBrush->Alpha1 * 100000 / 255));
m_oWriter.WriteString(str);
}
}
else
{
if (255 == pBrush->Alpha1)
{
CString str = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pBrush->Color1.m_lSchemeIndex) + _T("\"/></a:solidFill>");
m_oWriter.WriteString(str);
}
else
{
CString strAlpha; strAlpha.Format(_T("%d"), (int)(pBrush->Alpha1 * 100000 / 255));
if (prstGeom.empty()) prstGeom = L"rect";
CString str = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pBrush->Color1.m_lSchemeIndex) + _T("\"><a:alpha val=\"") + strAlpha + _T("\"/></a:schemeClr></a:solidFill>");
m_oWriter.WriteString(str);
}
}
//m_oWriter.WriteString(std::wstring(L"<a:effectLst/>"));
CPen* pPen = &m_pShapeElement->m_oShape.m_oPen;
CString strLine = _T("");
strLine.Format(_T("<a:ln w=\"%d\">"), (int)(pPen->Size * 36000));
m_oWriter.WriteString(strLine);
if (pPen->Color.m_lSchemeIndex == -1)
{
if (255 == pPen->Alpha)
m_oWriter.WriteString(std::wstring(L"<a:prstGeom"));
{
CString str = _T("");
str.Format(_T("<a:solidFill><a:srgbClr val=\"%06x\"/></a:solidFill>"), pPen->Color.GetLONG_RGB());
m_oWriter.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:solidFill><a:srgbClr val=\"%06x\"><a:alpha val=\"%d\"/></a:srgbClr></a:solidFill>"), pPen->Color.GetLONG_RGB(), (int)(pPen->Alpha * 100000 / 255));
m_oWriter.WriteString(str);
m_oWriter.WriteString(std::wstring(L" prst=\"") + prstGeom + std::wstring(L"\">"));
if (!m_bWordArt)
{
m_oWriter.WriteString(std::wstring(L"<a:avLst/>"));
//todooo !!
//for (int i = 0; i < m_pShapeElement->m_oShape.m_pShape->m_arAdjustments.size(); i++)
//{
// CString str;
// str.Format(L"<a:gd name=\"adj%d\" fmla=\"val %d\"/>", i+1, m_pShapeElement->m_oShape.m_pShape->m_arAdjustments[i]);
// m_oWriter.WriteString(str);
//}
//m_oWriter.WriteString(std::wstring(L"</a:avLst>"));
}
}
m_oWriter.WriteString(std::wstring(L"</a:prstGeom>"));
}
else
{
if (255 == pPen->Alpha)
{
CString str = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pPen->Color.m_lSchemeIndex) + _T("\"/></a:solidFill>");
m_oWriter.WriteString(str);
}
else
{
CString strAlpha; strAlpha.Format(_T("%d"), (int)(pPen->Alpha * 100000 / 255));
CString str = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pPen->Color.m_lSchemeIndex) + _T("\"><a:alpha val=\"") + strAlpha + _T("\"/></a:schemeClr></a:solidFill>");
m_oWriter.WriteString(str);
}
}
m_oWriter.WriteString(std::wstring(L"<a:round/><a:headEnd/><a:tailEnd/></a:ln>"));
m_oWriter.WriteString(ConvertBrush(m_oBrush));
m_oWriter.WriteString(ConvertLine());
m_oWriter.WriteString(ConvertShadow());
m_oWriter.WriteString(std::wstring(L"</p:spPr>"));
......@@ -213,6 +817,8 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
CString NSPresentationEditor::CShapeWriter::ConvertImage()
{
if (m_pImageElement->m_bImagePresent == false) return _T("");
m_oWriter.WriteString(std::wstring(L"<p:pic>"));
WriteImageInfo();
......@@ -251,7 +857,7 @@ CString NSPresentationEditor::CShapeWriter::ConvertImage()
if (m_pImageElement->m_bTile)
{
m_oWriter.WriteString(std::wstring(L"<a:tile><a:fillRect/></a:tile>"));
m_oWriter.WriteString(std::wstring(L"<a:tile/>"));
}
else if (m_pImageElement->m_bStretch)
{
......@@ -264,67 +870,42 @@ CString NSPresentationEditor::CShapeWriter::ConvertImage()
if (m_bIsWriteGeom)
{
CString strPosition = _T("");
if (0 == m_pImageElement->m_dRotate)
CString str;
m_oWriter.WriteString(std::wstring(L"<a:xfrm"));
if (0 != m_pImageElement->m_dRotate)
{
str.Format(L" rot=\"%d\"", m_pImageElement->m_dRotate * 60000);
m_oWriter.WriteString(str);
}
if (m_pImageElement->m_bFlipH)
{
m_oWriter.WriteString(std::wstring(L" flipH=\"1\""));
}
if (m_pImageElement->m_bFlipV)
{
m_oWriter.WriteString(std::wstring(L" flipV=\"1\""));
}
m_oWriter.WriteString(std::wstring(L">"));
if (m_pImageElement->m_rcBoundsOriginal.left >= 0 && m_pImageElement->m_rcBoundsOriginal.top >=0 )
{
strPosition.Format(_T("<a:xfrm><a:off x=\"%d\" y=\"%d\"/><a:ext cx=\"%d\" cy=\"%d\"/></a:xfrm>"),
(size_t) m_pImageElement->m_rcBoundsOriginal.left,
(size_t) m_pImageElement->m_rcBoundsOriginal.top,
(size_t)(m_pImageElement->m_rcBoundsOriginal.right - m_pImageElement->m_rcBoundsOriginal.left),
(size_t)(m_pImageElement->m_rcBoundsOriginal.bottom - m_pImageElement->m_rcBoundsOriginal.top));
str.Format(_T("<a:off x=\"%d\" y=\"%d\"/>"), (int)m_pImageElement->m_rcBoundsOriginal.left, (int)m_pImageElement->m_rcBoundsOriginal.top);
m_oWriter.WriteString(str);
}
else
if (m_pImageElement->m_rcBoundsOriginal.right - m_pImageElement->m_rcBoundsOriginal.left > 0 &&
m_pImageElement->m_rcBoundsOriginal.bottom - m_pImageElement->m_rcBoundsOriginal.top >0 )
{
strPosition.Format(_T("<a:xfrm rot=\"%d\" flipH=\"%d\" flipV=\"%d\"><a:off x=\"%d\" y=\"%d\"/><a:ext cx=\"%d\" cy=\"%d\"/></a:xfrm>"),
(int)(m_pImageElement->m_dRotate * 60000), m_pImageElement->m_bFlipH ? 1 : 0, m_pImageElement->m_bFlipV ? 1 : 0,
(int) m_pImageElement->m_rcBoundsOriginal.left,
(int) m_pImageElement->m_rcBoundsOriginal.top,
(int)(m_pImageElement->m_rcBoundsOriginal.right - m_pImageElement->m_rcBoundsOriginal.left),
(int)(m_pImageElement->m_rcBoundsOriginal.bottom - m_pImageElement->m_rcBoundsOriginal.top));
str.Format(_T("<a:ext cx=\"%d\" cy=\"%d\"/>"), (int)(m_pImageElement->m_rcBoundsOriginal.right - m_pImageElement->m_rcBoundsOriginal.left),
(int)(m_pImageElement->m_rcBoundsOriginal.bottom - m_pImageElement->m_rcBoundsOriginal.top));
m_oWriter.WriteString(str);
}
m_oWriter.WriteString(strPosition);
m_oWriter.WriteString(std::wstring(L"</a:xfrm>"));
}
m_oWriter.WriteString(std::wstring(L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>"));
m_oWriter.WriteString(std::wstring(L"<a:noFill/>"));
//CPen* pPen = &m_pImageElement->m_oShape.m_oPen;
//CString strLine = _T("");
//strLine.Format(_T("<a:ln w=\"%d\">"), (int)(pPen->Size * 36000));
//m_oWriter.WriteString(strLine);
//if (pPen->Color.m_lSchemeIndex == -1)
//{
// if (255 == pPen->Alpha)
// {
// CString str = _T("");
// str.Format(_T("<a:solidFill><a:srgbClr val=\"%06x\"/></a:solidFill>"), pPen->Color.GetLONG_RGB());
// m_oWriter.WriteString(str);
// }
// else
// {
// CString str = _T("");
// str.Format(_T("<a:solidFill><a:srgbClr val=\"%06x\"><a:alpha val=\"%d\"/></a:srgbClr></a:solidFill>"), pPen->Color.GetLONG_RGB(), (int)(pPen->Alpha * 100000 / 255));
// m_oWriter.WriteString(str);
// }
//}
//else
//{
// if (255 == pPen->Alpha)
// {
// CString str = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pPen->Color.m_lSchemeIndex) + _T("\"/></a:solidFill>");
// m_oWriter.WriteString(str);
// }
// else
// {
// CString strAlpha; strAlpha.Format(_T("%d"), (int)(pPen->Alpha * 100000 / 255));
// CString str = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pPen->Color.m_lSchemeIndex) + _T("\"><a:alpha val=\"") + strAlpha + _T("\"/></a:schemeClr></a:solidFill>");
// m_oWriter.WriteString(str);
// }
//}
//m_oWriter.WriteString(std::wstring(L"<a:round/><a:headEnd/><a:tailEnd/></a:ln>"));
m_oWriter.WriteString(std::wstring(L"</p:spPr>"));
m_oWriter.WriteString(std::wstring(L"</p:pic>"));
......
......@@ -11,23 +11,23 @@ namespace NSPresentationEditor
{
switch (lType)
{
case 0: return _T("body");
case 1: return _T("chart");
case 2: return _T("clipArt");
case 3: return _T("ctrTitle");
case 4: return _T("dgm");
case 5: return _T("dt");
case 6: return _T("ftr");
case 7: return _T("hdr");
case 8: return _T("media");
case 9: return _T("obj");
case 10: return _T("pic");
case 11: return _T("sldImg");
case 12: return _T("sldNum");
case 13: return _T("subTitle");
case 14: return _T("tbl");
case 15: return _T("title");
default: break;
case 0: return _T("body");
case 1: return _T("chart");
case 2: return _T("clipArt");
case 3: return _T("ctrTitle");
case 4: return _T("dgm");
case 5: return _T("dt");
case 6: return _T("ftr");
case 7: return _T("hdr");
case 8: return _T("media");
case 9: return _T("obj");
case 10: return _T("pic");
case 11: return _T("sldImg");
case 12: return _T("sldNum");
case 13: return _T("subTitle");
case 14: return _T("tbl");
case 15: return _T("title");
default: break;
}
return _T("body");
}
......@@ -50,6 +50,8 @@ namespace NSPresentationEditor
LONG m_lNextShapeID;
bool m_bIsWriteGeom;
bool m_bWordArt;
bool m_bTextBox;
public:
CShapeWriter();
......@@ -73,6 +75,8 @@ namespace NSPresentationEditor
m_oTextRect = m_oBounds;
m_bIsWriteGeom = true;
m_bWordArt = false;
m_bTextBox = false;
m_oWriter.ClearNoAttack();
m_oWriterPath.ClearNoAttack();
......@@ -88,6 +92,8 @@ namespace NSPresentationEditor
m_oTextRect = m_oBounds;
m_bIsWriteGeom = true;
m_bWordArt = false;
m_bTextBox = false;
if (m_pShapeElement)
{
......@@ -102,8 +108,12 @@ namespace NSPresentationEditor
{
m_bIsWriteGeom = bIsWrite;
}
CString ConvertShape();
CString ConvertImage();
CString ConvertShape ();
CString ConvertImage ();
CString ConvertLine ();
CString ConvertShadow ();
CString ConvertBrush (CBrush & brush);
CString ConvertColor (CColor & color, long alpha);
// -----------------------------------------------------------------------------
virtual HRESULT get_Type(LONG* lType) ;
//-------- --------------------------------------------------
......@@ -380,393 +390,9 @@ namespace NSPresentationEditor
m_oWriterPath.WriteString(str);
}
void WriteShapeInfo()
{
m_oWriter.WriteString(std::wstring(L"<p:nvSpPr>"));
CString strShapeID = _T("");
strShapeID.Format(L"%d", m_pShapeElement->m_lID);
m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") + string2std_string(strShapeID) + L"\"");
if (m_pShapeElement->m_sName.empty()) m_pShapeElement->m_sName = std::wstring(L"Shape ") + string2std_string(strShapeID);
m_oWriter.WriteString(std::wstring(L" name=\"") + m_pShapeElement->m_sName + L"\"");
m_oWriter.WriteString(std::wstring(L"></p:cNvPr><p:cNvSpPr><a:spLocks noGrp=\"1\" noChangeArrowheads=\"1\"/></p:cNvSpPr>"));
++m_lNextShapeID;
if (-1 != m_pShapeElement->m_lPlaceholderType)
{
if (15 == m_pShapeElement->m_lPlaceholderType)
m_pShapeElement->m_lPlaceholderID = -1;
if (0 == m_pShapeElement->m_lPlaceholderType)
m_pShapeElement->m_lPlaceholderID = 1;
if (-1 == m_pShapeElement->m_lPlaceholderID)
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pShapeElement->m_lPlaceholderType) +_T("\"/></p:nvPr>"));
}
else
{
CString strIdx; strIdx.Format(_T("%d"), m_pShapeElement->m_lPlaceholderID);
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pShapeElement->m_lPlaceholderType) + _T("\" idx=\"") + string2std_string(strIdx) + _T("\""));
if (5 == m_pShapeElement->m_lPlaceholderType)
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
if (12 == m_pShapeElement->m_lPlaceholderType)
m_oWriter.WriteString(std::wstring(L" size=\"quarter\""));
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
}
}
else
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr/>"));
}
CString str2 = _T("</p:nvSpPr>");
m_oWriter.WriteString(str2);
}
void WriteImageInfo()
{
m_oWriter.WriteString(std::wstring(L"<p:nvPicPr>"));
CString strShapeID;
strShapeID.Format(_T("%d"), m_lNextShapeID);
m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") +string2std_string(strShapeID) + L"\"" );
if (m_pImageElement->m_sName.empty()) m_pImageElement->m_sName = std::wstring(L"Image ") + string2std_string(strShapeID);
m_oWriter.WriteString(std::wstring(L" name=\"") + m_pImageElement->m_sName + L"\"");
m_oWriter.WriteString(std::wstring(L"></p:cNvPr><p:cNvPicPr><a:spLocks noGrp=\"1\" noChangeAspect=\"1\"/></p:cNvPicPr>"));
++m_lNextShapeID;
if (-1 != m_pImageElement->m_lPlaceholderType)
{
if (15 == m_pImageElement->m_lPlaceholderType)
m_pImageElement->m_lPlaceholderID = -1;
if (0 == m_pImageElement->m_lPlaceholderType)
m_pImageElement->m_lPlaceholderID = 1;
if (-1 == m_pImageElement->m_lPlaceholderID)
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) +_T("\"/></p:nvPr>"));
}
else
{
CString strIdx; strIdx.Format(_T("%d"), m_pImageElement->m_lPlaceholderID);
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + _T("\" idx=\"") + string2std_string(strIdx) + _T("\"/></p:nvPr>"));
}
}
else
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr/>"));
}
CString str2 = _T("</p:nvPicPr>");
m_oWriter.WriteString(str2);
}
void WriteTextInfo()
{
size_t nCount = m_pShapeElement->m_oShape.m_oText.m_arParagraphs.size();
if (/*0 == nCount || */(0x00 == (m_pShapeElement->m_oShape.m_lDrawType & c_ShapeDrawType_Text)))
return;
if (0 == nCount)
{
CString strEmptyText = _T("<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr dirty=\"0\"/></a:p></p:txBody>");
m_oWriter.WriteString(strEmptyText);
return;
}
void WriteShapeInfo();
m_oWriter.WriteString(std::wstring(L"<p:txBody>"));
m_oWriter.WriteString(std::wstring(L"<a:bodyPr lIns=\"0\" tIns=\"0\" rIns=\"0\" bIns=\"0\""));
if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 0 )
m_oWriter.WriteString(" anchor=\"t\"");
else if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 2 )
m_oWriter.WriteString(" anchor=\"b\"");
else if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 1 )
m_oWriter.WriteString(" anchor=\"ctr\"");
m_oWriter.WriteString(std::wstring(L"/>"));
CString str3 = _T("<a:lstStyle>");
m_oWriter.WriteString(str3);
CStylesWriter::ConvertStyles(m_pShapeElement->m_oShape.m_oText.m_oStyles, m_oMetricInfo, m_oWriter);
CString str4 = _T("</a:lstStyle>");
m_oWriter.WriteString(str4);
for (size_t nIndexPar = 0; nIndexPar < nCount; ++nIndexPar)
{
NSPresentationEditor::CParagraph* pParagraph = &m_pShapeElement->m_oShape.m_oText.m_arParagraphs[nIndexPar];
CString _str1 = _T("");
_str1.Format(_T("<a:p><a:pPr lvl=\"%d\""), pParagraph->m_lTextLevel);
m_oWriter.WriteString(_str1);
NSPresentationEditor::CTextPFRun* pPF = &pParagraph->m_oPFRun;
if (pPF->fontAlign.is_init())
{
CString strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get());
m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + string2std_string(strProp) + _T("\""));
}
if (pPF->leftMargin.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" marL=\"%d\""), pPF->leftMargin.get());
m_oWriter.WriteString(strProp);
}
if (pPF->indent.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" indent=\"%d\""), pPF->indent.get());
m_oWriter.WriteString(strProp);
}
if (pPF->textAlignment.is_init())
{
CString strProp = CStylesWriter::GetTextAlign(pPF->textAlignment.get());
m_oWriter.WriteString(std::wstring(L" algn=\"") + string2std_string(strProp) + _T("\""));
}
if (pPF->defaultTabSize.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" defTabSz=\"%d\""), pPF->defaultTabSize.get());
m_oWriter.WriteString(strProp);
}
CString _str2 = _T(">");
m_oWriter.WriteString(_str2);
double dKoef1 = 3.52777778;
if (pPF->lineSpacing.is_init())
{
LONG val = pPF->lineSpacing.get();
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:lnSpc><a:spcPts val=\"%d\"/></a:lnSpc>"), (int)(val / dKoef1));
m_oWriter.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:lnSpc><a:spcPct val=\"%d\"/></a:lnSpc>"), -val * 1000);
m_oWriter.WriteString(str);
}
}
if (pPF->spaceAfter.is_init())
{
LONG val = pPF->spaceAfter.get();
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:spcAft><a:spcPts val=\"%d\"/></a:spcAft>"), (int)(val / dKoef1));
m_oWriter.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:spcAft><a:spcPct val=\"%d\"/></a:spcAft>"), -val * 1000);
m_oWriter.WriteString(str);
}
}
if (pPF->spaceBefore.is_init())
{
LONG val = pPF->spaceBefore.get();
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:spcBef><a:spcPts val=\"%d\"/></a:spcBef>"), (int)(val / dKoef1));
m_oWriter.WriteString(str);
}
else
{
CString str = _T("");
str.Format(_T("<a:spcBef><a:spcPct val=\"%d\"/></a:spcBef>"), -val * 1000);
m_oWriter.WriteString(str);
}
}
if (pPF->hasBullet.is_init())
{
if (pPF->hasBullet.get())
{
wchar_t bu = 0x2022;
m_oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
if (pPF->bulletChar.is_init())
{
bu = pPF->bulletChar.get();
}
m_oWriter.WriteString(std::wstring(&bu, 1));
m_oWriter.WriteString(std::wstring(L"\"/>"));
}
else
{
m_oWriter.WriteString(std::wstring(L"<a:buNone/>"));
}
}
m_oWriter.WriteString(std::wstring(L"</a:pPr>"));
std::wstring typeRun = L"a:r";
//if (m_pShapeElement->m_lPlaceholderType == 12)
//{
// m_oWriter.WriteString(std::wstring(L"<a:fld id=\"{D038279B-FC19-497E-A7D1-5ADD9CAF016F}\" type=\"slidenum\">"));
// m_oWriter.WriteString(std::wstring(L"<a:rPr/><a:t>#</a:t></a:fld>"));
//}
//else
size_t nCountSpans = pParagraph->m_arSpans.size();
for (size_t nSpan = 0; nSpan < nCountSpans; ++nSpan)
{
if (TRUE)
{
if ((nSpan == (nCountSpans - 1)) && (_T("\n") == pParagraph->m_arSpans[nSpan].m_strText))
{
NSPresentationEditor::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun;
if (pCF->Size.is_init())
{
CString strProp = _T("");
strProp.Format(_T("<a:endParaRPr lang=\"en-US\" sz=\"%d\"/>"), (int)(100 * pCF->Size.get()));
m_oWriter.WriteString(strProp);
}
else
{
m_oWriter.WriteString(std::wstring(L"<a:endParaRPr lang=\"en-US\"/>"));
}
continue;
}
}
if (pParagraph->m_arSpans[nSpan].m_strText.IsEmpty()) continue;
NSPresentationEditor::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun;
bool bIsBr = false;
if (pParagraph->m_arSpans[nSpan].m_strText.GetLength() >0)
{
if(_T("\n") == pParagraph->m_arSpans[nSpan].m_strText) bIsBr=true;
}
if (bIsBr)
{
CString strRun1 = _T("<a:br><a:rPr");
m_oWriter.WriteString(strRun1);
}
else
{
if (m_pShapeElement->m_lPlaceholderType == 12)//todooo + date
{
m_oWriter.WriteString(std::wstring(L"<a:fld id=\"{D038279B-FC19-497E-A7D1-5ADD9CAF016F}\" type=\"slidenum\"><a:rPr"));
}
else
{
m_oWriter.WriteString(std::wstring(L"<a:r><a:rPr"));
}
}
if (pCF->Size.is_init())
{
CString strProp = _T("");
strProp.Format(_T(" sz=\"%d\""), (int)(100 * pCF->Size.get()));
m_oWriter.WriteString(strProp);
}
if (pCF->FontBold.is_init())
{
if (pCF->FontBold.get())
m_oWriter.WriteString(std::wstring(L" b=\"1\""));
else
m_oWriter.WriteString(std::wstring(L" b=\"0\""));
}
if (pCF->FontItalic.is_init())
{
if (pCF->FontItalic.get())
m_oWriter.WriteString(std::wstring(L" i=\"1\""));
else
m_oWriter.WriteString(std::wstring(L" i=\"0\""));
}
m_oWriter.WriteString(std::wstring(L">"));
if (pCF->Color.is_init())
{
if (pCF->Color->m_lSchemeIndex != -1)
{
CString strProp = _T("<a:solidFill><a:schemeClr val=\"") + CStylesWriter::GetColorInScheme(pCF->Color->m_lSchemeIndex) + _T("\"/></a:solidFill>");
m_oWriter.WriteString(strProp);
}
else
{
CString strColor = _T("");
strColor.Format(_T("%06x"), pCF->Color->GetLONG_RGB());
CString strProp = _T("<a:solidFill><a:srgbClr val=\"") + strColor + _T("\"/></a:solidFill>");
m_oWriter.WriteString(strProp);
}
}
if (pCF->Typeface.is_init())
{
if (0 == pCF->Typeface.get())
{
CString strProp = _T("<a:latin typeface=\"+mj-lt\"/>");
m_oWriter.WriteString(strProp);
}
else
{
CString strProp = _T("<a:latin typeface=\"+mn-lt\"/>");
m_oWriter.WriteString(strProp);
}
}
else if (pCF->FontProperties.is_init())
{
m_oWriter.WriteString(std::wstring(L"<a:latin typeface=\"") + pCF->FontProperties->strFontName + _T("\"/>"));
}
m_oWriter.WriteString(std::wstring(L"</a:rPr>"));
if (!bIsBr)
{
CString strT1 = _T("<a:t>");
m_oWriter.WriteString(strT1);
CString strT = pParagraph->m_arSpans[nSpan].m_strText;
NSPresentationEditor::CorrectXmlString(strT);
m_oWriter.WriteString(strT);
CString strT2 = _T("</a:t>");
m_oWriter.WriteString(strT2);
if (m_pShapeElement->m_lPlaceholderType == 12)
m_oWriter.WriteString(std::wstring(L"</a:fld>"));
else
m_oWriter.WriteString(std::wstring(L"</a:r>"));
}
else
{
m_oWriter.WriteString(std::wstring(L"</a:br>"));
}
}
CString strEndPar = _T("</a:p>");
m_oWriter.WriteString(strEndPar);
}
CString str5 = _T("</p:txBody>");
m_oWriter.WriteString(str5);
}
void WriteImageInfo();
void WriteTextInfo();
};
}
......@@ -135,6 +135,9 @@ public:
CString strProp = _T("");
strProp.Format(_T(" marL=\"%d\""), pPF->leftMargin.get());
oWriter.WriteString(strProp);
if (pPF->indent.is_init() == false)
pPF->indent = (LONG)0;
}
if (pPF->indent.is_init())
{
......@@ -142,11 +145,11 @@ public:
strProp.Format(_T(" indent=\"%d\""), pPF->indent.get());
oWriter.WriteString(strProp);
}
if (pPF->textAlignment.is_init())
{
CString strProp = GetTextAlign(pPF->textAlignment.get());
oWriter.WriteString(std::wstring(L" algn=\"") + string2std_string(strProp) + _T("\""));
}
//if (pPF->textAlignment.is_init())
//{
// CString strProp = GetTextAlign(pPF->textAlignment.get());
// oWriter.WriteString(std::wstring(L" algn=\"") + string2std_string(strProp) + _T("\""));
//}
if (pPF->defaultTabSize.is_init())
{
CString strProp = _T("");
......@@ -183,7 +186,7 @@ public:
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:lnSpc><a:spcPts val=\"%d\"/></a:lnSpc>"), (int)(val / dKoef1));
str.Format(_T("<a:lnSpc><a:spcPts val=\"%d\"/></a:lnSpc>"), (int)(val / dKoef1 * 100));
oWriter.WriteString(str);
}
else
......@@ -199,10 +202,10 @@ public:
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:spcAft><a:spcPts val=\"%d\"/></a:spcAft>"), (int)(val / dKoef1));
str.Format(_T("<a:spcAft><a:spcPts val=\"%d\"/></a:spcAft>"), (int)(val / dKoef1 * 100));
oWriter.WriteString(str);
}
else
else if (val < 0)
{
CString str = _T("");
str.Format(_T("<a:spcAft><a:spcPct val=\"%d\"/></a:spcAft>"), -val * 1000);
......@@ -215,10 +218,10 @@ public:
if (val > 0)
{
CString str = _T("");
str.Format(_T("<a:spcBef><a:spcPts val=\"%d\"/></a:spcBef>"), (int)(val / dKoef1));
str.Format(_T("<a:spcBef><a:spcPts val=\"%d\"/></a:spcBef>"), (int)(val / dKoef1 * 100));
oWriter.WriteString(str);
}
else
else if (val < 0)
{
CString str = _T("");
str.Format(_T("<a:spcBef><a:spcPct val=\"%d\"/></a:spcBef>"), -val * 1000);
......
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