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)
......
......@@ -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 "../../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:
......
......@@ -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
......
#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()
{
......
......@@ -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
}
}
This diff is collapsed.
......@@ -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();
......
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