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

PPTFormat fix по результатам тестирвоания

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65477 954022d7-b5bf-4e40-9824-e11837661b57
parent b025e737
......@@ -599,6 +599,22 @@ void CPPTUserInfo::LoadSlide(DWORD dwSlideID, CSlide* pSlide)
//}
}
IElement* CPPTUserInfo::AddNewLayoutElement (CLayout *pLayout, int placeholderType)
{
if (placeholderType < 1) return NULL;
CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pShape->m_lPlaceholderType = CPPTElement::CorrectPlaceHolderType(placeholderType);
pShape->m_bPlaceholderSet = false;
pShape->m_bLine = false;
pShape->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pShape));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pShape->m_lPlaceholderType, pLayout->m_arElements.size()-1));
return pShape;
}
int CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayoutAtom* layoutRecord, std::vector<CTextFullSettings> & text,
CRecordHeadersFootersAtom* headers_footers, bool addShapes)
......@@ -631,15 +647,9 @@ int CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayou
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));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pShape->m_lPlaceholderType, pLayout->m_arElements.size()-1));
AddNewLayoutElement(pLayout, layoutRecord->m_pPlaceHolderID[i]);
}
if (headers_footers)
{
std::map<int, int>::iterator it;
......@@ -650,14 +660,7 @@ int CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayou
it = pLayout->m_pPlaceholders.find(12);
if ( it == pLayout->m_pPlaceholders.end())
{
pElement = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pElement->m_lPlaceholderType = 12;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pLayout->m_arElements.size()-1));
pElement = AddNewLayoutElement(pLayout, 12);
}
else
{
......@@ -675,14 +678,7 @@ int CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayou
it = pLayout->m_pPlaceholders.find(5);
if (it == pLayout->m_pPlaceholders.end())
{
pElement = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pElement->m_lPlaceholderType = 5;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pLayout->m_arElements.size()-1));
pElement = AddNewLayoutElement(pLayout, 5);
}
else
{
......@@ -698,14 +694,7 @@ int CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayou
it = pLayout->m_pPlaceholders.find(7);
if (it == pLayout->m_pPlaceholders.end())
{
pElement = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pElement->m_lPlaceholderType = 7;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pLayout->m_arElements.size()-1));
pElement = AddNewLayoutElement(pLayout, 7);
}
else
{
......@@ -721,14 +710,7 @@ int CPPTUserInfo::AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayou
it = pLayout->m_pPlaceholders.find(6);
if (it == pLayout->m_pPlaceholders.end())
{
pElement = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pElement->m_lPlaceholderType = 6;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pLayout->m_arElements.size()-1));
pElement = AddNewLayoutElement(pLayout, 6);
}
else
{
......@@ -797,7 +779,6 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
if (0 != oArrayOrigId.size())
m_mapMasterOriginalIds.insert(std::pair<DWORD, DWORD>(oArrayOrigId[0]->m_dwID, dwMasterID));
LONG lIndexTheme = (LONG)m_arThemes.size();
m_mapMasterToTheme.insert(std::pair<DWORD, LONG>(dwMasterID, lIndexTheme));
......@@ -867,9 +848,6 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
}
// ---------------------------------------------------------------------------------
// , placeholder
std::map<DWORD, CRecordSlide*>::iterator pPairMaster1 = m_mapMasters.find(dwMasterID);
int indexUser = 0;
......@@ -969,7 +947,7 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
pElement->m_lPlaceholderType = 12;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pElement->m_bBoundsEnabled = false;
pTheme->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pTheme->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pTheme->m_arElements.size()-1));
......@@ -985,7 +963,7 @@ void CPPTUserInfo::LoadMainMaster(DWORD dwMasterID, const LONG& lOriginWidth, co
pElement->m_lPlaceholderType = 5;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pElement->m_bBoundsEnabled = false;
pTheme->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pTheme->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pTheme->m_arElements.size()-1));
......@@ -1086,11 +1064,12 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
CLayout* pLayout = NULL;
std::map<std::wstring, LONG>::iterator pPair1 = pTheme->m_mapGeomToLayout.find(strLayoutType);
int lLayoutID = AddNewLayout(pTheme, &oArraySlideAtoms[0]->m_oLayout, pCurMaster->m_oPersist.m_arTextAttrs, false);
pLayout = &pTheme->m_arLayouts[lLayoutID];
pLayout->m_bShowMasterShapes = false;
int lLayoutID = AddNewLayout(pTheme, &oArraySlideAtoms[0]->m_oLayout, pCurMaster->m_oPersist.m_arTextAttrs, NULL, false);
pLayout = &pTheme->m_arLayouts[lLayoutID];
pLayout->m_bShowMasterShapes = false;
pTheme->m_mapTitleLayout[dwMasterID] = lLayoutID;
pTheme->m_mapTitleLayout[dwMasterID] = lLayoutID;
std::vector<NSPresentationEditor::CColor>* pArrayColorScheme = &pTheme->m_arColorScheme;
// -----------------------------------------------------------
......@@ -1160,6 +1139,7 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
pElem->m_bPlaceholderSet = true;
pLayout->m_arElements.push_back(pElem);
if ( pElem->m_lPlaceholderType >0)
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElem->m_lPlaceholderType, pLayout->m_arElements.size()-1));
......@@ -1174,14 +1154,7 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
{
if (pLayout->m_pPlaceholders.find(12) == pLayout->m_pPlaceholders.end())
{
CShapeElement* pElement = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pElement->m_lPlaceholderType = 12;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pLayout->m_arElements.size()-1));
AddNewLayoutElement(pLayout, 12);
}
}
if (oArrayHeadersFootersAtoms[0]->m_bHasTodayDate ||
......@@ -1190,14 +1163,7 @@ void CPPTUserInfo::LoadNoMainMaster(DWORD dwMasterID, const LONG& lOriginWidth,
{
if (pLayout->m_pPlaceholders.find(5) == pLayout->m_pPlaceholders.end())
{
CShapeElement* pElement = new CShapeElement(NSBaseShape::ppt, PPTShapes::sptCRect);
pElement->m_lPlaceholderType = 5;
pElement->m_bPlaceholderSet = false;
//pElement->m_bBoundsEnabled = false;
pLayout->m_arElements.push_back(dynamic_cast<IElement*>(pElement));
pLayout->m_pPlaceholders.insert(std::pair<int, int>(pElement->m_lPlaceholderType, pLayout->m_arElements.size()-1));
AddNewLayoutElement(pLayout, 5);
}
}
}
......
......@@ -251,6 +251,7 @@ public:
void AddAnimation (DWORD dwSlideID, double Width, double Height, IElement* pElement);
void AddAudioTransition (DWORD dwSlideID, CTransition* pTransition, const std::wstring& strFilePath);
int AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayoutAtom* layoutRecord, std::vector<CTextFullSettings> & text,
int AddNewLayout(NSPresentationEditor::CTheme* pTheme, SSlideLayoutAtom* layoutRecord, std::vector<CTextFullSettings> & text,
CRecordHeadersFootersAtom* headers_footers = NULL, bool addShapes = true);
IElement* AddNewLayoutElement (CLayout *pLayout, int placeholderType);
};
......@@ -12,6 +12,7 @@
#include "../OutlineTextRefAtom.h"
#include "../InteractiveInfoAtom.h"
#include "../TextInteractiveInfoAtom.h"
#include "../MasterTextPropAtom.h"
#include "../../Reader/ClassesAtom.h"
#include "../../Reader/SlideInfo.h"
......@@ -410,8 +411,8 @@ public:
pElement->m_oBrush.TexturePath = pElement->m_oBrush.TexturePath + pInfo->GetFileNamePicture(dwOffset);
if (pElement->m_oBrush.Type == c_BrushTypePattern)
{
int rgbColor1 = 0;
int rgbColor2 = 0xFFFFFF;
int rgbColor1 = 0xFFFFFF;
int rgbColor2 = 0;
if (pElement->m_oBrush.Color1.m_lSchemeIndex == -1)
{
......@@ -443,7 +444,7 @@ public:
rgbColor2 = pTheme->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB();
}
}
ChangeBlack2ColorImage(pElement->m_oBrush.TexturePath, rgbColor1, rgbColor2);
ChangeBlack2ColorImage(pElement->m_oBrush.TexturePath, rgbColor2, rgbColor1);
pElement->m_oBrush.Type = c_BrushTypeTexture;
pElement->m_oBrush.TextureMode = c_BrushTextureModeTile;
......@@ -597,8 +598,8 @@ public:
bool bUse3DOk = (0x10 == (0x10 & flag3));
bool bUseShadowOk = (0x20 == (0x20 & flag3));
if (bUseLineOk)
pElement->m_bLine = bLineOk;//?? todooo
//if (bUseLineOk)
// pElement->m_bLine = bLineOk;//?? todooo - ! 1 (82).ppt
if (bUseFillOk)
bIsFilled = bFillOk;
......@@ -900,10 +901,8 @@ public:
}break;
case pibName:
{
std::wstring image_name = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2-1);
pElement->m_sName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2-1);
// TextMining05.ppt, 20 - ( - todooo
//pElement->m_sName = image_name;
}break;
case cropFromTop:
{
......@@ -1055,9 +1054,16 @@ public:
if (!str.empty() && pParentShape->m_oText.m_arParagraphs.empty())
{
int length = str.length();
for (int i = length-1; i>=0; i--)
{
if (str.at(i) > 13 ) break;
length--;
}
NSPresentationEditor::CParagraph p;
NSPresentationEditor::CSpan s;
s.m_strText = std_string2string(str);
s.m_strText = str.substr(0,length);
p.m_arSpans.push_back(s);
pParentShape->m_oText.m_arParagraphs.push_back(p);
}
......@@ -1346,8 +1352,7 @@ public:
}
if (lMasterID == pLayout->m_arElements[nIndex]->m_lID)
{
*ppElement = pLayout->m_arElements[nIndex]->CreateDublicate();
*ppElement = pLayout->m_arElements[nIndex]->CreateDublicate();
if (elType == etShape)
{
......@@ -1442,9 +1447,8 @@ public:
pImageElem->m_strImageFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR;
pElem = (IElement*)pImageElem;
}
break;
}
}
}break;
default:
{
// shape
......@@ -1454,43 +1458,35 @@ public:
{
pShape->m_bShapePreset = true;
}
if (true)//if (/* */OOXMLShapes::sptCustom != pShape->m_oShape.m_eType)
{
CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone;
CExFilesInfo * pTextureInfo = pMapIDs->Lock(0xFFFFFFFF, exType);
if (NULL != pTextureInfo)
{
pShape->m_oBrush.TexturePath = pTextureInfo->m_strFilePath + FILE_SEPARATOR_STR;
}
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
{
delete pShape;
pShape = NULL;
}
break;
}
pElem = (IElement*)pShape;
}break;
}
}
if (NULL == pElem)
return;
{
CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone;
CExFilesInfo * pTextureInfo = pMapIDs->Lock(0xFFFFFFFF, exType);
if (NULL != pTextureInfo)
{
pElem->m_oBrush.TexturePath = pTextureInfo->m_strFilePath + FILE_SEPARATOR_STR;
}
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)
{
pElem->m_sHyperlink = pInfo->m_strFilePath;
}
}
}
pElem->m_lID = oArrayShape[0]->m_nID;
// placeholder
......@@ -1501,10 +1497,10 @@ public:
pElem->m_lPlaceholderID = (int)(oArrayPlaceHolder[0]->m_nPosition);
pElem->m_lPlaceholderType = (int)(oArrayPlaceHolder[0]->m_nPlacementID);
if (0 == pElem->m_lPlaceholderType)
pElem->m_lPlaceholderID = 1;
else if (15 == pElem->m_lPlaceholderType)//??
pElem->m_lPlaceholderID = -1;
//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);
}
......@@ -1529,6 +1525,8 @@ public:
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;
pElem->m_bBoundsEnabled = true;
bAnchor = true;
}
else
......@@ -1544,6 +1542,8 @@ public:
pElem->m_rcBoundsOriginal.bottom = oArrayChildAnchor[0]->m_oBounds.bottom;
RecalcGroupShapeAnchor(pElem->m_rcBoundsOriginal);
pElem->m_bBoundsEnabled = true;
bAnchor = true;
}
else
......@@ -1582,6 +1582,7 @@ public:
pElementLayout->m_rcBounds = pElem->m_rcBounds;
pElementLayout->m_bPlaceholderSet = true;
pElementLayout->m_bBoundsEnabled = true;
}
//
......@@ -1717,6 +1718,14 @@ public:
pSlideWrapper->m_mapElements.insert(std::pair<LONG, CElementInfo>(pShapeElem->m_lID, oElementInfo));
SetUpTextStyle(strText, pTheme, pLayout, pElem, pThemeWrapper, pSlideWrapper, pSlide);
//------------------------------------------------------------------------------------
std::vector<CRecordMasterTextPropAtom*> oArrayMasterTextProp;
GetRecordsByType(&oArrayMasterTextProp, true);
if (!oArrayMasterTextProp.empty())
{
SetUpTextMasterIndent(pElem, oArrayMasterTextProp[0]);
}
}
else
{
......@@ -1813,6 +1822,27 @@ public:
protected:
void SetUpTextMasterIndent(IElement* pElem, CRecordMasterTextPropAtom* master_levels)
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElem);
if (NULL == pShape)
return;
if (master_levels->m_arrProps.empty()) return;
CTextAttributesEx* pText = &(pShape->m_oShape.m_oText);
int pos_text = 0, pos_si = 0;
int ind = 0;
for (int i = 0; i < pText->m_arParagraphs.size(); i++)
{
if (i >= master_levels->m_arrProps.size()) break;
pText->m_arParagraphs[i].m_lTextLevel = master_levels->m_arrProps[i].lIndentLevel;
pText->m_arParagraphs[i].m_oPFRun.leftMargin.reset();
pText->m_arParagraphs[i].m_oPFRun.indent.reset();
}
}
void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, IElement* pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide = NULL)
{
// shape
......@@ -2076,6 +2106,7 @@ protected:
break;
}
case NSOfficePPT::Body:
case NSOfficePPT::CenterBody:
case NSOfficePPT::MasterBody:
case NSOfficePPT::NotesBody:
case NSOfficePPT::MasterNotesBody:
......
......@@ -30,12 +30,8 @@ public:
}
};
private:
std::vector<SMasterTextPropRun> m_arrProps;
public:
CRecordMasterTextPropAtom()
{
}
......@@ -63,26 +59,6 @@ public:
}
virtual CString ToString()
{
CString strName = GetRecordName((DWORD)m_oHeader.RecType);
XmlUtils::CXmlWriter oWriter;
oWriter.WriteNodeBegin(strName, TRUE);
oWriter.WriteAttribute(_T("type"), CDirectory::ToString(m_oHeader.RecType));
oWriter.WriteAttribute(_T("length"), CDirectory::ToString(m_oHeader.RecLen));
oWriter.WriteAttribute(_T("instance"), CDirectory::ToString(m_oHeader.RecInstance));
oWriter.WriteNodeEnd(strName, TRUE, FALSE);
for (size_t nIndex = 0; nIndex < m_arrProps.size(); ++nIndex)
{
CString str = _T("");
str.Format(_T("<Run count='%d' indentlevel='%d' />"), m_arrProps[nIndex].lCount, m_arrProps[nIndex].lIndentLevel);
oWriter.WriteString(str);
}
oWriter.WriteNodeEnd(strName);
return oWriter.GetXmlString();
return L"";
}
};
\ No newline at end of file
......@@ -974,14 +974,6 @@
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Shapes\Shape.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\ShapeWriter.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\ShapeWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\OfficeDrawing\Slide.h"
>
......@@ -1118,6 +1110,14 @@
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\SettingWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\ShapeWriter.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCPresentationEditor\PPTXWriter\ShapeWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\StylesWriter.h"
>
......
......@@ -128,7 +128,7 @@ namespace NSPresentationEditor
m_dRotate = 0.0;
m_bFlipH = false;
m_bFlipV = false;
m_bLine = false;
m_bLine = true;
m_lCountRef = 1;
......
......@@ -289,6 +289,8 @@ namespace NSPresentationEditor
bool m_bOLE;
bool m_bImagePresent;
std::wstring m_sName;
public:
CImageElement() : IElement()
{
......
......@@ -16,8 +16,7 @@ namespace NSPresentationEditor
int lCountCFs = m_arParagraphs[i].m_arSpans.size();
for (int j = 0; j < lCountCFs; ++j)
{
std::wstring s = m_arParagraphs[i].m_arSpans[j].m_strText;
int s_size = s.length();
int s_size = m_arParagraphs[i].m_arSpans[j].m_strText.length();
int lFound1 = m_arParagraphs[i].m_arSpans[j].m_strText.find((TCHAR)13);
int lFound2 = m_arParagraphs[i].m_arSpans[j].m_strText.find((TCHAR)11);
......@@ -74,6 +73,8 @@ namespace NSPresentationEditor
nullable_base<LONG> indent;
nullable_base<LONG> margin;
nullable_base<LONG> spaceBefore;
if (-1 != m_lTextType && m_lTextType < 4 && pTheme->m_pStyles[m_lTextType].m_pLevels[lLevel].is_init())
{
......@@ -97,6 +98,9 @@ namespace NSPresentationEditor
if (pTheme->m_pStyles[m_lTextType].m_pLevels[lLevel]->m_oPFRun.indent.is_init())
indent = pTheme->m_pStyles[m_lTextType].m_pLevels[lLevel]->m_oPFRun.indent;
if (pTheme->m_pStyles[m_lTextType].m_pLevels[lLevel]->m_oPFRun.spaceBefore.is_init())
spaceBefore = pTheme->m_pStyles[m_lTextType].m_pLevels[lLevel]->m_oPFRun.spaceBefore;
}
if (m_oLayoutStyles.m_pLevels[lLevel].is_init())
{
......@@ -120,6 +124,9 @@ namespace NSPresentationEditor
if (m_oLayoutStyles.m_pLevels[lLevel]->m_oPFRun.indent.is_init())
indent = m_oLayoutStyles.m_pLevels[lLevel]->m_oPFRun.indent;
if (m_oLayoutStyles.m_pLevels[lLevel]->m_oPFRun.spaceBefore.is_init())
spaceBefore = m_oLayoutStyles.m_pLevels[lLevel]->m_oPFRun.spaceBefore;
}
if (m_oStyles.m_pLevels[lLevel].is_init())
{
......@@ -143,6 +150,9 @@ namespace NSPresentationEditor
if (m_oStyles.m_pLevels[lLevel]->m_oPFRun.indent.is_init())
indent = m_oStyles.m_pLevels[lLevel]->m_oPFRun.indent;
if (m_oStyles.m_pLevels[lLevel]->m_oPFRun.spaceBefore.is_init())
spaceBefore = m_oStyles.m_pLevels[lLevel]->m_oPFRun.spaceBefore;
}
if (!m_arParagraphs[nIndexP].m_oPFRun.hasBullet.is_init())
......@@ -166,6 +176,8 @@ namespace NSPresentationEditor
if (!m_arParagraphs[nIndexP].m_oPFRun.indent.is_init())
m_arParagraphs[nIndexP].m_oPFRun.indent = indent;
if (!m_arParagraphs[nIndexP].m_oPFRun.spaceBefore.is_init())
m_arParagraphs[nIndexP].m_oPFRun.spaceBefore = spaceBefore;
if (m_arParagraphs[nIndexP].m_oPFRun.bulletFontRef.is_init())
{
......@@ -173,7 +185,11 @@ namespace NSPresentationEditor
m_arParagraphs[nIndexP].m_oPFRun.bulletFontProperties = new CFontProperties();
int ref = m_arParagraphs[nIndexP].m_oPFRun.bulletFontRef.get();
m_arParagraphs[nIndexP].m_oPFRun.bulletFontProperties->SetFont(pTheme->m_arFonts[ref]);
if (ref < pTheme->m_arFonts.size())
{
m_arParagraphs[nIndexP].m_oPFRun.bulletFontProperties->SetFont(pTheme->m_arFonts[ref]);
}
}
}
......
......@@ -562,7 +562,12 @@ void NSPresentationEditor::CPPTXWriter::WriteThemes()
size_t nElements = pTheme->m_arElements.size();
for (size_t nEl = 0; nEl < nElements; ++nEl)
{
if (pTheme->m_arElements[nEl]->m_lPlaceholderType == 0)
pTheme->m_arElements[nEl]->m_lPlaceholderType =100; //body !!
WriteElement(oWriter, oRels, pTheme->m_arElements[nEl]);
}
oWriter.WriteString(std::wstring(L"</p:spTree></p:cSld>"));
......@@ -691,33 +696,6 @@ void NSPresentationEditor::CPPTXWriter::WriteBackground(CStringWriter& oWriter,
{
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;
//}
//else
m_pShapeWriter->SetRelsGenerator(&oRels);
{
oWriter.WriteString(m_pShapeWriter->ConvertBrush(oBackground));
......
......@@ -48,19 +48,23 @@ namespace NSPresentationEditor
if (-1 != nIndexExt)
strExts = strInput.substr(nIndexExt);
if (strExts == _T(".tmp"))
strExts = _T(".png");
if (strExts == _T(".tmp")) strExts = _T(".png");
CString strImage = _T("");
strImage.Format(_T("image%d"), m_lIndexNextImage++);
std::wstring strOutput = m_strDstMedia + string2std_string(strImage) + strExts;
strImage = _T("../media/") + strImage + std_string2string(strExts);
m_mapImages[strInput] = string2std_string(strImage);
//
if (strOutput != strInput)
CDirectory::CopyFile(std_string2string(strInput), std_string2string(strOutput), NULL, NULL);
{
if (CDirectory::CopyFile(std_string2string(strInput), std_string2string(strOutput), NULL, NULL) == false)
{
return L"";
}
}
m_mapImages[strInput] = string2std_string(strImage);
return strImage;
}
......@@ -244,9 +248,8 @@ namespace NSPresentationEditor
m_oWriter.WriteString(strRels);
}
AVSINLINE CString WriteImage(const std::wstring& strImagePath)
AVSINLINE CString WriteHyperlinkImage(const std::wstring& strImage, bool bExternal = true)
{
std::wstring strImage = m_pManager->GenerateImage(strImagePath);
std::map<std::wstring, int>::iterator pPair = m_mapImages.find(strImage);
if (m_mapImages.end() != pPair)
......@@ -264,12 +267,23 @@ namespace NSPresentationEditor
std::wstring strRels = _T("<Relationship Id=\"") ;
strRels += string2std_string(strRid) + _T("\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"");
strRels += strImage + _T("\"/>");
strRels += strImage + _T("\"");
if (bExternal)
strRels += std::wstring(L" TargetMode=\"External\"");
strRels += std::wstring(L"/>");
m_oWriter.WriteString(strRels);
return strRid;
}
AVSINLINE CString WriteImage(const std::wstring& strImagePath)
{
std::wstring strImage = m_pManager->GenerateImage(strImagePath);
if (strImage.empty()) return WriteHyperlinkImage(strImagePath, true);
return WriteHyperlinkImage(strImage, false);
}
};
}
......@@ -96,14 +96,16 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe
}
}
if (pPF->bulletFontProperties.is_init())
{
oWriter.WriteString(std::wstring(L"<a:buFont typeface=\"") + pPF->bulletFontProperties->strFontName + _T("\"/>"));
}
wchar_t bu = 0x2022;
if (pPF->bulletChar.is_init())
{
bu = pPF->bulletChar.get();
}
if (pPF->bulletFontProperties.is_init() && (unsigned short)bu < 0xFF)
{
oWriter.WriteString(std::wstring(L"<a:buFont typeface=\"") + pPF->bulletFontProperties->strFontName + _T("\"/>"));
}
oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
oWriter.WriteStringXML(std::wstring(&bu, 1));
......@@ -532,19 +534,27 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
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 (15 == m_pImageElement->m_lPlaceholderType)
// m_pImageElement->m_lPlaceholderID = -1;
//if (0 == m_pImageElement->m_lPlaceholderType) /// todooo body idx == 1???
// 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>"));
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph"));
if (m_pImageElement->m_lPlaceholderType > 0)
m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) +_T("\""));
m_oWriter.WriteString(std::wstring(L"/></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>"));
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph"));
if (m_pImageElement->m_lPlaceholderType > 0)
m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + _T("\""));
m_oWriter.WriteString(std::wstring(L" idx=\"") + string2std_string(strIdx) + _T("\"/></p:nvPr>"));
}
}
......@@ -604,17 +614,20 @@ void NSPresentationEditor::CShapeWriter::WriteShapeInfo()
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 (15 == m_pShapeElement->m_lPlaceholderType)
// m_pShapeElement->m_lPlaceholderID = -1;
//if (0 == m_pShapeElement->m_lPlaceholderType)
// m_pShapeElement->m_lPlaceholderID = 1;
if ( m_pShapeElement->m_lPlaceholderID < 0)
{
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"<p:nvPr><p:ph"));
if (m_pShapeElement->m_lPlaceholderType > 0)
m_oWriter.WriteString(std::wstring(L" 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\""));
......@@ -624,13 +637,18 @@ void NSPresentationEditor::CShapeWriter::WriteShapeInfo()
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><p:ph"));
if (m_pShapeElement->m_lPlaceholderType > 0)
m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pShapeElement->m_lPlaceholderType) + _T("\""));
m_oWriter.WriteString(std::wstring(L" 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>"));
}
......@@ -646,8 +664,6 @@ void NSPresentationEditor::CShapeWriter::WriteShapeInfo()
void NSPresentationEditor::CShapeWriter::WriteTextInfo()
{
size_t nCount = m_pShapeElement->m_oShape.m_oText.m_arParagraphs.size();
if (0x00 == (m_pShapeElement->m_oShape.m_lDrawType & c_ShapeDrawType_Text))
return;
m_oWriter.WriteString(std::wstring(L"<p:txBody>"));
......@@ -705,7 +721,10 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
}
m_oWriter.WriteString(std::wstring(L"<a:lstStyle>"));
CStylesWriter::ConvertStyles(m_pShapeElement->m_oShape.m_oText.m_oStyles, m_oMetricInfo, m_oWriter);
if (!m_bWordArt)
{
CStylesWriter::ConvertStyles(m_pShapeElement->m_oShape.m_oText.m_oStyles, m_oMetricInfo, m_oWriter);
}
m_oWriter.WriteString(std::wstring(L"</a:lstStyle>"));
......@@ -713,6 +732,12 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
{
NSPresentationEditor::CParagraph* pParagraph = &m_pShapeElement->m_oShape.m_oText.m_arParagraphs[nIndexPar];
if (m_bWordArt && nIndexPar == nCount-1)
{
if (pParagraph->m_arSpans.size() < 1) break;
if (pParagraph->m_arSpans.size() == 1 && pParagraph->m_arSpans[0].m_strText.empty()) break;
}
CString _str1 = _T("");
_str1.Format(_T("<a:p><a:pPr lvl=\"%d\""), pParagraph->m_lTextLevel);
m_oWriter.WriteString(_str1);
......@@ -838,17 +863,17 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
m_oWriter.WriteString(str);
}
}
if (pPF->bulletFontProperties.is_init())
{
m_oWriter.WriteString(std::wstring(L"<a:buFont typeface=\"") + pPF->bulletFontProperties->strFontName + _T("\"/>"));
}
wchar_t bu = 0x2022;
m_oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
if (pPF->bulletChar.is_init())
{
bu = pPF->bulletChar.get();
}
if (pPF->bulletFontProperties.is_init() && (unsigned short)bu < 0xFF) //??? 1 (91).ppt - windings + 0x2022 ????
{
m_oWriter.WriteString(std::wstring(L"<a:buFont typeface=\"") + pPF->bulletFontProperties->strFontName + _T("\"/>"));
}
m_oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
m_oWriter.WriteStringXML(std::wstring(&bu, 1));
m_oWriter.WriteString(std::wstring(L"\"/>"));
}
......@@ -1140,7 +1165,14 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
m_oWriter.WriteString(std::wstring(L"<a:prstGeom prst=\"rect\"/>"));
}
m_oWriter.WriteString(ConvertBrush(m_pShapeElement->m_oBrush));
if (m_bWordArt)
{
m_oWriter.WriteString(std::wstring(L"<a:noFill/>"));
}
else
{
m_oWriter.WriteString(ConvertBrush(m_pShapeElement->m_oBrush));
}
if (m_pShapeElement->m_bLine)
{
......@@ -1160,7 +1192,14 @@ CString NSPresentationEditor::CShapeWriter::ConvertShape()
CString NSPresentationEditor::CShapeWriter::ConvertImage()
{
if (m_pImageElement->m_bImagePresent == false) return _T("");
if (m_pImageElement->m_bImagePresent == false)
{
if (m_pImageElement->m_sName.empty()) return _T("");
//ppt_presentation.ppt -
m_pImageElement->m_strImageFileName.clear();
m_pImageElement->m_bImagePresent = true;
}
m_oWriter.WriteString(std::wstring(L"<p:pic>"));
......@@ -1177,7 +1216,15 @@ CString NSPresentationEditor::CShapeWriter::ConvertImage()
oInfo.m_lOriginalHeight = (LONG)m_pImageElement->m_rcBoundsOriginal.GetHeight();
m_oWriter.WriteString(std::wstring(L"<p:blipFill>"));
CString strRid = m_pRels->WriteImage(m_pImageElement->m_strImageFileName);
CString strRid;
if (m_pImageElement->m_strImageFileName.empty())
{
strRid = m_pRels->WriteHyperlinkImage(m_pImageElement->m_sName);
}
else
{
strRid = m_pRels->WriteImage(m_pImageElement->m_strImageFileName);
}
CString strWrite = _T("<a:blip r:embed=\"") + strRid + _T("\"/>");
......
......@@ -2,7 +2,6 @@
#include "../OfficeDrawing/Document.h"
#include "StylesWriter.h"
#include "ImageManager.h"
namespace NSPresentationEditor
......@@ -12,6 +11,7 @@ namespace NSPresentationEditor
switch (lType)
{
case 0: return _T("body");
case 100: return _T("body"); // master pages
case 1: return _T("chart");
case 2: return _T("clipArt");
case 3: return _T("ctrTitle");
......
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