Commit 73a1a6d2 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

PPTFormat

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65607 954022d7-b5bf-4e40-9824-e11837661b57
parent 531253c5
......@@ -1549,15 +1549,9 @@ void CPPTUserInfo::CreateDefaultStyle(NSPresentationEditor::CTextStyles& pStyle,
NSPresentationEditor::CTextCFRun* pCF = &pStyle.m_pLevels[i]->m_oCFRun;
pCF->Language = m_wLanguage;
//---------------------------------------- ?????????
pCF->FontBold = false;
pCF->FontItalic = false;
pCF->FontUnderline = false;
pCF->FontStrikeout = false;
pCF->Size = 18;
pCF->BaseLineOffset = 0.;
//-------------------------------------------
pCF->FontProperties = new NSPresentationEditor::CFontProperties();
pCF->FontProperties->SetFont(pTheme->m_arFonts[0]);
}
......
......@@ -316,15 +316,21 @@ void CTextPFRun_ppt::LoadFromStream(POLE::Stream* pStream, bool bIsIndentation)
{
m_oRun.bulletFontRef = StreamUtils::ReadWORD(pStream);
if ((bulletFlag & 0x0F) && !(0x02 == (bulletFlag & 0x02)))
m_oRun.bulletFontRef.reset();
if (bulletFlag & 0x0F)
{
if (!(0x02 == (bulletFlag & 0x02)))
m_oRun.bulletFontRef.reset();
}
}
if (bulletSize_)
{
m_oRun.bulletSize = StreamUtils::ReadWORD(pStream);
//if ((bulletFlag & 0x0F) && !(0x08 == (bulletFlag & 0x08)))
// m_oRun.bulletSize.reset();
if (bulletFlag & 0x0F)
{
if (!(0x08 == (bulletFlag & 0x08)))
m_oRun.bulletSize.reset();
}
}
if (bulletColor_)
{
......@@ -339,30 +345,24 @@ void CTextPFRun_ppt::LoadFromStream(POLE::Stream* pStream, bool bIsIndentation)
oColor.A = 255;
oColor.m_lSchemeIndex = -1;
//if (oColorAtom.Index < 64 && oColorAtom.bPaletteIndex) 1-(23).ppt
//{
// oColor = NSPresentationEditor::GetStandartPaletteColor(oColorAtom.Index);
//}
if (oColorAtom.Index < 10 && oColorAtom.bSchemeIndex)
if (oColorAtom.bSchemeIndex)
{
oColor.m_lSchemeIndex = oColorAtom.Index;
NSPresentationEditor::CorrectColorPPT(oColor.m_lSchemeIndex);
}
m_oRun.bulletColor = oColor;
//if ((bulletFlag & 0x0F) && !(0x04 == (bulletFlag & 0x04)))
// m_oRun.bulletColor.reset();
if (oColorAtom.bSchemeIndex || oColorAtom.bPaletteRGB)
{
m_oRun.bulletColor = oColor;
if (bulletFlag & 0x0F)
{
if (!(0x04 == (bulletFlag & 0x04)))
m_oRun.bulletColor.reset();
}
}
}
//if (/*((m_oRun.hasBullet.is_init()) && (m_oRun.hasBullet.get() == false)) ||*/ !m_oRun.hasBullet.is_init())
//{
// m_oRun.bulletColor.reset();
// m_oRun.bulletSize.reset();
// m_oRun.bulletFontRef.reset();
// m_oRun.bulletChar.reset();
//}
if (textAlignment_)
m_oRun.textAlignment = StreamUtils::ReadWORD(pStream);
......@@ -499,20 +499,15 @@ void CTextCFRun_ppt::LoadFromStream(POLE::Stream* pStream, bool bIsIndentation)
oColor.A = 255;
oColor.m_lSchemeIndex = -1;
//if (oColorAtom.Index < 64 && oColorAtom.bPaletteIndex && !oColorAtom.bPaletteRGB)
//{
// oColor = NSPresentationEditor::GetStandartPaletteColor(oColorAtom.Index);
//}
if (oColorAtom.Index < 10 && oColorAtom.bSchemeIndex)
if (oColorAtom.Index < 8 && oColorAtom.bSchemeIndex)
{
oColor.m_lSchemeIndex = oColorAtom.Index;
NSPresentationEditor::CorrectColorPPT(oColor.m_lSchemeIndex);
}
else
if (oColorAtom.bSchemeIndex || oColorAtom.bPaletteRGB)
{
m_oRun.Color = oColor;
}
m_oRun.Color = oColor;
}
if (BaseLineOffset_)
......
......@@ -328,11 +328,13 @@ namespace NSStreamReader
oAtom.B = StreamUtils::ReadBYTE(pStream);
oAtom.Index = StreamUtils::ReadBYTE(pStream);
oAtom.bPaletteIndex = (0x01 == (oAtom.Index & 0x01));
oAtom.bPaletteRGB = (0x02 == (oAtom.Index & 0x02));
oAtom.bSystemRGB = (0x04 == (oAtom.Index & 0x04));
oAtom.bSchemeIndex = (0x08 == (oAtom.Index & 0x08));
oAtom.bSysIndex = (0x10 == (oAtom.Index & 0x10));
oAtom.bPaletteIndex = oAtom.bPaletteRGB = oAtom.bSystemRGB = oAtom.bSysIndex = oAtom.bSchemeIndex = false;
if (oAtom.Index != 0xFF)
{
oAtom.bPaletteRGB = (oAtom.Index == 0xFE);
oAtom.bSchemeIndex = (oAtom.Index != 0xFE);
}
}
void Read(POLE::Stream* pStream, NSPresentationEditor::CTextSIRun& oRun, bool bIsIndentation = true);
......
......@@ -2060,7 +2060,7 @@ protected:
}
else
{
pTextSettings->m_lStyleThemeIndex = 0;
pTextSettings->m_lStyleThemeIndex = 0; //???
}
// (persist own) - m_oStyles
......
......@@ -64,37 +64,26 @@ void NSPresentationEditor::CShapeElement::SetupTextProperties(CSlide* pSlide, CT
pRun->Color->m_lSchemeIndex = nColorIndex;
}
}
if (pRun->Typeface.is_init() && (NULL != pTheme))
if (NULL != pTheme)
{
if (pRun->Typeface.get() < pTheme->m_arFonts.size())
if ((pRun->Typeface.is_init()) && (pRun->Typeface.get() < pTheme->m_arFonts.size()))
{
CFont* pFont = &(pTheme->m_arFonts[pRun->Typeface.get()]);
pRun->FontProperties = new CFontProperties();
// font name
pRun->FontProperties->strFontName = pFont->Name;
// charset
pRun->FontProperties->arFontCharsets.clear();
pRun->FontProperties->arFontCharsets.push_back(pFont->Charset);
// pitchfamily
pRun->FontProperties->strPitchFamily = pFont->PitchFamily;
// font panose
pRun->FontProperties->strPanose = pFont->Panose;
// font fixed
pRun->FontProperties->lFontFixed = -1;
pRun->FontProperties->SetFont(pTheme->m_arFonts[pRun->Typeface.get()]);
if (1 < pRun->Typeface.get())
pRun->Typeface.reset();
}
/*if (m_arCFs[nIndex].fontEAFontRef < pContainer->m_pFonts->size())
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()))
{
m_arCFs[nIndex].strFontName = (*(pContainer->m_pFonts))[m_arCFs[nIndex].fontEAFontRef].m_strFontName;
}*/
pRun->FontPropertiesSym = new CFontProperties();
pRun->FontPropertiesSym->SetFont(pTheme->m_arFonts[pRun->SymbolFontRef.get()]);
}
}
}
}
......
......@@ -57,7 +57,7 @@ namespace NSPresentationEditor
m_lPlaceholderType = -1;
m_lPlaceholderID = -1;
m_lStyleThemeIndex = 0;//default
m_lStyleThemeIndex = -1;
m_lFontRef = -1;
m_bIsSlideFontRef = false;
......
......@@ -128,11 +128,12 @@ namespace NSPresentationEditor
NSCommon::nullable_base<CColor> Color; // text color
NSCommon::nullable_base<WORD> Size; // font size
NSCommon::nullable_base<WORD> Cap; // 0 - none, 1 - TEXT, 2 - text
NSCommon::nullable_base<WORD> Language;
NSCommon::nullable_base<CFontProperties> FontProperties;
NSCommon::nullable_base<WORD> Language;
NSCommon::nullable_base<CFontProperties> FontPropertiesEA;
NSCommon::nullable_base<CFontProperties> FontPropertiesSym;
public:
......@@ -236,100 +237,6 @@ namespace NSPresentationEditor
Language = oSrc.Language;
}
CString ToString(LONG lCount)
{
NSPresentationEditor::CXmlWriter oWriter;
oWriter.WriteNodeBegin(_T("Character"), true);
oWriter.WriteAttributeLONG(_T("count"), lCount);
oWriter.WriteNodeEnd(_T("Character"), true, false);
oWriter.WriteNodeBegin(_T("Attributes"));
int nBold = 0;
int nItalic = 0;
CString strXml = _T("");
if (FontBold.is_init())
{
if (FontBold.get())
{
strXml += _T("<font-bold>1</font-bold>");
nBold = 1;
}
}
if (FontItalic.is_init())
{
if (FontItalic.get())
{
strXml += _T("<font-italic>1</font-italic>");
nItalic = 1;
}
}
if (FontUnderline.is_init())
{
if (FontUnderline.get())
{
strXml += _T("<font-underline>1</font-underline>");
}
}
if (FontStrikeout.is_init())
{
if (FontStrikeout.get())
{
strXml += _T("<font-strikeout>1</font-strikeout>");
}
}
if (FontShadow.is_init())
{
if (FontShadow.get())
{
strXml += _T("<shadow-visible>1</shadow-visible>");
}
}
strXml += ToNode(BaseLineOffset, _T("baseline-shift"));
strXml += ToNode(Color, _T("brush-color1"));
strXml += ToNode(Size, _T("font-size"));
if (FontProperties.is_init())
{
strXml += (_T("<font-name>") + std_string2string(FontProperties->strFontName) + _T("</font-name>"));
oWriter.WriteString(strXml);
oWriter.WriteNodeEnd(_T("Attributes"));
// font properties
strXml = _T("<FontProperties>");
strXml += (_T("<Name value='") + std_string2string(FontProperties->strFontName) + _T("' />"));
if (0 < FontProperties->arFontCharsets.size())
strXml += (_T("<Charset value='") + XmlUtils::IntToString((int)FontProperties->arFontCharsets[0]) + _T("' />"));
if (_T("unknown") != FontProperties->strPitchFamily)
strXml += (_T("<FamilyClass name='") + std_string2string(FontProperties->strPitchFamily) + _T("' />"));
if (-1 != FontProperties->lFontFixed)
strXml += (_T("<FixedWidth value='") + XmlUtils::IntToString(FontProperties->lFontFixed) + _T("' />"));
if (_T("") != FontProperties->strPanose)
strXml += (_T("<Panose value='") + std_string2string(FontProperties->strPanose) + _T("' />"));
strXml += (_T("<Style bold='") + XmlUtils::IntToString(nBold) + _T("' italic='") + XmlUtils::IntToString(nItalic) + _T("' />"));
strXml += _T("</FontProperties>");
}
else
{
oWriter.WriteNodeEnd(_T("Attributes"));
}
oWriter.WriteString(strXml);
oWriter.WriteNodeEnd(_T("Character"));
return oWriter.GetXmlString();
}
};
class CTextPFRun
......@@ -403,16 +310,17 @@ namespace NSPresentationEditor
void ApplyBefore(const CTextPFRun& oSrc)
{
if (!hasBullet.is_init()) hasBullet = oSrc.hasBullet;
if (!bulletSize.is_init()) bulletSize = oSrc.bulletSize;
if (!bulletChar.is_init())
if (!hasBullet.is_init())
{
hasBullet = oSrc.hasBullet;
bulletSize = oSrc.bulletSize;
bulletChar = oSrc.bulletChar;
bulletFontRef = oSrc.bulletFontRef;
bulletColor = oSrc.bulletColor;
bulletFontProperties.reset();
}
if (!bulletColor.is_init()) bulletColor = oSrc.bulletColor;
if (!textAlignment.is_init()) textAlignment = oSrc.textAlignment;
if (!lineSpacing.is_init()) lineSpacing = oSrc.lineSpacing;
......@@ -434,16 +342,17 @@ namespace NSPresentationEditor
void ApplyAfter(const CTextPFRun& oSrc)
{
if (oSrc.hasBullet.is_init()) hasBullet = oSrc.hasBullet;
if (oSrc.bulletSize.is_init()) bulletSize = oSrc.bulletSize;
if (oSrc.bulletChar.is_init())
if (oSrc.hasBullet.is_init())
{
hasBullet = oSrc.hasBullet;
bulletSize = oSrc.bulletSize;
bulletChar = oSrc.bulletChar;
bulletFontRef = oSrc.bulletFontRef;
bulletColor = oSrc.bulletColor;
bulletFontProperties.reset();
}
if (oSrc.bulletColor.is_init()) bulletColor = oSrc.bulletColor;
if (oSrc.textAlignment.is_init()) textAlignment = oSrc.textAlignment;
if (oSrc.lineSpacing.is_init()) lineSpacing = oSrc.lineSpacing;
......@@ -867,9 +776,9 @@ namespace NSPresentationEditor
public:
CParagraph() : m_oPFRun(), m_arSpans()
{
m_lTextType = 0;
m_lTextType = -1;
m_lTextLevel = 0;
m_lStyleThemeIndex = 0;
m_lStyleThemeIndex = -1;
}
CParagraph(const CParagraph& oSrc)
{
......
......@@ -215,12 +215,7 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe
oWriter.WriteString(strProp);
}
}
if ((pCF->FontProperties.is_init()) && (!pCF->FontProperties->strFontName.empty()))
{
oWriter.WriteString(std::wstring(L"<a:latin typeface=\"") + pCF->FontProperties->strFontName + _T("\"/>"));
}
else if (pCF->Typeface.is_init())
if (pCF->Typeface.is_init())
{
if (0 == pCF->Typeface.get())
{
......@@ -233,6 +228,18 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe
oWriter.WriteString(strProp);
}
}
else if ((pCF->FontProperties.is_init()) && (!pCF->FontProperties->strFontName.empty()))
{
oWriter.WriteString(std::wstring(L"<a:latin typeface=\"") + pCF->FontProperties->strFontName + _T("\"/>"));
}
if (pCF->FontPropertiesEA.is_init())
{
oWriter.WriteString(std::wstring(L"<a:ea typeface=\"") + pCF->FontPropertiesEA->strFontName + _T("\"/>"));
}
if (pCF->FontPropertiesSym.is_init())
{
oWriter.WriteString(std::wstring(L"<a:sym typeface=\"") + pCF->FontPropertiesSym->strFontName + _T("\"/>"));
}
CString strCF2 = _T("</a:defRPr>");
oWriter.WriteString(strCF2);
......@@ -524,24 +531,17 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
if (-1 != m_pImageElement->m_lPlaceholderType)
{
if (-1 == m_pImageElement->m_lPlaceholderID)
{
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
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("\""));
if (-1 != m_pImageElement->m_lPlaceholderID)
{
CString strIdx; strIdx.Format(_T("%d"), m_pImageElement->m_lPlaceholderID);
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>"));
m_oWriter.WriteString(std::wstring(L" idx=\"") + string2std_string(strIdx) + _T("\""));
}
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
}
else
{
......@@ -599,48 +599,32 @@ void NSPresentationEditor::CShapeWriter::WriteShapeInfo()
if (-1 != m_pShapeElement->m_lPlaceholderType)
{
if ( m_pShapeElement->m_lPlaceholderID < 0)
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph"));
if (m_pShapeElement->m_lPlaceholderType > 0 /*&& !isBodyPlaceholder(m_pShapeElement->m_lPlaceholderType)*/)
m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pShapeElement->m_lPlaceholderType) + _T("\""));
if ( m_pShapeElement->m_lPlaceholderID != -1)
{
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 (m_pShapeElement->m_lPlaceholderSizePreset > 1 && !isTitlePlaceholder(m_pShapeElement->m_lPlaceholderType))
{
if (m_pShapeElement->m_lPlaceholderSizePreset == 2)
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
if (m_pShapeElement->m_lPlaceholderSizePreset == 4)
m_oWriter.WriteString(std::wstring(L" size=\"quarter\""));
if (m_pShapeElement->m_lPlaceholderSizePreset == 3)
{
if (isBodyPlaceholder(m_pShapeElement->m_lPlaceholderType))
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
else
m_oWriter.WriteString(std::wstring(L" size=\"quarter\""));
}
}
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
CString strIdx; strIdx.Format(_T("%d"), m_pShapeElement->m_lPlaceholderID);
m_oWriter.WriteString(std::wstring(L" idx=\"") + string2std_string(strIdx) + _T("\""));
}
else
if (m_pShapeElement->m_lPlaceholderSizePreset > 1 && !isTitlePlaceholder(m_pShapeElement->m_lPlaceholderType))
{
CString strIdx; strIdx.Format(_T("%d"), m_pShapeElement->m_lPlaceholderID);
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 (PT_MasterSlideNumber == m_pShapeElement->m_lPlaceholderType)
if (m_pShapeElement->m_lPlaceholderSizePreset == 2)
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
if (PT_MasterDate == m_pShapeElement->m_lPlaceholderType)
if (m_pShapeElement->m_lPlaceholderSizePreset == 4)
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>"));
}
if (m_pShapeElement->m_lPlaceholderSizePreset == 3)
{
if (isBodyPlaceholder(m_pShapeElement->m_lPlaceholderType))
m_oWriter.WriteString(std::wstring(L" size=\"half\""));
else
m_oWriter.WriteString(std::wstring(L" size=\"quarter\""));
}
}
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
}
else
{
......@@ -873,22 +857,27 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
}
if (pPF->bulletFontProperties.is_init())
{
int rFind = pPF->bulletFontProperties->strFontName.find(L"Wingdings");
unsigned short bu = pPF->bulletChar.is_init() ? pPF->bulletChar.get() : 0;
if (!(rFind >=0 && bu > 0xff ) || rFind < 0)
{
m_oWriter.WriteString(std::wstring(L"<a:buFont typeface=\"") + pPF->bulletFontProperties->strFontName + _T("\"/>"));
}
}
m_oWriter.WriteString(std::wstring(L"<a:buFont typeface=\"") + pPF->bulletFontProperties->strFontName + _T("\"/>"));
}
bool set = true;
if (pPF->bulletFontProperties.is_init() == false && pPF->bulletSize.is_init() == false)
{
m_oWriter.WriteString(std::wstring(L"<a:buFontTx/>"));
if (pPF->bulletColor.is_init() == false)
set = false;
}
if (pPF->bulletChar.is_init())
{
wchar_t bu = pPF->bulletChar.get();
m_oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
m_oWriter.WriteStringXML(std::wstring(&bu, 1));
m_oWriter.WriteString(std::wstring(L"\"/>"));
set = true;
}
else if (pParagraph->m_lTextLevel == 0)
if (!set && pParagraph->m_lTextLevel == 0)
{
wchar_t bu = 0x2022;
m_oWriter.WriteString(std::wstring(L"<a:buChar char=\""));
......@@ -1049,7 +1038,14 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo()
{
m_oWriter.WriteString(std::wstring(L"<a:latin typeface=\"") + pCF->FontProperties->strFontName + _T("\"/>"));
}
if (pCF->FontPropertiesEA.is_init())
{
m_oWriter.WriteString(std::wstring(L"<a:ea typeface=\"") + pCF->FontPropertiesEA->strFontName + _T("\"/>"));
}
if (pCF->FontPropertiesSym.is_init())
{
m_oWriter.WriteString(std::wstring(L"<a:sym typeface=\"") + pCF->FontPropertiesSym->strFontName + _T("\"/>"));
}
m_oWriter.WriteString(std::wstring(L"</a:rPr>"));
if (!bIsBr)
......
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