Commit d02392ac authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

(1.0.0.224) pptx shapes in docx (text props)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53137 954022d7-b5bf-4e40-9824-e11837661b57
parent 1c40c9ab
......@@ -2526,7 +2526,7 @@ HRESULT CAVSOfficeDrawingConverter::GetThemeBinary(BSTR bsThemeFilePath, SAFEARR
*ppBinary = pArray;
m_oBinaryWriter.ThemeDoc = pTheme.smart_dynamic_cast<PPTX::FileContainer>();
m_oBinaryWriter.ThemeDoc.reset();
//m_oBinaryWriter.ThemeDoc.reset();
return S_OK;
}
......
......@@ -24,6 +24,9 @@ namespace OOX
{
m_lMaxRid = 0;
}
virtual ~IFileContainer()
{
}
protected:
CAtlMap<CString, smart_ptr<OOX::File>> m_container;
size_t m_lMaxRid;
......
......@@ -15,7 +15,9 @@ namespace PPTX
{
m_lPercent = 0;
m_bCancelled = false;
}
virtual ~FileContainer()
{
}
protected:
void read(const OOX::CPath& filename);
......
......@@ -91,7 +91,7 @@ namespace PPTX
}
else if (txBody.is_init())
{
CString strContent = txBody->GetDocxTxBoxContent(pWriter);
CString strContent = txBody->GetDocxTxBoxContent(pWriter, style);
LPSAFEARRAY psaData = NULL;
BSTR bsTxContent = strContent.AllocSysString();
......
......@@ -8,7 +8,7 @@ namespace PPTX
{
namespace Logic
{
CString TxBody::GetDocxTxBoxContent(NSBinPptxRW::CBinaryFileWriter* pWriter)
CString TxBody::GetDocxTxBoxContent(NSBinPptxRW::CBinaryFileWriter* pWriter, const nullable<ShapeStyle>& shape_style)
{
CString strXml = _T("<w:txbxContent ");
......@@ -36,8 +36,19 @@ namespace PPTX
strXml += _T(">");
smart_ptr<PPTX::Theme> pTheme = pWriter->ThemeDoc.smart_dynamic_cast<PPTX::Theme>();
smart_ptr<PPTX::Logic::ClrMap> pClrMap = pWriter->ClrMapDoc.smart_dynamic_cast<PPTX::Logic::ClrMap>();
smart_ptr<PPTX::WrapperFile> pTheme = pWriter->ThemeDoc.smart_dynamic_cast<PPTX::WrapperFile>();
smart_ptr<PPTX::WrapperWritingElement> pClrMap = pWriter->ClrMapDoc.smart_dynamic_cast<PPTX::WrapperWritingElement>();
CString sThemeFont = _T("");
DWORD dwColor = 0;
if (shape_style.is_init() && shape_style->fontRef.idx.is_init())
{
if (shape_style->fontRef.idx->get() == _T("major"))
sThemeFont = _T("+mj-lt");
else
sThemeFont = _T("+mn-lt");
}
NSBinPptxRW::CXmlWriter oWriter;
......@@ -92,6 +103,11 @@ namespace PPTX
oWriter.EndNode(_T("w:ind"));
}
if (TRUE)
{
oWriter.WriteString(_T("<w:spacing w:before=\"0\" w:after=\"0\" />"));
}
if (pPr->algn.is_init())
{
LONG _code = pPr->algn->GetBYTECode();
......@@ -162,11 +178,46 @@ namespace PPTX
nullable<PPTX::Logic::RunProperties> pRPr;
pRPr = new PPTX::Logic::RunProperties();
if (_T("") != sThemeFont)
{
pRPr->latin = new PPTX::Logic::TextFont();
pRPr->latin->typeface = sThemeFont;
pRPr->ea = new PPTX::Logic::TextFont();
pRPr->ea->typeface = sThemeFont;
pRPr->cs = new PPTX::Logic::TextFont();
pRPr->cs->typeface = sThemeFont;
pRPr->sym = new PPTX::Logic::TextFont();
pRPr->sym->typeface = sThemeFont;
}
pRunProps->Merge(pRPr);
if (oRun.rPr.is_init())
oRun.rPr->Merge(pRPr);
bool bIsWriteColor = false;
DWORD dwColor = 0;
if (pRPr->Fill.is_init() && pRPr->Fill.is<PPTX::Logic::SolidFill>())
{
PPTX::Logic::SolidFill& oFill = pRPr->Fill.as<PPTX::Logic::SolidFill>();
if (oFill.Color.is_init())
{
bIsWriteColor = true;
dwColor = oFill.Color.GetRGBColor(pTheme, pClrMap, 0);
}
}
else if (shape_style.is_init() && shape_style->fontRef.Color.is_init())
{
bIsWriteColor = true;
dwColor = shape_style->fontRef.Color.GetRGBColor(pTheme, pClrMap, 0);
}
oWriter.StartNode(_T("w:r"));
oWriter.EndAttributes();
......@@ -174,6 +225,78 @@ namespace PPTX
oWriter.StartNode(_T("w:rPr"));
oWriter.EndAttributes();
if (pRPr->latin.is_init() || pRPr->ea.is_init() || pRPr->cs.is_init())
{
oWriter.StartNode(_T("w:rFonts"));
if (pRPr->latin.is_init())
{
CString sPick = pWriter->m_oCommon.m_pNativePicker->GetTypefacePick(pRPr->latin.get2());
if (sPick == _T("minor") || sPick == _T("+mn-lt"))
{
oWriter.WriteAttribute(_T("w:asciiTheme"), (CString)_T("minorHAnsi"));
oWriter.WriteAttribute(_T("w:hAnsiTheme"), (CString)_T("minorHAnsi"));
}
else if (sPick == _T("major") || sPick == _T("+mj-lt"))
{
oWriter.WriteAttribute(_T("w:asciiTheme"), (CString)_T("majorHAnsi"));
oWriter.WriteAttribute(_T("w:hAnsiTheme"), (CString)_T("majorHAnsi"));
}
else
{
oWriter.WriteAttribute(_T("w:ascii"), sPick);
oWriter.WriteAttribute(_T("w:hAnsi"), sPick);
}
}
if (pRPr->ea.is_init())
{
CString sPick = pWriter->m_oCommon.m_pNativePicker->GetTypefacePick(pRPr->ea.get2());
if (sPick == _T("minor") || sPick == _T("+mn-lt"))
{
oWriter.WriteAttribute(_T("w:eastAsiaTheme"), (CString)_T("minorEastAsia"));
}
else if (sPick == _T("major") || sPick == _T("+mj-lt"))
{
oWriter.WriteAttribute(_T("w:eastAsiaTheme"), (CString)_T("majorEastAsia"));
}
else
{
oWriter.WriteAttribute(_T("w:eastAsia"), sPick);
}
}
if (pRPr->cs.is_init())
{
CString sPick = pWriter->m_oCommon.m_pNativePicker->GetTypefacePick(pRPr->cs.get2());
if (sPick == _T("minor") || sPick == _T("+mn-lt"))
{
oWriter.WriteAttribute(_T("w:cstheme"), (CString)_T("minorBidi"));
}
else if (sPick == _T("major") || sPick == _T("+mj-lt"))
{
oWriter.WriteAttribute(_T("w:cstheme"), (CString)_T("majorBidi"));
}
else
{
oWriter.WriteAttribute(_T("w:cs"), sPick);
}
}
oWriter.WriteNodeEnd(_T("w:rFonts"), TRUE, TRUE);
}
if (bIsWriteColor)
{
BYTE _r = (BYTE)((dwColor >> 16) & 0xFF);
BYTE _g = (BYTE)((dwColor >> 8) & 0xFF);
BYTE _b = (BYTE)((dwColor) & 0xFF);
CString sHex = _T("");
sHex.Format(_T("<w:color w:val=\"%02X%02X%02X\" />"), _r, _g, _b);
oWriter.WriteString(sHex);
}
if (pRPr->b.get_value_or(false))
oWriter.WriteString(_T("<w:b/>"));
......@@ -189,7 +312,6 @@ namespace PPTX
oWriter.WriteString(_T("<w:strike/>"));
}
/*
if (pRPr->sz.is_init())
{
double dSize = (double)pRPr->sz.get();
......@@ -200,7 +322,6 @@ namespace PPTX
strFS.Format(_T("<w:sz w:val=\"%d\"/><w:szCs w:val=\"%d\"/>"), nSize, nSize);
oWriter.WriteString(strFS);
}
*/
if (pRPr->u.is_init())
{
......
......@@ -6,6 +6,7 @@
#include "BodyPr.h"
#include "TextListStyle.h"
#include "Paragraph.h"
#include "ShapeStyle.h"
namespace PPTX
{
......@@ -196,7 +197,7 @@ namespace PPTX
return (bodyPr.wrap->get() == _T("none"));
}
CString GetDocxTxBoxContent(NSBinPptxRW::CBinaryFileWriter* pWriter);
CString GetDocxTxBoxContent(NSBinPptxRW::CBinaryFileWriter* pWriter, const nullable<PPTX::Logic::ShapeStyle>& shape_style);
};
} // namespace Logic
} // namespace PPTX
......
......@@ -2,6 +2,6 @@
//1
//0
//0
//223
#define INTVER 1,0,0,223
#define STRVER "1,0,0,223\0"
//224
#define INTVER 1,0,0,224
#define STRVER "1,0,0,224\0"
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