Commit 037c4046 authored by ElenaSubbotina's avatar ElenaSubbotina

PptxFormat - extending reading xml; sppr, txpr in chart without DrawingConverter

parent 4e5ac14c
......@@ -85,9 +85,10 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
if (type == SimpleTypes::shapetypeRect && oox_shape->txBody.IsInit()) type = 2000;
if (type == 2000 && oox_shape->txBody->bodyPr.fromWordArt.get_value_or(false))
if (type == 2000 && oox_shape->txBody->bodyPr.IsInit()
&& oox_shape->txBody->bodyPr->fromWordArt.get_value_or(false))
{
int wordart_type = convert(oox_shape->txBody->bodyPr.prstTxWarp.GetPointer());
int wordart_type = convert(oox_shape->txBody->bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
}
......@@ -111,7 +112,7 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
odf_context()->drawing_context()->set_text( odf_context()->text_context());
//наложим внешние настройки для текста
convert(&oox_shape->txBody->bodyPr);
convert(oox_shape->txBody->bodyPr.GetPointer());
if (oox_shape->style.IsInit())
{
......@@ -281,15 +282,15 @@ void OoxConverter::convert(PPTX::Logic::PathBase *oox_path)
}
if (cubicBezTo)
{
std::wstring path_elm = cubicBezTo->x1 + L" " + cubicBezTo->y1 + L" " +
cubicBezTo->x2 + L" " + cubicBezTo->y2 + L" " +
cubicBezTo->x3 + L" " + cubicBezTo->y3;
std::wstring path_elm = cubicBezTo->x[0] + L" " + cubicBezTo->y[0] + L" " +
cubicBezTo->x[1] + L" " + cubicBezTo->y[1] + L" " +
cubicBezTo->x[2] + L" " + cubicBezTo->y[2];
odf_context()->drawing_context()->add_path_element(std::wstring(L"C"), path_elm);
}
if (quadBezTo)
{
std::wstring path_elm = quadBezTo->x1 + L" " + quadBezTo->y1 + L" " +
quadBezTo->x2 + L" " + quadBezTo->y2;
std::wstring path_elm = quadBezTo->x[0] + L" " + quadBezTo->y[0] + L" " +
quadBezTo->x[1] + L" " + quadBezTo->y[1];
odf_context()->drawing_context()->add_path_element(std::wstring(L"S"), path_elm);
}
if (arcTo)
......
......@@ -395,7 +395,7 @@ void OoxConverter::convert(OOX::Drawing::CDiagrammParts *oox_diagramm)
if (oFile.is_init() && OOX::FileTypes::DiagDrawing == oFile->type())
{
_CP_OPT(double) x, y, width, height, cx = 0, cy = 0;
_CP_OPT(double) x, y, width, height, cx, cy;
odf_context()->drawing_context()->get_size (width, height);
odf_context()->drawing_context()->get_position (x, y);
......
......@@ -270,7 +270,6 @@ namespace OOX
class CT_Style1;
class CT_Style;
class CT_TextLanguageID;
class CRichText;
class CTextProperties;
}
namespace Vml
......@@ -495,8 +494,8 @@ public:
void convert(OOX::Spreadsheet::CT_LineSer *ser);
void convert(OOX::Spreadsheet::CT_AxDataSource *cat, int type);
void convert(OOX::Spreadsheet::CT_NumDataSource *val);
void convert(OOX::Spreadsheet::CRichText *rich);
void convert(OOX::Spreadsheet::CTextProperties *txPr);
//void convert(OOX::Spreadsheet::CRichText *rich);
//void convert(OOX::Spreadsheet::CTextProperties *txPr);
void convert(OOX::Spreadsheet::CT_Tx *ct_tx);
void convert(OOX::Spreadsheet::CT_Layout *ct_layout);
void convert(OOX::Spreadsheet::CT_ManualLayout *ct_layout);
......
......@@ -73,32 +73,32 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart)
odf_context()->chart_context()->end_plot_area();
}
void OoxConverter::convert(OOX::Spreadsheet::CRichText* rich)
{
if (rich == NULL)return;
odf_context()->chart_context()->start_text();
OoxConverter::convert(rich->m_oBodyPr.GetPointer());
for (size_t i = 0; i < rich->m_arrItems.size();i++)
{
OoxConverter::convert(rich->m_arrItems[i]);
}
odf_context()->chart_context()->end_text();
}
void OoxConverter::convert(OOX::Spreadsheet::CTextProperties* txPr)
{
if (txPr == NULL)return;
odf_context()->chart_context()->start_text();
OoxConverter::convert(txPr->m_oBodyPr.GetPointer());
for (size_t i = 0; i < txPr->m_arrItems.size();i++)
{
OoxConverter::convert(txPr->m_arrItems[i]);
}
odf_context()->chart_context()->end_text();
}
//void OoxConverter::convert(OOX::Spreadsheet::CRichText* rich)
//{
// if (rich == NULL)return;
//
// odf_context()->chart_context()->start_text();
// OoxConverter::convert(rich->m_oBodyPr.GetPointer());
//
// for (size_t i = 0; i < rich->m_arrItems.size();i++)
// {
// OoxConverter::convert(rich->m_arrItems[i]);
// }
// odf_context()->chart_context()->end_text();
//}
//void OoxConverter::convert(OOX::Spreadsheet::CTextProperties* txPr)
//{
// if (txPr == NULL)return;
//
// odf_context()->chart_context()->start_text();
// OoxConverter::convert(txPr->m_oBodyPr.GetPointer());
//
// for (size_t i = 0; i < txPr->m_arrItems.size();i++)
// {
// OoxConverter::convert(txPr->m_arrItems[i]);
// }
// odf_context()->chart_context()->end_text();
//}
void OoxConverter::convert(OOX::Spreadsheet::CT_Tx* ct_tx)
{
if (ct_tx == NULL)return;
......
......@@ -2754,7 +2754,11 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
{
if (pShape->txBody.IsInit() == false)
pShape->txBody = new PPTX::Logic::TxBody();
pShape->txBody->bodyPr.vert = pShape->TextBoxBodyPr->vert;
if (!pShape->txBody->bodyPr.IsInit())
pShape->txBody->bodyPr = new PPTX::Logic::BodyPr();
pShape->txBody->bodyPr->vert = pShape->TextBoxBodyPr->vert;
}
pPair = oCSSParser.m_mapSettings.find(L"mso-rotate");
......@@ -2765,7 +2769,11 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
pShape->TextBoxBodyPr->rot = _wtoi(pPair->second.c_str()) * 60000; //для docx, xlsx
if (pShape->txBody.IsInit() == false) //для pptx
pShape->txBody = new PPTX::Logic::TxBody();
pShape->txBody->bodyPr.rot = pShape->TextBoxBodyPr->rot;
if (!pShape->txBody->bodyPr.IsInit())
pShape->txBody->bodyPr = new PPTX::Logic::BodyPr();
pShape->txBody->bodyPr->rot = pShape->TextBoxBodyPr->rot;
}catch(...){}
}
......@@ -5210,45 +5218,45 @@ void CDrawingConverter::ConvertMainPropsToVML(const std::wstring& bsMainProps, N
pWriter.m_strStyleMain = oWriter.GetXmlString();
}
HRESULT CDrawingConverter::GetTxBodyBinary(const std::wstring& bsXml)
{
XmlUtils::CXmlNode oNode;
if (!oNode.FromXmlString((std::wstring)bsXml))
return S_FALSE;
PPTX::Logic::TxBody oTxBody(oNode);
//m_pBinaryWriter->ClearNoAttack();
//ULONG lOldPos = m_pBinaryWriter->GetPosition();
m_pBinaryWriter->m_pCommon->CheckFontPicker();
//m_pBinaryWriter->m_pCommon->m_pNativePicker->Init(m_strFontDirectory);
m_pBinaryWriter->WriteRecord1(0, oTxBody);
//m_pBinaryWriter->SetPosition(lOldPos);
//m_pBinaryWriter->ClearNoAttack();
return S_OK;
}
HRESULT CDrawingConverter::GetTxBodyXml(LONG lStart, std::wstring& sXml)
{
m_pReader->Seek(lStart);
BYTE type = m_pReader->GetUChar();
if (0 != type)
return S_FALSE;
PPTX::Logic::TxBody oTxBody;
oTxBody.fromPPTY(m_pReader);
NSBinPptxRW::CXmlWriter oWriter;
oTxBody.toXmlWriterExcel(&oWriter);
sXml = oWriter.GetXmlString();
return S_OK;
}
//HRESULT CDrawingConverter::GetTxBodyBinary(const std::wstring& bsXml)
//{
// XmlUtils::CXmlNode oNode;
// if (!oNode.FromXmlString((std::wstring)bsXml))
// return S_FALSE;
//
// PPTX::Logic::TxBody oTxBody(oNode);
//
// //m_pBinaryWriter->ClearNoAttack();
// //ULONG lOldPos = m_pBinaryWriter->GetPosition();
// m_pBinaryWriter->m_pCommon->CheckFontPicker();
// //m_pBinaryWriter->m_pCommon->m_pNativePicker->Init(m_strFontDirectory);
//
// m_pBinaryWriter->WriteRecord1(0, oTxBody);
//
// //m_pBinaryWriter->SetPosition(lOldPos);
//
// //m_pBinaryWriter->ClearNoAttack();
// return S_OK;
//}
//HRESULT CDrawingConverter::GetTxBodyXml(LONG lStart, std::wstring& sXml)
//{
// m_pReader->Seek(lStart);
//
// BYTE type = m_pReader->GetUChar();
// if (0 != type)
// return S_FALSE;
//
// PPTX::Logic::TxBody oTxBody;
// oTxBody.fromPPTY(m_pReader);
//
// NSBinPptxRW::CXmlWriter oWriter;
// oTxBody.toXmlWriterExcel(&oWriter);
//
// sXml = oWriter.GetXmlString();
//
// return S_OK;
//}
HRESULT CDrawingConverter::SetFontDir(const std::wstring& bsFontDir)
{
......
......@@ -236,8 +236,6 @@ namespace NSBinPptxRW
HRESULT WriteRels (const std::wstring& sType, const std::wstring& sTarget, const std::wstring& sTargetMode, long* lId);
HRESULT LoadClrMap (const std::wstring& sXml);
HRESULT(GetTxBodyBinary) (const std::wstring& sXml);
HRESULT(GetTxBodyXml) (long lStart, std::wstring & Xml);
HRESULT(SetFontDir) (const std::wstring& sFontDir);
HRESULT SetFontPicker (COfficeFontPicker* pFontPicker);
......
......@@ -45,9 +45,15 @@ namespace PPTX
class AhBase : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(AhBase)
WritingElement_AdditionConstructors(AhBase)
PPTX_LOGIC_BASE2(AhBase)
public:
virtual OOX::EElementType getType() const
{
if (ah.IsInit())
return ah->getType();
return OOX::et_Unknown;
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
std::wstring name = XmlUtils::GetNameNoNS(node.GetName());
......@@ -58,7 +64,16 @@ namespace PPTX
ah.reset(new Logic::AhPolar(node));
else ah.reset();
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring sName = oReader.GetName();
if (sName == L"a:ahXY")
ah.reset(new Logic::AhXY(oReader));
else if(sName == L"a:ahPolar")
ah.reset(new Logic::AhPolar(oReader));
else ah.reset();
}
virtual void GetAdjustHandleFrom(XmlUtils::CXmlNode& element)
{
XmlUtils::CXmlNode oNode;
......
......@@ -43,9 +43,9 @@ namespace PPTX
class AhPolar : public Ah
{
public:
PPTX_LOGIC_BASE(AhPolar)
WritingElement_AdditionConstructors(AhPolar)
PPTX_LOGIC_BASE2(AhPolar)
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oPos = node.ReadNode(_T("a:pos"));
......@@ -60,7 +60,46 @@ namespace PPTX
node.ReadAttributeBase(L"minAng", minAng);
node.ReadAttributeBase(L"minR", minR);
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_ahPolar;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:pos")
{
ReadAttributes2(oReader);
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("gdRefR"), gdRefR )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minR"), minR )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxR"), maxR )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gdRefAng"), gdRefAng )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minAng"), minAng )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxAng"), maxAng )
WritingElement_ReadAttributes_End( oReader )
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual std::wstring toXML() const
{
XmlUtils::CAttribute oAttr1;
......
......@@ -43,9 +43,9 @@ namespace PPTX
class AhXY : public Ah
{
public:
PPTX_LOGIC_BASE(AhXY)
WritingElement_AdditionConstructors(AhXY)
PPTX_LOGIC_BASE2(AhXY)
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oPos = node.ReadNode(_T("a:pos"));
......@@ -60,7 +60,46 @@ namespace PPTX
node.ReadAttributeBase(L"minX", minX);
node.ReadAttributeBase(L"minY", minY);
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_ahXY;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:pos")
{
ReadAttributes2(oReader);
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("gdRefX"), gdRefX )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minX"), minX )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxX"), maxX )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gdRefY"), gdRefY )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minY"), minY )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxY"), maxY )
WritingElement_ReadAttributes_End( oReader )
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual std::wstring toXML() const
{
XmlUtils::CAttribute oAttr1;
......
......@@ -51,9 +51,63 @@ namespace PPTX
class BodyPr : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(BodyPr)
WritingElement_AdditionConstructors(BodyPr)
PPTX_LOGIC_BASE2(BodyPr)
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = oReader.GetName();
if (L"a:prstTxWarp" == strName)
prstTxWarp = oReader;
else if (L"a:scene3d" == strName)
scene3d = oReader;
else if (L"a:sp3d" == strName)
sp3d = oReader;
else if (strName == L"a:noAutofit" || strName == L"a:spAutoFit" || strName == L"a:normAutofit")
Fit.fromXML(oReader);
else if (L"a:flatTx" == strName)
{
//oNode.ReadAttributeBase(L"z", flatTx);
}
}
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("anchor"), anchor )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("anchorCtr"), anchorCtr )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("bIns"), bIns )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("compatLnSpc"), compatLnSpc )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("forceAA"), forceAA )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("fromWordArt"), fromWordArt )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("horzOverflow"), horzOverflow )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("lIns"), lIns )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("numCol"), numCol )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("rIns"), rIns )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("rot"), rot )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("rtlCol"), rtlCol )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("spcCol"), spcCol )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("spcFirstLastPara"), spcFirstLastPara )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("tIns"), tIns )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("upright"), upright )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("vert"), vert )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("vertOverflow"), vertOverflow )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("wrap"), wrap )
WritingElement_ReadAttributes_End ( oReader )
Normalize();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
......@@ -172,10 +226,16 @@ namespace PPTX
pWriter->EndNode(m_namespace + _T(":bodyPr"));
}
void Merge(BodyPr& bodyPr)const
void Merge(nullable<BodyPr>& bodyPr)const
{
if (!bodyPr.IsInit())
{
bodyPr = new PPTX::Logic::BodyPr();
}
if(Fit.type != TextFit::FitEmpty)
Fit.Merge(bodyPr.Fit);
Fit.Merge(bodyPr->Fit);
/*
nullable_property<PrstTxWarp> prstTxWarp;
nullable_property<Scene3d> scene3d;
......@@ -184,43 +244,43 @@ namespace PPTX
*/
// Attributes
if(anchor.IsInit())
bodyPr.anchor = *anchor;
bodyPr->anchor = *anchor;
if(anchorCtr.IsInit())
bodyPr.anchorCtr = *anchorCtr;
bodyPr->anchorCtr = *anchorCtr;
if(bIns.IsInit())
bodyPr.bIns = *bIns;
bodyPr->bIns = *bIns;
if(compatLnSpc.IsInit())
bodyPr.compatLnSpc = *compatLnSpc;
bodyPr->compatLnSpc = *compatLnSpc;
if(forceAA.IsInit())
bodyPr.forceAA = *forceAA;
bodyPr->forceAA = *forceAA;
if(fromWordArt.IsInit())
bodyPr.fromWordArt = *fromWordArt;
bodyPr->fromWordArt = *fromWordArt;
if(horzOverflow.IsInit())
bodyPr.horzOverflow = *horzOverflow;
bodyPr->horzOverflow = *horzOverflow;
if(lIns.IsInit())
bodyPr.lIns = *lIns;
bodyPr->lIns = *lIns;
if(numCol.IsInit())
bodyPr.numCol = *numCol;
bodyPr->numCol = *numCol;
if(rIns.IsInit())
bodyPr.rIns = *rIns;
bodyPr->rIns = *rIns;
if(rot.IsInit())
bodyPr.rot = *rot;
bodyPr->rot = *rot;
if(rtlCol.IsInit())
bodyPr.rtlCol = *rtlCol;
bodyPr->rtlCol = *rtlCol;
if(spcCol.IsInit())
bodyPr.spcCol = *spcCol;
bodyPr->spcCol = *spcCol;
if(spcFirstLastPara.IsInit())
bodyPr.spcFirstLastPara = *spcFirstLastPara;
bodyPr->spcFirstLastPara = *spcFirstLastPara;
if(tIns.IsInit())
bodyPr.tIns = *tIns;
bodyPr->tIns = *tIns;
if(upright.IsInit())
bodyPr.upright = *upright;
bodyPr->upright = *upright;
if(vert.IsInit())
bodyPr.vert = *vert;
bodyPr->vert = *vert;
if(vertOverflow.IsInit())
bodyPr.vertOverflow = *vertOverflow;
bodyPr->vertOverflow = *vertOverflow;
if(wrap.IsInit())
bodyPr.wrap = *wrap;
bodyPr->wrap = *wrap;
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......
......@@ -47,7 +47,8 @@ namespace PPTX
class CustGeom : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(CustGeom)
WritingElement_AdditionConstructors(CustGeom)
PPTX_LOGIC_BASE2(CustGeom)
CustGeom& operator=(const CustGeom& oSrc)
{
......@@ -65,7 +66,107 @@ namespace PPTX
return *this;
}
public:
virtual OOX::EElementType getType() const
{
return OOX::et_a_custGeom;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:avLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if (sName1 == L"a:gd")
{
Gd gd;
avLst.push_back(gd);
avLst.back().fromXML(oReader);
}
}
}
else if (sName == L"a:gdLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if (sName1 == L"a:gd")
{
Gd gd;
gdLst.push_back(gd);
gdLst.back().fromXML(oReader);
}
}
}
else if (sName == L"a:rect")
rect = oReader;
else if (sName == L"a:pathLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if (sName1 == L"a:path")
{
Path2D gd;
pathLst.push_back(gd);
pathLst.back().fromXML(oReader);
}
}
}
else if (sName == L"a:ahLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if (sName1 == L"a:ahPolar")
{
AhBase gd;
ahLst.push_back(gd);
ahLst.back().fromXML(oReader);
}
else if (sName1 == L"a:ahXY")
{
AhBase gd;
ahLst.push_back(gd);
ahLst.back().fromXML(oReader);
}
}
}
else if (sName == L"a:cxnLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if (sName1 == L"a:cxn")
{
Cxn gd;
cxnLst.push_back(gd);
cxnLst.back().fromXML(oReader);
}
}
}
}
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oNode;
......
......@@ -43,7 +43,8 @@ namespace PPTX
class Cxn : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Cxn)
WritingElement_AdditionConstructors(Cxn)
PPTX_LOGIC_BASE2(Cxn)
Cxn& operator=(const Cxn& oSrc)
{
......@@ -55,8 +56,41 @@ namespace PPTX
ang = oSrc.ang;
return *this;
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_cxn;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
public:
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:pos")
{
ReadAttributes2(oReader);
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("ang"), ang )
WritingElement_ReadAttributes_End( oReader )
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
ang = node.GetAttribute(_T("ang"));
......
......@@ -95,7 +95,7 @@ namespace PPTX
{
XmlUtils::CNodeValue oValue;
oValue.Write(spPr);
oValue.Write(bodyPr);
oValue.WriteNullable(bodyPr);
oValue.Write(lstStyle);
oValue.WriteNullable(style);
......@@ -105,7 +105,7 @@ namespace PPTX
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteRecord1(0, spPr);
pWriter->WriteRecord1(1, bodyPr);
pWriter->WriteRecord2(1, bodyPr);
pWriter->WriteRecord1(2, lstStyle);
pWriter->WriteRecord2(3, style);
}
......@@ -127,8 +127,9 @@ namespace PPTX
}
case 1:
{
bodyPr.m_namespace = _T("a");
bodyPr.fromPPTY(pReader);
bodyPr = BodyPr();
bodyPr->m_namespace = _T("a");
bodyPr->fromPPTY(pReader);
break;
}
case 2:
......@@ -160,7 +161,9 @@ namespace PPTX
pWriter->m_lFlag = 0x04;
spPr.toXmlWriter(pWriter);
pWriter->m_lFlag = 0;
bodyPr.toXmlWriter(pWriter);
if (bodyPr.IsInit())
bodyPr->toXmlWriter(pWriter);
lstStyle.toXmlWriter(pWriter);
pWriter->Write(style);
......@@ -169,16 +172,19 @@ namespace PPTX
public:
SpPr spPr;
BodyPr bodyPr;
nullable<BodyPr> bodyPr;
TextListStyle lstStyle;
nullable<ShapeStyle> style;
public:
std::wstring m_name;
std::wstring m_name;
protected:
virtual void FillParentPointersForChilds()
{
spPr.SetParentPointer(this);
bodyPr.SetParentPointer(this);
if (bodyPr.IsInit())
bodyPr->SetParentPointer(this);
lstStyle.SetParentPointer(this);
if(style.IsInit())
style->SetParentPointer(this);
......
......@@ -78,7 +78,7 @@ namespace PPTX
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = oReader.GetName();
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("blip") == strName)
{
if (!blip.IsInit())
......
......@@ -42,9 +42,25 @@ namespace PPTX
class Gd : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Gd)
WritingElement_AdditionConstructors(Gd)
PPTX_LOGIC_BASE2(Gd)
public:
virtual OOX::EElementType getType () const
{
return OOX::et_a_gd;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), name )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("fmla"), fmla )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"name", name);
......
......@@ -45,9 +45,26 @@ namespace PPTX
class Geometry : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Geometry)
WritingElement_AdditionConstructors(Geometry)
PPTX_LOGIC_BASE2(Geometry)
public:
virtual OOX::EElementType getType() const
{
if (m_geometry.IsInit())
return m_geometry->getType();
return OOX::et_Unknown;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == _T("prstGeom"))
m_geometry.reset(new Logic::PrstGeom(oReader));
else if (strName == _T("custGeom"))
m_geometry.reset(new Logic::CustGeom(oReader));
else
m_geometry.reset();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
std::wstring strName = XmlUtils::GetNameNoNS(node.GetName());
......
......@@ -45,7 +45,8 @@ namespace PPTX
class Path2D : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(Path2D)
WritingElement_AdditionConstructors(Path2D)
PPTX_LOGIC_BASE2(Path2D)
Path2D& operator=(const Path2D& oSrc)
{
......@@ -62,8 +63,40 @@ namespace PPTX
return *this;
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_path;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
public:
Paths.clear();
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
UniPath2D p;
Paths.push_back(p);
Paths.back().fromXML(oReader);
}
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("extrusionOk"), extrusionOk)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("fill"), fill )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("h"), h )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("stroke"), stroke )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w"), w )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"extrusionOk", extrusionOk);
......@@ -229,12 +262,12 @@ namespace PPTX
case GEOMETRY_TYPE_PATH_CUBICBEZTO:
{
Logic::CubicBezTo* p = new Logic::CubicBezTo();
p->x1 = arr[0];
p->y1 = arr[1];
p->x2 = arr[2];
p->y2 = arr[3];
p->x3 = arr[4];
p->y3 = arr[5];
p->x[0] = arr[0];
p->y[0] = arr[1];
p->x[1] = arr[2];
p->y[1] = arr[3];
p->x[2] = arr[4];
p->y[2] = arr[5];
oPath.Path2D.reset(p);
break;
}
......@@ -251,10 +284,10 @@ namespace PPTX
case GEOMETRY_TYPE_PATH_QUADBEZTO:
{
Logic::QuadBezTo* p = new Logic::QuadBezTo();
p->x1 = arr[0];
p->y1 = arr[1];
p->x2 = arr[2];
p->y2 = arr[3];
p->x[0] = arr[0];
p->y[0] = arr[1];
p->x[1] = arr[2];
p->y[1] = arr[3];
oPath.Path2D.reset(p);
break;
}
......
......@@ -42,7 +42,8 @@ namespace PPTX
class ArcTo : public PathBase
{
public:
PPTX_LOGIC_BASE(ArcTo)
WritingElement_AdditionConstructors(ArcTo)
PPTX_LOGIC_BASE2(ArcTo)
ArcTo& operator=(const ArcTo& oSrc)
{
......@@ -56,8 +57,23 @@ namespace PPTX
return *this;
}
public:
virtual OOX::EElementType getType() const
{
return OOX::et_a_arcTo;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("wR"), wR )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("hR"), hR)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("stAng"), stAng)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("swAng"), swAng)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
wR = node.GetAttribute(_T("wR"));
......
......@@ -43,7 +43,8 @@ namespace PPTX
class Close : public PathBase
{
public:
PPTX_LOGIC_BASE(Close)
WritingElement_AdditionConstructors(Close)
PPTX_LOGIC_BASE2(Close)
Close& operator=(const Close& oSrc)
{
......@@ -52,8 +53,14 @@ namespace PPTX
return *this;
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_close;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
......
......@@ -43,24 +43,24 @@ namespace PPTX
class CubicBezTo : public PathBase
{
public:
PPTX_LOGIC_BASE(CubicBezTo)
WritingElement_AdditionConstructors(CubicBezTo)
PPTX_LOGIC_BASE2(CubicBezTo)
CubicBezTo& operator=(const CubicBezTo& oSrc)
{
parentFile = oSrc.parentFile;
parentElement = oSrc.parentElement;
x1 = oSrc.x1;
y1 = oSrc.y1;
x2 = oSrc.x2;
y2 = oSrc.y2;
x3 = oSrc.x3;
y3 = oSrc.y3;
x[0] = oSrc.x[0];
y[0] = oSrc.y[0];
x[1] = oSrc.x[1];
y[1] = oSrc.y[1];
x[2] = oSrc.x[2];
y[2] = oSrc.y[2];
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNodes oNodes;
......@@ -73,23 +73,53 @@ namespace PPTX
XmlUtils::CXmlNode oNode;
oNodes.GetAt(0, oNode);
x1 = oNode.GetAttribute(_T("x"));
y1 = oNode.GetAttribute(_T("y"));
x[0] = oNode.GetAttribute(_T("x"));
y[0] = oNode.GetAttribute(_T("y"));
oNodes.GetAt(1, oNode);
x2 = oNode.GetAttribute(_T("x"));
y2 = oNode.GetAttribute(_T("y"));
x[1] = oNode.GetAttribute(_T("x"));
y[1] = oNode.GetAttribute(_T("y"));
oNodes.GetAt(2, oNode);
x3 = oNode.GetAttribute(_T("x"));
y3 = oNode.GetAttribute(_T("y"));
x[2] = oNode.GetAttribute(_T("x"));
y[2] = oNode.GetAttribute(_T("y"));
}
}
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_cubicBezTo;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int count = 0;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:pos")
{
ReadAttributes2(oReader, x[count], y[count]);
count++;
}
}
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader, std::wstring & x, std::wstring & y)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual std::wstring toXML() const
{
std::wstring str1 = L"<a:pt x=\"" + x1 + L"\" y=\"" + y1 + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x2 + L"\" y=\"" + y2 + L"\" />";
std::wstring str3 = L"<a:pt x=\"" + x3 + L"\" y=\"" + y3 + L"\" />";
std::wstring str1 = L"<a:pt x=\"" + x[0] + L"\" y=\"" + y[0] + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x[1] + L"\" y=\"" + y[1] + L"\" />";
std::wstring str3 = L"<a:pt x=\"" + x[2] + L"\" y=\"" + y[2] + L"\" />";
return _T("<a:cubicBezTo>") + str1 + str2 + str3 + _T("</a:cubicBezTo>");
}
......@@ -101,22 +131,22 @@ namespace PPTX
pWriter->StartNode(_T("a:pt"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("x"), x1);
pWriter->WriteAttribute(_T("y"), y1);
pWriter->WriteAttribute(_T("x"), x[0]);
pWriter->WriteAttribute(_T("y"), y[0]);
pWriter->EndAttributes();
pWriter->EndNode(_T("a:pt"));
pWriter->StartNode(_T("a:pt"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("x"), x2);
pWriter->WriteAttribute(_T("y"), y2);
pWriter->WriteAttribute(_T("x"), x[1]);
pWriter->WriteAttribute(_T("y"), y[1]);
pWriter->EndAttributes();
pWriter->EndNode(_T("a:pt"));
pWriter->StartNode(_T("a:pt"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("x"), x3);
pWriter->WriteAttribute(_T("y"), y3);
pWriter->WriteAttribute(_T("x"), x[2]);
pWriter->WriteAttribute(_T("y"), y[2]);
pWriter->EndAttributes();
pWriter->EndNode(_T("a:pt"));
......@@ -128,33 +158,29 @@ namespace PPTX
pWriter->StartRecord(GEOMETRY_TYPE_PATH_CUBICBEZTO);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, x1);
pWriter->WriteString1(1, y1);
pWriter->WriteString1(2, x2);
pWriter->WriteString1(3, y2);
pWriter->WriteString1(4, x3);
pWriter->WriteString1(5, y3);
pWriter->WriteString1(0, x[0]);
pWriter->WriteString1(1, y[0]);
pWriter->WriteString1(2, x[1]);
pWriter->WriteString1(3, y[1]);
pWriter->WriteString1(4, x[2]);
pWriter->WriteString1(5, y[2]);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->EndRecord();
}
public:
std::wstring x1;
std::wstring y1;
std::wstring x2;
std::wstring y2;
std::wstring x3;
std::wstring y3;
std::wstring x[3];
std::wstring y[3];
protected:
virtual void FillParentPointersForChilds(){};
public:
virtual std::wstring GetODString()const
{
std::wstring str1 = L"<pt x=\"" + x1 + L"\" y=\"" + y1 + L"\"/>";
std::wstring str2 = L"<pt x=\"" + x2 + L"\" y=\"" + y2 + L"\"/>";
std::wstring str3 = L"<pt x=\"" + x3 + L"\" y=\"" + y3 + L"\"/>";
std::wstring str1 = L"<pt x=\"" + x[0] + L"\" y=\"" + y[0] + L"\"/>";
std::wstring str2 = L"<pt x=\"" + x[1] + L"\" y=\"" + y[1] + L"\"/>";
std::wstring str3 = L"<pt x=\"" + x[2] + L"\" y=\"" + y[2] + L"\"/>";
return _T("<cubicBezTo>") + str1 + str2 + str3 + _T("</cubicBezTo>");
}
......
......@@ -43,7 +43,8 @@ namespace PPTX
class LineTo : public PathBase
{
public:
PPTX_LOGIC_BASE(LineTo)
WritingElement_AdditionConstructors(LineTo)
PPTX_LOGIC_BASE2(LineTo)
LineTo& operator=(const LineTo& oSrc)
{
......@@ -55,7 +56,33 @@ namespace PPTX
return *this;
}
public:
virtual OOX::EElementType getType() const
{
return OOX::et_a_lineTo;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:pos")
{
ReadAttributes2(oReader);
}
}
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oNode;
......
......@@ -43,7 +43,8 @@ namespace PPTX
class MoveTo : public PathBase
{
public:
PPTX_LOGIC_BASE(MoveTo)
WritingElement_AdditionConstructors(MoveTo)
PPTX_LOGIC_BASE2(MoveTo)
MoveTo& operator=(const MoveTo& oSrc)
{
......@@ -54,8 +55,34 @@ namespace PPTX
y = oSrc.y;
return *this;
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_moveTo;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
public:
if (sName == L"a:pos")
{
ReadAttributes2(oReader);
}
}
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNode oNode;
......
......@@ -42,21 +42,52 @@ namespace PPTX
class QuadBezTo : public PathBase
{
public:
PPTX_LOGIC_BASE(QuadBezTo)
WritingElement_AdditionConstructors(QuadBezTo)
PPTX_LOGIC_BASE2(QuadBezTo)
QuadBezTo& operator=(const QuadBezTo& oSrc)
{
parentFile = oSrc.parentFile;
parentElement = oSrc.parentElement;
x1 = oSrc.x1;
y1 = oSrc.y1;
x2 = oSrc.x2;
y2 = oSrc.y2;
x[0] = oSrc.x[0];
y[0] = oSrc.y[0];
x[1] = oSrc.x[1];
y[1] = oSrc.y[1];
return (*this);
}
public:
virtual OOX::EElementType getType() const
{
return OOX::et_a_quadBezTo;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int count = 0;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:pos")
{
ReadAttributes2(oReader, x[count], y[count]);
count++;
}
}
}
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader, std::wstring & x, std::wstring & y)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
XmlUtils::CXmlNodes oNodes;
......@@ -69,19 +100,19 @@ namespace PPTX
XmlUtils::CXmlNode oNode;
oNodes.GetAt(0, oNode);
x1 = oNode.GetAttribute(_T("x"));
y1 = oNode.GetAttribute(_T("y"));
x[0] = oNode.GetAttribute(_T("x"));
y[0] = oNode.GetAttribute(_T("y"));
oNodes.GetAt(1, oNode);
x2 = oNode.GetAttribute(_T("x"));
y2 = oNode.GetAttribute(_T("y"));
x[1] = oNode.GetAttribute(_T("x"));
y[1] = oNode.GetAttribute(_T("y"));
}
}
}
virtual std::wstring toXML() const
{
std::wstring str1 = L"<a:pt x=\"" + x1 + L"\" y=\"" + y1 + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x2 + L"\" y=\"" + y2 + L"\" />";
std::wstring str1 = L"<a:pt x=\"" + x[0] + L"\" y=\"" + y[0] + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x[1] + L"\" y=\"" + y[1] + L"\" />";
return _T("<a:quadBezTo>") + str1 + str2 + _T("</a:quadBezTo>");
}
......@@ -93,15 +124,15 @@ namespace PPTX
pWriter->StartNode(_T("a:pt"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("x"), x1);
pWriter->WriteAttribute(_T("y"), y1);
pWriter->WriteAttribute(_T("x"), x[0]);
pWriter->WriteAttribute(_T("y"), y[0]);
pWriter->EndAttributes();
pWriter->EndNode(_T("a:pt"));
pWriter->StartNode(_T("a:pt"));
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("x"), x2);
pWriter->WriteAttribute(_T("y"), y2);
pWriter->WriteAttribute(_T("x"), x[1]);
pWriter->WriteAttribute(_T("y"), y[1]);
pWriter->EndAttributes();
pWriter->EndNode(_T("a:pt"));
......@@ -113,27 +144,25 @@ namespace PPTX
pWriter->StartRecord(GEOMETRY_TYPE_PATH_QUADBEZTO);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, x1);
pWriter->WriteString1(1, y1);
pWriter->WriteString1(2, x2);
pWriter->WriteString1(3, y2);
pWriter->WriteString1(0, x[0]);
pWriter->WriteString1(1, y[0]);
pWriter->WriteString1(2, x[1]);
pWriter->WriteString1(3, y[1]);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->EndRecord();
}
public:
std::wstring x1;
std::wstring y1;
std::wstring x2;
std::wstring y2;
std::wstring x[2];
std::wstring y[2];
protected:
virtual void FillParentPointersForChilds(){};
public:
virtual std::wstring GetODString()const
{
std::wstring str1 = L"<a:pt x=\"" + x1 + L"\" y=\"" + y1 + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x2 + L"\" y=\"" + y2 + L"\" />";
std::wstring str1 = L"<a:pt x=\"" + x[0] + L"\" y=\"" + y[0] + L"\" />";
std::wstring str2 = L"<a:pt x=\"" + x[1] + L"\" y=\"" + y[1] + L"\" />";
return _T("<quadBezTo>") + str1 + str2 + _T("</quadBezTo>");
}
......
......@@ -44,7 +44,8 @@ namespace PPTX
class PrstGeom : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(PrstGeom)
WritingElement_AdditionConstructors(PrstGeom)
PPTX_LOGIC_BASE2(PrstGeom)
PrstGeom& operator=(const PrstGeom& oSrc)
{
......@@ -56,8 +57,47 @@ namespace PPTX
return *this;
}
public:
virtual OOX::EElementType getType() const
{
return OOX::et_a_prstGeom;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
if (sName == L"a:avLst")
{
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if (sName1 == L"a:gd")
{
Gd gd;
avLst.push_back(gd);
avLst.back().fromXML(oReader);
}
}
}
}
FillParentPointersForChilds();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("r:prst"), prst)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"prst", prst);
......
......@@ -44,7 +44,8 @@ namespace PPTX
class PrstTxWarp : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(PrstTxWarp)
WritingElement_AdditionConstructors(PrstTxWarp)
PPTX_LOGIC_BASE2(PrstTxWarp)
PrstTxWarp& operator=(const PrstTxWarp& oSrc)
{
......@@ -56,8 +57,45 @@ namespace PPTX
return *this;
}
virtual OOX::EElementType getType () const
{
return OOX::et_a_prstTxWarp;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
public:
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = oReader.GetName();
if (_T("a:avLst") == strName)
{
int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{
std::wstring strName1 = oReader.GetName();
if (_T("a:gd") == strName1)
{
Gd gd;
avLst.push_back(gd);
avLst.back().fromXML(oReader);
}
}
}
}
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("prst"), prst )
WritingElement_ReadAttributes_End ( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"prst", prst);
......
......@@ -176,7 +176,7 @@ namespace PPTX
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && txBody.is_init())
txBody->m_ns = _T("xdr");
txBody->m_name = _T("xdr:txBody");
pWriter->Write(txBody);
}
......@@ -198,7 +198,7 @@ namespace PPTX
}
else if (txBody.is_init())
{
txBody->m_ns = _T("wps");
txBody->m_name = _T("wps:txBody");
pWriter->Write(txBody);
}
......@@ -371,7 +371,7 @@ namespace PPTX
pWriter->m_pMainDocument->getBinaryContent(strContent, *pWriter, lDataSize);
pWriter->EndRecord();
pWriter->WriteRecord1(5, txBody->bodyPr);
pWriter->WriteRecord2(5, txBody->bodyPr);
}
}
else
......@@ -597,7 +597,9 @@ namespace PPTX
if(!shape.txBody.is_init())
shape.txBody = new TxBody();
txBody->bodyPr.Merge(shape.txBody->bodyPr);
if (txBody->bodyPr.IsInit())
txBody->bodyPr->Merge(shape.txBody->bodyPr);
if(txBody->lstStyle.is_init())
{
for (int i = 0; i < 10; i++)
......@@ -738,9 +740,9 @@ namespace PPTX
if (txBody.is_init())
{
if (txBody->bodyPr.anchor.is_init())
if (txBody->bodyPr.IsInit() && txBody->bodyPr->anchor.is_init())
{
std::wstring _strAnchor = txBody->bodyPr.anchor->get();
std::wstring _strAnchor = txBody->bodyPr->anchor->get();
if (_strAnchor == L"t")
oStylesWriter.WriteAttributeCSS(L"v-text-anchor", L"top");
else if (_strAnchor == L"b")
......
......@@ -65,7 +65,9 @@ namespace PPTX
{
if(Src.IsInit())
{
Src->bodyPr.Merge(bodyPr);
if (Src->bodyPr.IsInit())
Src->bodyPr->Merge(bodyPr);
if(Src->lstStyle.IsInit())
{
for(int i = 0; i < 10; i++)
......@@ -753,7 +755,9 @@ namespace PPTX
void ShapeProperties::SetParentFilePointer(const WrapperFile* pFile)
{
bodyPr.SetParentFilePointer(pFile);
if (bodyPr.IsInit())
bodyPr->SetParentFilePointer(pFile);
for(int i = 0; i < 10; i ++)
{
levels[i]->SetParentFilePointer(pFile);
......@@ -766,45 +770,53 @@ namespace PPTX
DWORD ShapeProperties::GetHyperlinkRGBA()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetRGBAFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetRGBAFromMap(_T("hlink"));
else return 0;
}
DWORD ShapeProperties::GetHyperlinkARGB()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetARGBFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetARGBFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetARGBFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetARGBFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetARGBFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetARGBFromMap(_T("hlink"));
else return 0;
}
DWORD ShapeProperties::GetHyperlinkBGRA()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetBGRAFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetBGRAFromMap(_T("hlink"));
else return 0;
}
DWORD ShapeProperties::GetHyperlinkABGR()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetABGRFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetABGRFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetABGRFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetABGRFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetABGRFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetABGRFromMap(_T("hlink"));
else return 0;
}
......
......@@ -56,7 +56,7 @@ namespace PPTX
nullable<FontRef> fontStyle;
nullable<TextParagraphPr> levels[10];
nullable<TextParagraphPr> masters[10];
BodyPr bodyPr;
nullable<BodyPr> bodyPr;
//std::string MajorLatin;
//std::string MinorLatin;
......@@ -80,7 +80,7 @@ namespace PPTX
void SetMajorLatin(const TextFont& mjltFont){MajorLatin = mjltFont;};
void SetMinorLatin(const TextFont& mnltFont){MinorLatin = mnltFont;};
std::wstring GetAnchor()const{return bodyPr.anchor.get_value_or(_T("t"));};
std::wstring GetAnchor()const{return bodyPr.IsInit() ? bodyPr->anchor.get_value_or(L"t") : L"t";};
std::wstring GetParagraphAlgn (int level, const nullable<TextParagraphPr>& pParagraph)const;
int GetParagraphLeftMargin (int level, const nullable<TextParagraphPr>& pParagraph)const;
......
......@@ -101,7 +101,9 @@ namespace PPTX
{
if (Src.IsInit())
{
Src->bodyPr.Merge(bodyPr);
if (Src->bodyPr.IsInit())
Src->bodyPr->Merge(bodyPr);
if (Src->lstStyle.IsInit())
{
for(int i = 0; i < 10; i++)
......@@ -589,48 +591,57 @@ namespace PPTX
DWORD CShapeTextProperties::GetHyperlinkRGBA()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetRGBAFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetRGBAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetRGBAFromMap(_T("hlink"));
else return 0;
}
DWORD CShapeTextProperties::GetHyperlinkARGB()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetARGBFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetARGBFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetARGBFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetARGBFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetARGBFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetARGBFromMap(_T("hlink"));
else return 0;
}
DWORD CShapeTextProperties::GetHyperlinkBGRA()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetBGRAFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetBGRAFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetBGRAFromMap(_T("hlink"));
else return 0;
}
DWORD CShapeTextProperties::GetHyperlinkABGR()const
{
if(bodyPr.parentFileIs<Slide>())
return bodyPr.parentFileAs<Slide>().GetABGRFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideLayout>())
return bodyPr.parentFileAs<SlideLayout>().GetABGRFromMap(_T("hlink"));
else if(bodyPr.parentFileIs<SlideMaster>())
return bodyPr.parentFileAs<SlideMaster>().GetABGRFromMap(_T("hlink"));
if (!bodyPr.IsInit()) return 0;
if(bodyPr->parentFileIs<Slide>())
return bodyPr->parentFileAs<Slide>().GetABGRFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideLayout>())
return bodyPr->parentFileAs<SlideLayout>().GetABGRFromMap(_T("hlink"));
else if(bodyPr->parentFileIs<SlideMaster>())
return bodyPr->parentFileAs<SlideMaster>().GetABGRFromMap(_T("hlink"));
else return 0;
}
void CShapeTextProperties::SetParentFilePointer(const WrapperFile* pFile)
{
bodyPr.SetParentFilePointer(pFile);
if (bodyPr.IsInit())
bodyPr->SetParentFilePointer(pFile);
m_pFile = pFile;
......
......@@ -48,11 +48,11 @@ namespace PPTX
class CFontInfo
{
public:
LONG FontRef;
LONG FontRef;
std::wstring strFontName;
std::wstring strPanose;
std::wstring strPitchFamily;
BYTE Charset;
std::wstring strPanose;
std::wstring strPitchFamily;
BYTE Charset;
public:
CFontInfo()
......@@ -90,7 +90,7 @@ namespace PPTX
LONG m_lTextType;
nullable<TextParagraphPr> m_levels[10];
nullable<TextParagraphPr> m_body[10];
BodyPr bodyPr;
nullable<BodyPr> bodyPr;
// просто указатель - он должен выставиться из темы
std::vector<nullable<TextParagraphPr>*>* m_masters;
......@@ -135,7 +135,7 @@ namespace PPTX
return -1;
}
std::wstring GetAnchor()const{return bodyPr.anchor.get_value_or(_T("t"));};
std::wstring GetAnchor()const{return bodyPr.IsInit() ? bodyPr->anchor.get_value_or(L"t") : L"t"; };
nullable_base<WORD> GetParagraphAlgn (int level, const nullable<TextParagraphPr>& pParagraph)const;
nullable_base<LONG> GetParagraphLeftMargin (int level, const nullable<TextParagraphPr>& pParagraph)const;
......
......@@ -44,26 +44,73 @@ namespace PPTX
{
Fill.m_type = UniFill::notInit;
}
SpPr::~SpPr()
{
}
SpPr::SpPr(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
SpPr::SpPr(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const SpPr& SpPr::operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
const SpPr& SpPr::operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
void SpPr::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_namespace = XmlUtils::GetNamespace(oReader.GetName());
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"xfrm" == sName)
xfrm = oReader;
else if ( L"ln" == sName)
ln = oReader;
else if ( L"scene3d" == sName)
scene3d = oReader;
else if ( L"sp3d" == sName)
sp3d = oReader;
else if ( L"blipFill" == sName ||
L"gradFill" == sName ||
L"grpFill" == sName ||
L"noFill" == sName ||
L"pattFill" == sName ||
L"solidFill" == sName )
{
Fill.fromXML(oReader);
}
else if ( L"effectDag" == sName ||
L"effectLst" == sName ||
L"extLst" == sName )
{
EffectList.fromXML(oReader);
}
else if ( L"prstGeom" == sName ||
L"custGeom" == sName)
{
Geometry.fromXML(oReader);
}
}
FillParentPointersForChilds();
}
void SpPr::fromXML(XmlUtils::CXmlNode& node)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
......
......@@ -57,12 +57,24 @@ namespace PPTX
explicit SpPr(XmlUtils::CXmlNode& node);
const SpPr& operator =(XmlUtils::CXmlNode& node);
explicit SpPr(XmlUtils::CXmlLiteReader& oReader);
const SpPr& operator =(XmlUtils::CXmlLiteReader& oReader);
virtual OOX::EElementType getType () const
{
return OOX::et_p_spPr;
return OOX::et_a_spPr;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual void fromXML(XmlUtils::CXmlNode& node);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("bwMode"), bwMode )
WritingElement_ReadAttributes_End( oReader )
}
virtual std::wstring toXML() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
......
......@@ -148,7 +148,7 @@ namespace PPTX
{
txBody = new Logic::TxBody();
txBody->fromPPTY(pReader);
txBody->m_ns = _T("a");
txBody->m_name = _T("a:txBody");
break;
}
default:
......
......@@ -44,9 +44,9 @@ namespace PPTX
class TextListStyle : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(TextListStyle)
WritingElement_AdditionConstructors(TextListStyle)
PPTX_LOGIC_BASE2(TextListStyle)
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
m_name = node.GetName();
......@@ -64,6 +64,44 @@ namespace PPTX
FillParentPointersForChilds();
}
virtual OOX::EElementType getType () const
{
return OOX::et_Unknown;//a_bodyStyle;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = oReader.GetName();
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("defPPr") == strName)
levels[9] = oReader;
else if (_T("lvl1pPr") == strName)
levels[0] = oReader;
else if (_T("lvl2pPr") == strName)
levels[1] = oReader;
else if (_T("lvl3pPr") == strName)
levels[2] = oReader;
else if (_T("lvl4pPr") == strName)
levels[3] = oReader;
else if (_T("lvl5pPr") == strName)
levels[4] = oReader;
else if (_T("lvl6pPr") == strName)
levels[5] = oReader;
else if (_T("lvl7pPr") == strName)
levels[6] = oReader;
else if (_T("lvl8pPr") == strName)
levels[7] = oReader;
else if (_T("lvl9pPr") == strName)
levels[8] = oReader;
}
}
virtual std::wstring toXML() const
{
XmlUtils::CNodeValue oValue;
......@@ -139,10 +177,8 @@ namespace PPTX
levels[i]->Merge(lstStyle->levels[i]);
}
public:
nullable<TextParagraphPr> levels[10];
//private:
public:
mutable std::wstring m_name;
nullable<TextParagraphPr> levels[10];
mutable std::wstring m_name;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -49,15 +49,27 @@ namespace PPTX
public:
TxBody()
{
m_ns = _T("p");
m_name = _T("p:txBody");
}
virtual ~TxBody() {}
explicit TxBody(XmlUtils::CXmlNode& node) { fromXML(node); }
explicit TxBody(XmlUtils::CXmlNode& node)
{
fromXML(node);
}
const TxBody& operator =(XmlUtils::CXmlNode& node)
{
fromXML(node);
return *this;
}
explicit TxBody(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
}
const TxBody& operator =(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader);
return *this;
}
TxBody(const TxBody& oSrc) { *this = oSrc; }
TxBody& operator=(const TxBody& oSrc)
......@@ -65,20 +77,49 @@ namespace PPTX
parentFile = oSrc.parentFile;
parentElement = oSrc.parentElement;
bodyPr = oSrc.bodyPr;
lstStyle = oSrc.lstStyle;
Paragrs = oSrc.Paragrs;
bodyPr = oSrc.bodyPr;
lstStyle = oSrc.lstStyle;
Paragrs = oSrc.Paragrs;
m_ns = oSrc.m_ns;
m_name = oSrc.m_name;
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_name = oReader.GetName();
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring strName = oReader.GetName();
if (_T("a:bodyPr") == strName)
{
bodyPr = oReader;
}
else if (_T("a:lstStyle") == strName)
{
lstStyle = oReader;
}
else if (_T("a:p") == strName)
{
Paragraph p;
Paragrs.push_back(p);
Paragrs.back().fromXML(oReader);
}
}
FillParentPointersForChilds();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
Paragrs.clear();
m_name = node.GetName();
bodyPr = node.ReadNode(_T("a:bodyPr"));
lstStyle = node.ReadNode(_T("a:lstStyle"));
......@@ -89,22 +130,25 @@ namespace PPTX
virtual std::wstring toXML() const
{
XmlUtils::CNodeValue oValue;
oValue.Write(bodyPr);
oValue.WriteNullable(bodyPr);
oValue.WriteNullable(lstStyle);
oValue.WriteArray(Paragrs);
return XmlUtils::CreateNode(_T("p:txBody"), oValue);
return XmlUtils::CreateNode(m_name, oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(m_ns + _T(":txBody"));
pWriter->StartNode(m_name);
pWriter->EndAttributes();
bodyPr.m_namespace = _T("a");
bodyPr.toXmlWriter(pWriter);
if (lstStyle.is_init())
if (bodyPr.IsInit())
{
bodyPr->m_namespace = _T("a");
bodyPr->toXmlWriter(pWriter);
}
if (lstStyle.IsInit())
lstStyle->m_name = _T("a:lstStyle");
pWriter->Write(lstStyle);
......@@ -112,7 +156,7 @@ namespace PPTX
for (size_t i = 0; i < nCount; ++i)
Paragrs[i].toXmlWriter(pWriter);
pWriter->EndNode(m_ns + _T(":txBody"));
pWriter->EndNode(m_name);
}
void toXmlWriterExcel(NSBinPptxRW::CXmlWriter* pWriter) const
......@@ -121,9 +165,11 @@ namespace PPTX
pWriter->StartNode(_T("c:rich"));
pWriter->EndAttributes();
*/
bodyPr.m_namespace = _T("a");
bodyPr.toXmlWriter(pWriter);
if (bodyPr.IsInit())
{
bodyPr->m_namespace = _T("a");
bodyPr->toXmlWriter(pWriter);
}
if (lstStyle.is_init())
lstStyle->m_name = _T("a:lstStyle");
......@@ -150,16 +196,18 @@ namespace PPTX
void Merge(nullable<TxBody>& txBody)const
{
if(!txBody.is_init())
txBody = new TxBody();
bodyPr.Merge(txBody->bodyPr);
if(lstStyle.is_init())
if(!txBody.is_init()) return;
if(bodyPr.IsInit())
bodyPr->Merge(txBody->bodyPr);
if(lstStyle.IsInit())
lstStyle->Merge(txBody->lstStyle);
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteRecord1(0, bodyPr);
pWriter->WriteRecord2(0, bodyPr);
pWriter->WriteRecord2(1, lstStyle);
pWriter->WriteRecordArray(2, 0, Paragrs);
}
......@@ -174,7 +222,8 @@ namespace PPTX
{
case 0:
{
bodyPr.fromPPTY(pReader);
bodyPr = new Logic::BodyPr();
bodyPr->fromPPTY(pReader);
break;
}
case 1:
......@@ -206,15 +255,17 @@ namespace PPTX
}
public:
BodyPr bodyPr;
nullable<BodyPr> bodyPr;
nullable<TextListStyle> lstStyle;
std::vector<Paragraph> Paragrs;
std::wstring m_ns;
std::wstring m_name;
protected:
virtual void FillParentPointersForChilds()
{
bodyPr.SetParentPointer(this);
if(bodyPr.is_init())
bodyPr->SetParentPointer(this);
if(lstStyle.is_init())
lstStyle->SetParentPointer(this);
......@@ -226,9 +277,11 @@ namespace PPTX
public:
bool IsOneLineParagraphs() const
{
if (!bodyPr.wrap.is_init())
return false;
return (bodyPr.wrap->get() == _T("none"));
if (!bodyPr.is_init()) return false;
if (!bodyPr->wrap.is_init()) return false;
return (bodyPr->wrap->get() == _T("none"));
}
std::wstring GetDocxTxBoxContent(NSBinPptxRW::CBinaryFileWriter* pWriter, const nullable<PPTX::Logic::ShapeStyle>& shape_style);
......
......@@ -49,9 +49,35 @@ namespace PPTX
class UniPath2D : public WrapperWritingElement
{
public:
PPTX_LOGIC_BASE(UniPath2D)
WritingElement_AdditionConstructors(UniPath2D)
PPTX_LOGIC_BASE2(UniPath2D)
public:
virtual OOX::EElementType getType() const
{
if (Path2D.IsInit())
return Path2D->getType();
return OOX::et_Unknown;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName());
if (name == _T("moveTo"))
Path2D.reset(new Logic::MoveTo(oReader));
else if (name == _T("lnTo"))
Path2D.reset(new Logic::LineTo(oReader));
else if (name == _T("cubicBezTo"))
Path2D.reset(new Logic::CubicBezTo(oReader));
else if (name == _T("close"))
Path2D.reset(new Logic::Close(oReader));
else if (name == _T("arcTo"))
Path2D.reset(new Logic::ArcTo(oReader));
else if (name == _T("quadBezTo"))
Path2D.reset(new Logic::QuadBezTo(oReader));
else Path2D.reset();
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
std::wstring name = XmlUtils::GetNameNoNS(node.GetName());
......
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="PPTXFormat"
ProjectGUID="{36636678-AE25-4BE6-9A34-2561D1BCF302}"
RootNamespace="PPTXFormat"
......
......@@ -249,6 +249,7 @@ namespace OOX
et_a_latin, // <a:latin>
et_a_lightRig, // <a:lightRig>
et_a_lin, // <a:lin>
et_a_lineTo, // <a:lineTo>
et_a_ln, // <a:ln>
et_a_lnDef, // <a:lnDef>
et_a_lnRef, // <a:lnRef>
......
......@@ -41,6 +41,9 @@
#include "../DocxFormat/Drawing/DrawingTextProperties.h"
#include "../DocxFormat/Drawing/DrawingParagraph.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpPr.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxBody.h"
#include "ComplexTypes_Spreadsheet.h"
#include "FileTypes_Spreadsheet.h"
#include "WritingElement.h"
......
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="X2tTest"
ProjectGUID="{355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}"
RootNamespace="X2tTest"
......@@ -356,12 +356,16 @@
<Filter
Name="Common"
>
<File
RelativePath="..\..\..\XlsxSerializerCom\Writer\BinaryReader.h"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Common\BinReaderWriterDefines.h"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Common\Common.cpp"
RelativePath="..\..\..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -376,33 +380,16 @@
>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/bigobj"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Common\Common.h"
>
</File>
<File
RelativePath="..\..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
</Filter>
<Filter
Name="Reader"
>
<File
RelativePath="..\..\..\XlsxSerializerCom\Writer\BinaryCommonReader.h"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Writer\BinaryReader.h"
RelativePath="..\..\..\XlsxSerializerCom\Reader\ChartFromToBinary.h"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\CSVReader.cpp"
RelativePath="..\..\..\XlsxSerializerCom\Common\Common.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -417,24 +404,29 @@
>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/bigobj"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\CSVReader.h"
RelativePath="..\..\..\XlsxSerializerCom\Common\Common.h"
>
</File>
<File
RelativePath="..\..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
</Filter>
<Filter
Name="Writer"
Name="Reader"
>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\BinaryWriter.h"
RelativePath="..\..\..\XlsxSerializerCom\Writer\BinaryCommonReader.h"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
RelativePath="..\..\..\XlsxSerializerCom\Reader\CSVReader.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -454,7 +446,15 @@
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\ChartFromToBinary.h"
RelativePath="..\..\..\XlsxSerializerCom\Reader\CSVReader.h"
>
</File>
</Filter>
<Filter
Name="Writer"
>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\BinaryWriter.h"
>
</File>
<File
......
......@@ -59,7 +59,6 @@ namespace BinXlsxRW {
int ReadCT_RelId (long length, CT_RelId* poResult);
private:
std::wstring* GetRecordXml (long length, int nRecordType);
std::wstring* GetTxBodyXml (long length);
int ReadCT_extLst (BYTE type, long length, void* poResult);
int ReadCT_ChartSpace (BYTE type, long length, void* poResult);
......@@ -201,6 +200,8 @@ namespace BinXlsxRW {
int ReadAlternateContent (BYTE type, long length, void* poResult);
int ReadAlternateContentChoice (BYTE type, long length, void* poResult);
int ReadAlternateContentFallback(BYTE type, long length, void* poResult);
int ReadCT_SpPr (BYTE type, long length, void* poResult);
int ReadCT_TxPr (BYTE type, long length, void* poResult);
};
class BinaryChartWriter
{
......@@ -348,15 +349,14 @@ namespace BinXlsxRW {
void WriteAlternateContent(AlternateContent& oVal);
void WriteAlternateContentChoice(AlternateContentChoice& oVal);
void WriteAlternateContentFallback(AlternateContentFallback& oVal);
private:
void toBin(ItemsChoiceType5 eType, void* pVal);
void toBin(ItemsChoiceType6 eType, void* pVal);
void toBin(ItemsChoiceType4 eType, void* pVal);
void GetRecordBinary(int nType, std::wstring& sXml, int nRecordType);
void GetTxBodyBinary(int nType, std::wstring& sXml);
void toBin(ItemsChoiceType3 eType, void* pVal);
void GetRecordBinary(int nType, std::wstring& sXml, int nRecordType);
};
}
#endif // #ifndef CHART_FROM_TO_BINARY
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