mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-16 01:57:36 +08:00
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58863 954022d7-b5bf-4e40-9824-e11837661b57
231 lines
6.7 KiB
C++
231 lines
6.7 KiB
C++
#pragma once
|
|
#include "Structures.h"
|
|
#include "Layout.h"
|
|
#include "../PPTXWriter/CSS.h"
|
|
|
|
namespace NSPresentationEditor
|
|
{
|
|
const long g_ThemeTextStylesCount = 4;
|
|
|
|
class CTheme : public IBase
|
|
{
|
|
public:
|
|
std::vector<CColor> m_arColorScheme;
|
|
std::vector<CFont> m_arFonts;
|
|
std::vector<CBrush> m_arBrushes;
|
|
std::vector<CPen> m_arPens;
|
|
|
|
std::vector<CEffects> m_arEffects;
|
|
CTextStyles m_pStyles[g_ThemeTextStylesCount];
|
|
std::vector<CLayout> m_arLayouts;
|
|
|
|
bool m_bIsBackground;
|
|
CBrush m_oBackground;
|
|
|
|
std::vector<IElement*> m_arElements;
|
|
|
|
CMetricInfo m_oInfo;
|
|
|
|
public:
|
|
CTheme() : m_arColorScheme(), m_arFonts(), m_arBrushes(),
|
|
m_arPens(), m_arEffects(), m_arLayouts()
|
|
{
|
|
}
|
|
|
|
CTheme(const CTheme& oSrc)
|
|
{
|
|
*this = oSrc;
|
|
}
|
|
|
|
CTheme& operator=(const CTheme& oSrc)
|
|
{
|
|
m_arColorScheme.insert (m_arColorScheme.end(), oSrc.m_arColorScheme.begin(), oSrc.m_arColorScheme.end());
|
|
m_arFonts.insert (m_arFonts.end(), oSrc.m_arFonts.begin(), oSrc.m_arFonts.end());
|
|
m_arBrushes.insert (m_arBrushes.end(), oSrc.m_arBrushes.begin(), oSrc.m_arBrushes.end());
|
|
m_arPens.insert (m_arPens.end(), oSrc.m_arPens.begin(), oSrc.m_arPens.end());
|
|
m_arEffects.insert (m_arEffects.end(), oSrc.m_arEffects.begin(), oSrc.m_arEffects.end());
|
|
|
|
for (int i = 0; i < g_ThemeTextStylesCount; ++i)
|
|
m_pStyles[i] = oSrc.m_pStyles[i];
|
|
|
|
m_arLayouts.insert(m_arLayouts.end(), oSrc.m_arLayouts.begin(), oSrc.m_arLayouts.end());
|
|
|
|
m_bIsBackground = oSrc.m_bIsBackground;
|
|
m_oBackground = oSrc.m_oBackground;
|
|
|
|
// òåïåðü ñäåëàåì êîïèþ âñåõ ýëåìåíòîâ layout'îâ
|
|
size_t nCount = m_arLayouts.size();
|
|
for (size_t i = 0; i < nCount; ++i)
|
|
{
|
|
m_arLayouts[i].CreateDublicateElements();
|
|
}
|
|
|
|
Clear();
|
|
m_arElements.insert(m_arElements.end(), oSrc.m_arElements.begin(), oSrc.m_arElements.end());
|
|
|
|
nCount = m_arElements.size();
|
|
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
|
{
|
|
ADDREFINTERFACE((m_arElements[nIndex]));
|
|
}
|
|
CreateDublicateElements();
|
|
|
|
for (long nIndexStyle = 0; nIndexStyle < g_ThemeTextStylesCount; ++nIndexStyle)
|
|
{
|
|
m_pStyles[nIndexStyle] = oSrc.m_pStyles[nIndexStyle];
|
|
}
|
|
|
|
return (*this);
|
|
}
|
|
|
|
void CreateDublicateElements()
|
|
{
|
|
// ïðîñòî èç âñåõ ñâîèõ ýëåìåíòîâ äåëàåì äóáëèêàòà
|
|
size_t nCount = m_arElements.size();
|
|
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
|
{
|
|
IElement* pElem = m_arElements[nIndex];
|
|
if (NULL != pElem)
|
|
{
|
|
m_arElements[nIndex] = pElem->CreateDublicate();
|
|
}
|
|
RELEASEINTERFACE(pElem);
|
|
}
|
|
}
|
|
|
|
void Clear()
|
|
{
|
|
size_t nCount = m_arElements.size();
|
|
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
|
{
|
|
RELEASEINTERFACE((m_arElements[nIndex]));
|
|
}
|
|
|
|
m_arElements.clear();
|
|
}
|
|
|
|
~CTheme()
|
|
{
|
|
}
|
|
|
|
public:
|
|
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode);
|
|
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
|
|
{
|
|
}
|
|
|
|
CString ToXmlEditor(const CMetricInfo& oInfo);
|
|
|
|
NSPresentationEditor::CColor GetColor(const LONG& lIndexScheme)
|
|
{
|
|
if (lIndexScheme < (LONG)m_arColorScheme.size())
|
|
{
|
|
return m_arColorScheme[lIndexScheme];
|
|
}
|
|
return NSPresentationEditor::CColor();
|
|
}
|
|
|
|
void CalculateStyles()
|
|
{
|
|
LONG lCountColors = (LONG)m_arColorScheme.size();
|
|
|
|
// ïîêà çäåñü ðàñ÷èòûâàþòñÿ òîëüêî öâåòà
|
|
for (int pos = 0; pos < g_ThemeTextStylesCount; ++pos)
|
|
{
|
|
NSPresentationEditor::CTextStyles& oStyle = m_pStyles[pos];
|
|
|
|
size_t nLevels = 10;
|
|
for (size_t i = 0; i < nLevels; ++i)
|
|
{
|
|
if (!oStyle.m_pLevels[i].is_init())
|
|
continue;
|
|
|
|
CTextStyleLevel* pLevel = oStyle.m_pLevels[i].operator ->();
|
|
|
|
if (pLevel->m_oPFRun.bulletColor.is_init())
|
|
{
|
|
CColor& oColor = pLevel->m_oPFRun.bulletColor.get();
|
|
if ((0 <= oColor.m_lSchemeIndex) && (oColor.m_lSchemeIndex < lCountColors))
|
|
{
|
|
oColor.R = m_arColorScheme[oColor.m_lSchemeIndex].R;
|
|
oColor.G = m_arColorScheme[oColor.m_lSchemeIndex].G;
|
|
oColor.B = m_arColorScheme[oColor.m_lSchemeIndex].B;
|
|
oColor.A = m_arColorScheme[oColor.m_lSchemeIndex].A;
|
|
}
|
|
}
|
|
if (pLevel->m_oCFRun.Color.is_init())
|
|
{
|
|
CColor& oColor = pLevel->m_oCFRun.Color.get();
|
|
if ((0 <= oColor.m_lSchemeIndex) && (oColor.m_lSchemeIndex < lCountColors))
|
|
{
|
|
oColor.R = m_arColorScheme[oColor.m_lSchemeIndex].R;
|
|
oColor.G = m_arColorScheme[oColor.m_lSchemeIndex].G;
|
|
oColor.B = m_arColorScheme[oColor.m_lSchemeIndex].B;
|
|
oColor.A = m_arColorScheme[oColor.m_lSchemeIndex].A;
|
|
}
|
|
}
|
|
if (pLevel->m_oCFRun.Typeface.IsInit())
|
|
{
|
|
WORD lFontIndex = pLevel->m_oCFRun.Typeface.get();
|
|
if (lFontIndex < (WORD)m_arFonts.size())
|
|
{
|
|
if (!pLevel->m_oCFRun.FontProperties.is_init())
|
|
pLevel->m_oCFRun.FontProperties = new CFontProperties();
|
|
|
|
pLevel->m_oCFRun.FontProperties->SetFont(m_arFonts[lFontIndex]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static void CalculateStyle(CTheme* pTheme, CTextStyles& oStyle)
|
|
{
|
|
LONG lCountColors = (LONG)pTheme->m_arColorScheme.size();
|
|
|
|
// ïîêà çäåñü ðàñ÷èòûâàþòñÿ òîëüêî öâåòà
|
|
size_t nLevels = 10;
|
|
for (size_t i = 0; i < nLevels; ++i)
|
|
{
|
|
if (!oStyle.m_pLevels[i].is_init())
|
|
continue;
|
|
|
|
CTextStyleLevel* pLevel = oStyle.m_pLevels[i].operator ->();
|
|
|
|
if (pLevel->m_oPFRun.bulletColor.is_init())
|
|
{
|
|
CColor& oColor = pLevel->m_oPFRun.bulletColor.get();
|
|
if ((0 <= oColor.m_lSchemeIndex) && (oColor.m_lSchemeIndex < lCountColors))
|
|
{
|
|
oColor.R = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].R;
|
|
oColor.G = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].G;
|
|
oColor.B = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].B;
|
|
oColor.A = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].A;
|
|
}
|
|
}
|
|
if (pLevel->m_oCFRun.Color.is_init())
|
|
{
|
|
CColor& oColor = pLevel->m_oCFRun.Color.get();
|
|
if ((0 <= oColor.m_lSchemeIndex) && (oColor.m_lSchemeIndex < lCountColors))
|
|
{
|
|
oColor.R = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].R;
|
|
oColor.G = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].G;
|
|
oColor.B = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].B;
|
|
oColor.A = pTheme->m_arColorScheme[oColor.m_lSchemeIndex].A;
|
|
}
|
|
}
|
|
if (pLevel->m_oCFRun.Typeface.IsInit())
|
|
{
|
|
WORD lFontIndex = pLevel->m_oCFRun.Typeface.get();
|
|
if (lFontIndex < (WORD)pTheme->m_arFonts.size())
|
|
{
|
|
if (!pLevel->m_oCFRun.FontProperties.is_init())
|
|
pLevel->m_oCFRun.FontProperties = new CFontProperties();
|
|
|
|
pLevel->m_oCFRun.FontProperties->SetFont(pTheme->m_arFonts[lFontIndex]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
} |