mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-11 06:22:44 +08:00
124 lines
4.1 KiB
C++
124 lines
4.1 KiB
C++
|
|
#include "Slide.h"
|
|
|
|
void NSPresentationEditor::CShapeElement::CalculateColor(CColor& oColor, CSlide* pSlide, CTheme* pTheme, CLayout* pLayout)
|
|
{
|
|
LONG lOldIndex = oColor.m_lSchemeIndex;
|
|
if (-1 == oColor.m_lSchemeIndex)
|
|
return;
|
|
|
|
std::vector<CColor>* pArray = NULL;
|
|
|
|
if (pTheme) pArray = &pTheme->m_arColorScheme;
|
|
|
|
if ((NULL != pLayout) && (!pLayout->m_bUseThemeColorScheme))
|
|
pArray = &pLayout->m_arColorScheme;
|
|
|
|
if (NULL != pSlide)
|
|
{
|
|
if (!pSlide->m_bUseLayoutColorScheme)
|
|
pArray = &pSlide->m_arColorScheme;
|
|
}
|
|
|
|
if ((0 > oColor.m_lSchemeIndex) || ((pArray) && (oColor.m_lSchemeIndex >= (LONG)pArray->size())))
|
|
return;
|
|
|
|
if (pArray)
|
|
{
|
|
oColor = pArray->at(oColor.m_lSchemeIndex);
|
|
}
|
|
oColor.m_lSchemeIndex = lOldIndex;
|
|
}
|
|
|
|
void NSPresentationEditor::CShapeElement::SetupTextProperties(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout)
|
|
{
|
|
NSPresentationEditor::CTextAttributesEx* pAttributes = &m_oShape.m_oText;
|
|
int nCountColors = 0;
|
|
if (NULL != pTheme)
|
|
nCountColors = (int)pTheme->m_arColorScheme.size();
|
|
|
|
size_t nCount = pAttributes->m_arParagraphs.size();
|
|
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
|
{
|
|
if (pAttributes->m_arParagraphs[nIndex].m_oPFRun.bulletColor.is_init())
|
|
{
|
|
int nColorIndex = (int)pAttributes->m_arParagraphs[nIndex].m_oPFRun.bulletColor->m_lSchemeIndex;
|
|
if (0 <= nColorIndex && nColorIndex < nCountColors)
|
|
{
|
|
CalculateColor(pAttributes->m_arParagraphs[nIndex].m_oPFRun.bulletColor.get(), pSlide, pTheme, pLayout);
|
|
pAttributes->m_arParagraphs[nIndex].m_oPFRun.bulletColor->m_lSchemeIndex = nColorIndex;
|
|
}
|
|
}
|
|
|
|
size_t nCountCFs = pAttributes->m_arParagraphs[nIndex].m_arSpans.size();
|
|
for (size_t i = 0; i < nCountCFs; ++i)
|
|
{
|
|
CTextCFRun* pRun = &pAttributes->m_arParagraphs[nIndex].m_arSpans[i].m_oRun;
|
|
|
|
if (pRun->Color.is_init())
|
|
{
|
|
int nColorIndex = (int)pRun->Color->m_lSchemeIndex;
|
|
if (0 <= nColorIndex && nColorIndex < nCountColors)
|
|
{
|
|
CalculateColor(pRun->Color.get(), pSlide, pTheme, pLayout);
|
|
pRun->Color->m_lSchemeIndex = nColorIndex;
|
|
}
|
|
}
|
|
if (NULL != pTheme)
|
|
{
|
|
if ((pRun->Typeface.is_init()) && (pRun->Typeface.get() < pTheme->m_arFonts.size()))
|
|
{
|
|
pRun->FontProperties = new CFontProperties();
|
|
pRun->FontProperties->SetFont(pTheme->m_arFonts[pRun->Typeface.get()]);
|
|
|
|
if (1 < pRun->Typeface.get())
|
|
pRun->Typeface.reset();
|
|
}
|
|
if ((pRun->EAFontRef.is_init()) && (pRun->EAFontRef.get() < pTheme->m_arFonts.size()))
|
|
{
|
|
pRun->FontPropertiesEA = new CFontProperties();
|
|
pRun->FontPropertiesEA->SetFont(pTheme->m_arFonts[pRun->EAFontRef.get()]);
|
|
}
|
|
if ((pRun->SymbolFontRef.is_init()) && (pRun->SymbolFontRef.get() < pTheme->m_arFonts.size()))
|
|
{
|
|
pRun->FontPropertiesSym = new CFontProperties();
|
|
pRun->FontPropertiesSym->SetFont(pTheme->m_arFonts[pRun->SymbolFontRef.get()]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool NSPresentationEditor::CShapeElement::SetUpTextPlaceholder(std::wstring newText)
|
|
{
|
|
bool result = false;
|
|
NSPresentationEditor::CTextAttributesEx* pText = &m_oShape.m_oText;
|
|
|
|
for (int p = 0 ; p < pText->m_arParagraphs.size(); p++) //тут по всем -> 1-(33).ppt
|
|
{
|
|
if (pText->m_arParagraphs[p].m_arSpans.size() >0)//??? по всем?
|
|
{
|
|
int pos = pText->m_arParagraphs[p].m_arSpans[0].m_strText.find(L"*");
|
|
|
|
if (pos >= 0)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
} |