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

PPTFormat автоподстановки + правка багов

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65724 954022d7-b5bf-4e40-9824-e11837661b57
parent 64b48af5
......@@ -42,7 +42,7 @@ public:
std::vector<CFont> m_arrFonts;
NSPresentationEditor::CTextStyles m_oDefaultTextStyle;
std::vector<std::wstring> m_PlaceholdersReplaceString[3]; //0-dates, 1 - headers, 2 - footers
vector_string m_PlaceholdersReplaceString[3]; //0-dates, 1 - headers, 2 - footers
bool m_bHasDate;
bool m_bHasSlideNumber;
......@@ -265,6 +265,6 @@ public:
IElement* AddNewThemePlaceholder (CTheme* pTheme, int placeholderType, int placeholderSizePreset = -1);
IElement* AddThemeLayoutPlaceholder (CLayout *pLayout, int placeholderType, CTheme* pTheme);
IElement* AddThemeLayoutPlaceholder (CLayout *pLayout, int placeholderType, CTheme* pTheme, bool idx_only = false);
IElement* AddLayoutSlidePlaceholder (CSlide *pSlide, int placeholderType, CLayout *pLayout, bool idx_only = false);
};
......@@ -154,8 +154,7 @@ class CRecordSlideNumberMetaAtom : public CRecordMetaCharacterAtom
class CRecordHeadersFootersContainer : public CRecordsContainer
{
public:
std::vector<std::wstring> m_HeadersFootersString[3]; //0-dates, 1 - headers, 2 - footers
vector_string m_HeadersFootersString[3]; //0-dates, 1 - headers, 2 - footers
CRecordHeadersFootersAtom *m_oHeadersFootersAtom;
......
......@@ -82,80 +82,7 @@ namespace NSPresentationEditor
public:
// layouts
void CalculateLayouts()
{
size_t nCountThemes = m_arThemes.size();
for (size_t i = 0; i < nCountThemes; ++i)
{
CTheme* pTheme = &m_arThemes[i];
size_t nCountLayouts = pTheme->m_arLayouts.size();
for (size_t j = 0; j < nCountLayouts; ++j)
{
CLayout* pLayout = &pTheme->m_arLayouts[j];
size_t nCountElements = pLayout->m_arElements.size();
for (size_t nElem = 0; nElem < nCountElements; ++nElem)
{
if (pLayout->m_bUseThemeColorScheme)
{
pLayout->m_arElements[nElem]->SetupProperties(NULL, &m_arThemes[i], NULL);
}
else
{
//pLayout->m_arElements[nElem]->SetupProperties(NULL, &m_arThemes[i], NULL);
}
}
}
}
}
//
void Calculate()
{
CalculateLayouts();
size_t nCount = m_arSlides.size();
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
{
int lThemeID = m_arSlides[nIndex]->m_lThemeID;
if ((0 > lThemeID) || (lThemeID >= (LONG)m_arThemes.size()))
{
m_arSlides[nIndex]->Calculate(NULL);
continue;
}
m_arSlides[nIndex]->Calculate(&m_arThemes[lThemeID]);
}
//
size_t nCountThemes = m_arThemes.size();
for (size_t i = 0; i < nCountThemes; ++i)
{
CTheme* pTheme = &m_arThemes[i];
size_t nCountEl = pTheme->m_arElements.size();
for (size_t j = 0; j < nCountEl; ++j)
{
pTheme->m_arElements[j]->m_pTheme = pTheme;
}
size_t nCountLayouts = pTheme->m_arLayouts.size();
for (size_t j = 0; j < nCountLayouts; ++j)
{
CLayout* pLayout = &pTheme->m_arLayouts[j];
nCountEl = pLayout->m_arElements.size();
for (size_t k = 0; k < nCountEl; ++k)
{
pLayout->m_arElements[k]->m_pTheme = pTheme;
}
}
}
}
CString GetXmlSlideTransition ( CSlide& oSlide/*, CAudioOverlay& oAudioOverlay*/ )
{
CString Source = CString ( _T("") );
......@@ -529,9 +456,35 @@ namespace NSPresentationEditor
}
public:
void ResetAutoText(IElement *pElement, vector_string const (&placeholdersReplaceString)[3])
{
CShapeElement* pShape = dynamic_cast<CShapeElement*>(pElement);
if (NULL == pShape) return;
if (pElement->m_lPlaceholderType == NSOfficePPT::MasterSlideNumber) pShape->SetUpTextPlaceholder(L"<#>");
int ind = -1;
if (pElement->m_lPlaceholderType == NSOfficePPT::MasterDate) ind = 0;
if (pElement->m_lPlaceholderType == NSOfficePPT::MasterFooter) ind = 2;
if (pElement->m_lPlaceholderUserStr >= 0 && ind >= 0)
{
if (pElement->m_lPlaceholderUserStr < placeholdersReplaceString[ind].size())
pShape->SetUpTextPlaceholder( placeholdersReplaceString[ind][pElement->m_lPlaceholderUserStr] );
else pShape->SetUpTextPlaceholder(L"");
}
else
{
if (pElement->m_lPlaceholderType == NSOfficePPT::MasterDate)
pShape->SetUpTextPlaceholder(L"*"); //
}
}
void CalculateEditor(const NSPresentationEditor::CMetricInfo& oInfo, bool bIsPlaceholderSetUp = false)
{
//
m_oInfo = oInfo;
double dScaleX = (double)m_oInfo.m_lMillimetresHor / m_oInfo.m_lUnitsHor;
......@@ -548,6 +501,10 @@ namespace NSPresentationEditor
{
IElement* pElement = pTheme->m_arElements[nIndexEl];
if (pElement->m_lPlaceholderType > 0)
{
ResetAutoText(pElement, pTheme->m_PlaceholdersReplaceString);
}
pElement->m_pTheme = pTheme;
pElement->m_pLayout = NULL;
......@@ -571,6 +528,11 @@ namespace NSPresentationEditor
for (size_t nIndexLayoutEl = 0; nIndexLayoutEl < nCountLayoutElements; ++nIndexLayoutEl)
{
IElement* pElement = pLayout->m_arElements[nIndexLayoutEl];
if (pElement->m_lPlaceholderType > 0)
{
ResetAutoText(pElement, pLayout->m_PlaceholdersReplaceString);
}
pElement->m_oMetric = m_oInfo;
pElement->NormalizeCoords(dScaleX, dScaleY);
......@@ -651,6 +613,10 @@ namespace NSPresentationEditor
{
IElement* pElement = pSlide->m_arElements[nIndexEl];
if (pElement->m_lPlaceholderType > 0)
{
ResetAutoText(pElement, pSlide->m_PlaceholdersReplaceString);
}
pElement->m_pTheme = pTheme;
pElement->m_pLayout = pLayout;
......@@ -663,7 +629,5 @@ namespace NSPresentationEditor
pSlide->SetUpPlaceholderStyles(pLayout);
}
}
};
}
......@@ -267,8 +267,9 @@ namespace NSPresentationEditor
pDublicate->m_lPlaceholderID = m_lPlaceholderID;
pDublicate->m_lPlaceholderType = m_lPlaceholderType;
pDublicate->m_bPlaceholderSet = m_bPlaceholderSet;
pDublicate->m_lPlaceholderSizePreset = m_lPlaceholderSizePreset;
pDublicate->m_lPlaceholderUserStr = m_lPlaceholderUserStr;
pDublicate->m_lPlaceholderUserStr = m_lPlaceholderUserStr;
pDublicate->m_nFormatDate = m_nFormatDate;
pDublicate->m_oMetric = m_oMetric;
......
......@@ -94,15 +94,28 @@ bool NSPresentationEditor::CShapeElement::SetUpTextPlaceholder(std::wstring newT
bool result = false;
NSPresentationEditor::CTextAttributesEx* pText = &m_oShape.m_oText;
if (pText->m_arParagraphs.size() > 0)
for (int p = 0 ; p < pText->m_arParagraphs.size(); p++) //тут по всем -> 1-(33).ppt
{
if (pText->m_arParagraphs[0].m_arSpans.size() >0)
if (pText->m_arParagraphs[p].m_arSpans.size() >0)//??? по всем?
{
int pos = pText->m_arParagraphs[0].m_arSpans[0].m_strText.find(L"*");
int pos = pText->m_arParagraphs[p].m_arSpans[0].m_strText.find(L"*");
if (pos >= 0)
{
ReplaceAll(pText->m_arParagraphs[0].m_arSpans[0].m_strText, L"*", newText);
CSpan first = pText->m_arParagraphs[p].m_arSpans[0];
CSpan last = pText->m_arParagraphs[p].m_arSpans[0];
first.m_strText = pText->m_arParagraphs[p].m_arSpans[0].m_strText.substr(0, pos);
last.m_strText = pText->m_arParagraphs[p].m_arSpans[0].m_strText.substr(pos + 1);
pText->m_arParagraphs[p].m_arSpans[0].m_strText = newText;
pText->m_arParagraphs[p].m_arSpans[0].m_bField = true;
if (last.m_strText.empty() == false)
pText->m_arParagraphs[p].m_arSpans.insert(pText->m_arParagraphs[p].m_arSpans.begin() + 1, last);
if (first.m_strText.empty() == false)
pText->m_arParagraphs[p].m_arSpans.insert(pText->m_arParagraphs[p].m_arSpans.begin(), first);
result = true;
}
}
......
......@@ -29,6 +29,7 @@ namespace NSPresentationEditor
bool m_bHasSlideNumber;
bool m_bHasFooter;
int m_nFormatDate;
vector_string m_PlaceholdersReplaceString[3]; //0-dates, 1 - headers, 2 - footers
bool m_bShowMasterShapes;
std::wstring m_strLayoutType;
......@@ -76,6 +77,8 @@ namespace NSPresentationEditor
m_bHasFooter = oSrc.m_bHasFooter;
m_nFormatDate = oSrc.m_nFormatDate;
for (int i = 0 ; i < 3 ; i++) m_PlaceholdersReplaceString[i] = oSrc.m_PlaceholdersReplaceString[i];
m_bShowMasterShapes = oSrc.m_bShowMasterShapes;
m_strLayoutType = oSrc.m_strLayoutType;
......@@ -109,6 +112,7 @@ namespace NSPresentationEditor
m_bHasSlideNumber = false;
m_bHasFooter = false;
m_nFormatDate = 1;
for (int i = 0 ; i < 3 ; i++) m_PlaceholdersReplaceString[i].clear();
m_bUseThemeColorScheme = true;
m_bShowMasterShapes = true;
......
......@@ -35,11 +35,7 @@ namespace NSPresentationEditor
CMetricInfo m_oInfo;
bool m_bHasDate;
bool m_bHasSlideNumber;
bool m_bHasFooter;
int m_nFormatDate;
vector_string m_PlaceholdersReplaceString[3];
std::wstring m_strComment;
std::wstring m_sName;
public:
......@@ -75,15 +71,11 @@ namespace NSPresentationEditor
m_dEndTime = 0.0;
m_dDuration = 30000.0;
m_bHasDate = false;
m_bHasSlideNumber = false;
m_bHasFooter = false;
m_nFormatDate = 1;
m_bShowMasterShapes = true;
m_strComment.clear();
m_sName.clear();
for (int i = 0 ; i < 3 ; i++) m_PlaceholdersReplaceString[i].clear();
}
CSlide(const CSlide& oSrc)
......@@ -118,62 +110,13 @@ namespace NSPresentationEditor
m_bShowMasterShapes = oSrc.m_bShowMasterShapes;
m_bHasDate = oSrc.m_bHasDate;
m_bHasSlideNumber = oSrc.m_bHasSlideNumber;
m_bHasFooter = oSrc.m_bHasFooter;
m_nFormatDate = oSrc.m_nFormatDate;
for (int i = 0 ; i < 3 ; i++) m_PlaceholdersReplaceString[i] = oSrc.m_PlaceholdersReplaceString[i];
m_strComment = oSrc.m_strComment;
m_sName = oSrc.m_sName;
}
public:
void Calculate(CTheme* pTheme)
{
CLayout* pLayout = NULL;
if (NULL != pTheme)
{
if ((0 <= m_lLayoutID) && (m_lLayoutID < (LONG)pTheme->m_arLayouts.size()))
{
pLayout = &pTheme->m_arLayouts[m_lLayoutID];
}
}
//
size_t nCount = m_arElements.size();
for (size_t i = 0; i < nCount; ++i)
{
CalculateElement(i, pTheme, pLayout);
m_arElements[i]->m_pTheme = pTheme;
}
}
void CalculateElement(size_t nIndexElement, CTheme* pTheme, CLayout* pLayout)
{
IElement* pElement = m_arElements[nIndexElement];
if (NULL == pElement)
return;
LONG lPlaceholderID = pElement->m_lPlaceholderType;
if (-1 == lPlaceholderID)
{
//pElement->SetupProperties(pTheme, pColorScheme);
m_arElements[nIndexElement]->SetupProperties(this, pTheme, pLayout);
return;
}
IElement* pLayoutElem = pLayout->GetPlaceholder(lPlaceholderID, FALSE);
if (NULL == pLayoutElem)
{
m_arElements[nIndexElement]->SetupProperties(this, pTheme, pLayout);
return;
}
m_arElements[nIndexElement]->SetupProperties(this, pTheme, pLayout);
}
void SetMetricInfo(const CMetricInfo& oInfo)
{
m_oInfo = oInfo;
......
......@@ -4,6 +4,8 @@
#define GETBIT(from, num) ((from & (1 << num)) != 0)
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
typedef std::vector<std::wstring> vector_string;
namespace NSPresentationEditor
{
static void CorrectColorPPT(LONG& lSchemeIndex)
......
......@@ -601,9 +601,9 @@ namespace NSPresentationEditor
public:
CTextCFRun m_oRun;
std::wstring m_strText;
bool m_bField;
public:
CSpan() : m_oRun(), m_strText(_T(""))
CSpan() : m_oRun(), m_strText(_T("")), m_bField(false)
{
}
CSpan(const CSpan& oSrc)
......@@ -614,6 +614,7 @@ namespace NSPresentationEditor
{
m_oRun = oSrc.m_oRun;
m_strText = oSrc.m_strText;
m_bField = oSrc.m_bField;
return *this;
}
......
......@@ -44,7 +44,7 @@ namespace NSPresentationEditor
int m_nFormatDate;//1- current, 2 - user
std::vector<std::wstring> m_PlaceholdersReplaceString[3]; //0-dates, 1 - headers, 2 - footers
vector_string m_PlaceholdersReplaceString[3]; //0-dates, 1 - headers, 2 - footers
//------------------------------------------------------------------------------------
CTheme() : m_arColorScheme(), m_arFonts(), m_arBrushes(),
......@@ -76,6 +76,8 @@ namespace NSPresentationEditor
m_bHasFooter = oSrc.m_bHasFooter;
m_nFormatDate = oSrc.m_nFormatDate;
for (int i = 0 ; i < 3 ; i++) m_PlaceholdersReplaceString[i] = oSrc.m_PlaceholdersReplaceString[i];
for (int i = 0; i < oSrc.m_arExtraColorScheme.size(); ++i)
{
m_arExtraColorScheme.push_back(oSrc.m_arExtraColorScheme[i]);
......@@ -153,6 +155,8 @@ namespace NSPresentationEditor
m_bHasSlideNumber = false;
m_bHasFooter = false;
m_nFormatDate = 1;
for (int i = 0 ; i < 3 ; i++) m_PlaceholdersReplaceString[i].clear();
}
~CTheme()
......
......@@ -947,11 +947,11 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
}
else
{
if (m_pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber)
if (m_pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber && pParagraph->m_arSpans[nSpan].m_bField)
{
m_oWriter.WriteString(std::wstring(L"<a:fld id=\"{D038279B-FC19-497E-A7D1-5ADD9CAF016F}\" type=\"slidenum\"><a:rPr"));
}
else if (m_pShapeElement->m_lPlaceholderType == PT_MasterDate && m_pShapeElement->m_nFormatDate == 1)
else if (m_pShapeElement->m_lPlaceholderType == PT_MasterDate && m_pShapeElement->m_nFormatDate == 1 && pParagraph->m_arSpans[nSpan].m_bField)
{
m_oWriter.WriteString(std::wstring(L"<a:fld id=\"{D7E01130-044F-4930-9A27-C729C70D8524}\" type=\"datetime1\"><a:rPr"));
}
......@@ -1066,8 +1066,8 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
CString strT2 = _T("</a:t>");
m_oWriter.WriteString(strT2);
if (m_pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber ||
(m_pShapeElement->m_lPlaceholderType == PT_MasterDate && m_pShapeElement->m_nFormatDate == 1))
if ((m_pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber ||
(m_pShapeElement->m_lPlaceholderType == PT_MasterDate && m_pShapeElement->m_nFormatDate == 1)) && pParagraph->m_arSpans[nSpan].m_bField)
{
m_oWriter.WriteString(std::wstring(L"</a:fld>"));
}
......
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