Commit 5d8dda02 authored by ElenaSubbotina's avatar ElenaSubbotina

pptx extended reading fix

parent bc346114
...@@ -75,9 +75,9 @@ namespace PPTX ...@@ -75,9 +75,9 @@ namespace PPTX
int nParentDepth = oReader.GetDepth(); int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) ) while( oReader.ReadNextSiblingNode( nParentDepth ) )
{ {
std::wstring strName = oReader.GetName(); std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (strName == L"a:graphicFrameLocks") if (strName == L"graphicFrameLocks")
{ {
ReadAttributesLocks(oReader); ReadAttributesLocks(oReader);
} }
...@@ -98,29 +98,29 @@ namespace PPTX ...@@ -98,29 +98,29 @@ namespace PPTX
{ {
m_namespace = XmlUtils::GetNamespace(node.GetName()); m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNode oNode; XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(L"graphicFrameLocks");
if (node.GetNode(_T("a:graphicFrameLocks"), oNode)) if (oNode.IsValid())
{ {
oNode.ReadAttributeBase(L"noChangeAspect", noChangeAspect); oNode.ReadAttributeBase(L"noChangeAspect", noChangeAspect);
oNode.ReadAttributeBase(L"noDrilldown", noDrilldown); oNode.ReadAttributeBase(L"noDrilldown", noDrilldown);
oNode.ReadAttributeBase(L"noGrp", noGrp); oNode.ReadAttributeBase(L"noGrp", noGrp);
oNode.ReadAttributeBase(L"noMove", noMove); oNode.ReadAttributeBase(L"noMove", noMove);
oNode.ReadAttributeBase(L"noResize", noResize); oNode.ReadAttributeBase(L"noResize", noResize);
oNode.ReadAttributeBase(L"noSelect", noSelect); oNode.ReadAttributeBase(L"noSelect", noSelect);
} }
} }
virtual std::wstring toXML() const virtual std::wstring toXML() const
{ {
XmlUtils::CAttribute oAttr; XmlUtils::CAttribute oAttr;
oAttr.Write(_T("noChangeAspect"), noChangeAspect); oAttr.Write(_T("noChangeAspect"), noChangeAspect);
oAttr.Write(_T("noDrilldown"), noDrilldown); oAttr.Write(_T("noDrilldown"), noDrilldown);
oAttr.Write(_T("noGrp"), noGrp); oAttr.Write(_T("noGrp"), noGrp);
oAttr.Write(_T("noMove"), noMove); oAttr.Write(_T("noMove"), noMove);
oAttr.Write(_T("noResize"), noResize); oAttr.Write(_T("noResize"), noResize);
oAttr.Write(_T("noSelect"), noSelect); oAttr.Write(_T("noSelect"), noSelect);
return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr>", XmlUtils::CreateNode(_T("a:graphicFrameLocks"), oAttr)); return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", oAttr.m_strValue.empty() ? L"" : XmlUtils::CreateNode(L"a:graphicFrameLocks", oAttr));
} }
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
...@@ -128,6 +128,7 @@ namespace PPTX ...@@ -128,6 +128,7 @@ namespace PPTX
std::wstring namespace_ = m_namespace; std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wp";
pWriter->StartNode(namespace_ + L":cNvGraphicFramePr"); pWriter->StartNode(namespace_ + L":cNvGraphicFramePr");
......
...@@ -94,7 +94,7 @@ namespace PPTX ...@@ -94,7 +94,7 @@ namespace PPTX
{ {
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("a:picLocks") == strName) if (_T("picLocks") == strName)
{ {
ReadAttributesLocks(oReader); ReadAttributesLocks(oReader);
} }
......
...@@ -82,6 +82,9 @@ namespace PPTX ...@@ -82,6 +82,9 @@ namespace PPTX
if (sName == L"a:avLst") if (sName == L"a:avLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
...@@ -97,6 +100,9 @@ namespace PPTX ...@@ -97,6 +100,9 @@ namespace PPTX
} }
else if (sName == L"a:gdLst") else if (sName == L"a:gdLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
...@@ -114,6 +120,9 @@ namespace PPTX ...@@ -114,6 +120,9 @@ namespace PPTX
rect = oReader; rect = oReader;
else if (sName == L"a:pathLst") else if (sName == L"a:pathLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
...@@ -129,6 +138,9 @@ namespace PPTX ...@@ -129,6 +138,9 @@ namespace PPTX
} }
else if (sName == L"a:ahLst") else if (sName == L"a:ahLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
...@@ -150,6 +162,9 @@ namespace PPTX ...@@ -150,6 +162,9 @@ namespace PPTX
} }
else if (sName == L"a:cxnLst") else if (sName == L"a:cxnLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
......
...@@ -77,7 +77,7 @@ namespace PPTX ...@@ -77,7 +77,7 @@ namespace PPTX
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{ {
WritingElement_ReadAttributes_Start_No_NS( oReader ) WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:embed"), embed) WritingElement_ReadAttributes_Read_if ( oReader, _T("r:embed"), embed)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("r:link"), link ) WritingElement_ReadAttributes_Read_else_if( oReader, _T("r:link"), link )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate ) WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate )
......
...@@ -84,25 +84,13 @@ namespace PPTX ...@@ -84,25 +84,13 @@ namespace PPTX
{ {
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("blip") == strName) if (_T("blip") == strName)
{ blip = oReader;
if (!blip.IsInit())
blip = oReader;
}
else if (_T("srcRect") == strName) else if (_T("srcRect") == strName)
{ srcRect = oReader;
if (!srcRect.IsInit())
srcRect = oReader;
}
else if (_T("tile") == strName) else if (_T("tile") == strName)
{ tile = oReader;
if (!tile.IsInit())
tile = oReader;
}
else if (_T("stretch") == strName) else if (_T("stretch") == strName)
{ stretch = oReader;
if (!stretch.IsInit())
stretch = oReader;
}
} }
} }
virtual OOX::EElementType getType () const virtual OOX::EElementType getType () const
......
...@@ -98,6 +98,9 @@ namespace PPTX ...@@ -98,6 +98,9 @@ namespace PPTX
tileRect = oReader; tileRect = oReader;
else if (_T("gsLst") == strName) else if (_T("gsLst") == strName)
{ {
if ( oReader.IsEmptyNode() )
continue;
int nCurDepth1 = oReader.GetDepth(); int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) ) while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{ {
......
...@@ -72,9 +72,48 @@ namespace PPTX ...@@ -72,9 +72,48 @@ namespace PPTX
} }
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) virtual void 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"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);
}
}
FillParentPointersForChilds();
} }
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("bwMode"), bwMode )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
m_namespace = XmlUtils::GetNamespace(node.GetName());
node.ReadAttributeBase(L"bwMode", bwMode); node.ReadAttributeBase(L"bwMode", bwMode);
XmlUtils::CXmlNodes oNodes; XmlUtils::CXmlNodes oNodes;
......
...@@ -80,6 +80,9 @@ namespace PPTX ...@@ -80,6 +80,9 @@ namespace PPTX
ph = oReader; ph = oReader;
else if (strName == L"extLst") else if (strName == L"extLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
......
...@@ -138,6 +138,9 @@ namespace PPTX ...@@ -138,6 +138,9 @@ namespace PPTX
RunElems.push_back(RunElem(oReader)); RunElems.push_back(RunElem(oReader));
else if (_T("AlternateContent") == strName) else if (_T("AlternateContent") == strName)
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
......
...@@ -75,6 +75,9 @@ namespace PPTX ...@@ -75,6 +75,9 @@ namespace PPTX
if (sName == L"a:avLst") if (sName == L"a:avLst")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
...@@ -95,7 +98,7 @@ namespace PPTX ...@@ -95,7 +98,7 @@ namespace PPTX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{ {
WritingElement_ReadAttributes_Start( oReader ) WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("r:prst"), prst) WritingElement_ReadAttributes_ReadSingle( oReader, _T("prst"), prst)
WritingElement_ReadAttributes_End( oReader ) WritingElement_ReadAttributes_End( oReader )
} }
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
......
...@@ -75,6 +75,9 @@ namespace PPTX ...@@ -75,6 +75,9 @@ namespace PPTX
if (_T("a:avLst") == strName) if (_T("a:avLst") == strName)
{ {
if ( oReader.IsEmptyNode() )
continue;
int nCurDepth1 = oReader.GetDepth(); int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) ) while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{ {
......
...@@ -171,7 +171,7 @@ namespace PPTX ...@@ -171,7 +171,7 @@ namespace PPTX
virtual std::wstring toXML() const virtual std::wstring toXML() const
{ {
std::wstring name_; std::wstring name_;
if (m_namespace == L"wpg") if (m_namespace == L"wp")
{ {
if (m_lGroupIndex == 0) name_ = L"wpg:wgp"; if (m_lGroupIndex == 0) name_ = L"wpg:wgp";
else name_ = L"wpg:grpSp"; else name_ = L"wpg:grpSp";
......
...@@ -86,6 +86,9 @@ namespace PPTX ...@@ -86,6 +86,9 @@ namespace PPTX
if (strName == L"tblGrid") if (strName == L"tblGrid")
{ {
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth(); int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{ {
......
...@@ -107,25 +107,36 @@ namespace PPTX ...@@ -107,25 +107,36 @@ namespace PPTX
} }
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{ {
ReadAttributes( oReader ); std::wstring strName = oReader.GetName();
int nCurDepth = oReader.GetDepth(); if (_T("a:noAutofit") == strName)
while( oReader.ReadNextSiblingNode( nCurDepth ) ) type = FitNo;
else if (_T("a:spAutoFit") == strName)
type = FitSpAuto;
else if (_T("a:normAutofit") == strName)
{ {
std::wstring sName = oReader.GetName(); type = FitNormAuto;
ReadAttributes(oReader);
} }
} }
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{ {
nullable_string sFontScale;
nullable_string sLnSpcRed;
WritingElement_ReadAttributes_Start( oReader ) WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("fontScale"), sFontScale)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lnSpcReduction"), sLnSpcRed)
WritingElement_ReadAttributes_End( oReader ) WritingElement_ReadAttributes_End( oReader )
Normalize(sFontScale, sLnSpcRed);
} }
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
type = FitEmpty; type = FitEmpty;
std::wstring strName = XmlUtils::GetNameNoNS(node.GetName()); std::wstring strName = node.GetName();
if (_T("a:noAutofit") == strName) if (_T("a:noAutofit") == strName)
type = FitNo; type = FitNo;
...@@ -141,33 +152,7 @@ namespace PPTX ...@@ -141,33 +152,7 @@ namespace PPTX
node.ReadAttributeBase(L"fontScale", sFontScale); node.ReadAttributeBase(L"fontScale", sFontScale);
node.ReadAttributeBase(L"lnSpcReduction", sLnSpcRed); node.ReadAttributeBase(L"lnSpcReduction", sLnSpcRed);
if (sFontScale.is_init()) Normalize(sFontScale, sLnSpcRed);
{
int nFound = (int)sFontScale->rfind(wchar_t('%'));
if (nFound < 0)
fontScale = *sFontScale;
else
{
std::wstring sRet = sFontScale->substr(0, nFound);
double dRet = XmlUtils::GetDouble(sRet);
int val = (int)(dRet * 1000);
fontScale = val;
}
}
if (sLnSpcRed.is_init())
{
int nFound = (int)sLnSpcRed->rfind(wchar_t('%'));
if (nFound < 0)
lnSpcReduction = *sLnSpcRed;
else
{
std::wstring sRet = sLnSpcRed->substr(0, nFound);
double dRet = XmlUtils::GetDouble(sRet);
int val = (int)(dRet * 1000);
lnSpcReduction = val;
}
}
} }
} }
virtual std::wstring toXML() const virtual std::wstring toXML() const
...@@ -287,6 +272,37 @@ namespace PPTX ...@@ -287,6 +272,37 @@ namespace PPTX
nullable_int lnSpcReduction; nullable_int lnSpcReduction;
protected: protected:
virtual void FillParentPointersForChilds(){} virtual void FillParentPointersForChilds(){}
void Normalize(nullable_string & sFontScale, nullable_string & sLnSpcRed)
{
if (sFontScale.is_init())
{
int nFound = (int)sFontScale->rfind(wchar_t('%'));
if (nFound < 0)
fontScale = *sFontScale;
else
{
std::wstring sRet = sFontScale->substr(0, nFound);
double dRet = XmlUtils::GetDouble(sRet);
int val = (int)(dRet * 1000);
fontScale = val;
}
}
if (sLnSpcRed.is_init())
{
int nFound = (int)sLnSpcRed->rfind(wchar_t('%'));
if (nFound < 0)
lnSpcReduction = *sLnSpcRed;
else
{
std::wstring sRet = sLnSpcRed->substr(0, nFound);
double dRet = XmlUtils::GetDouble(sRet);
int val = (int)(dRet * 1000);
lnSpcReduction = val;
}
}
}
}; };
} // namespace Logic } // namespace Logic
} // namespace PPTX } // namespace PPTX
......
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