Commit 5d8dda02 authored by ElenaSubbotina's avatar ElenaSubbotina

pptx extended reading fix

parent bc346114
......@@ -75,9 +75,9 @@ namespace PPTX
int nParentDepth = oReader.GetDepth();
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);
}
......@@ -98,8 +98,8 @@ namespace PPTX
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
XmlUtils::CXmlNode oNode;
if (node.GetNode(_T("a:graphicFrameLocks"), oNode))
XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(L"graphicFrameLocks");
if (oNode.IsValid())
{
oNode.ReadAttributeBase(L"noChangeAspect", noChangeAspect);
oNode.ReadAttributeBase(L"noDrilldown", noDrilldown);
......@@ -120,7 +120,7 @@ namespace PPTX
oAttr.Write(_T("noResize"), noResize);
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
......@@ -128,6 +128,7 @@ namespace PPTX
std::wstring namespace_ = m_namespace;
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");
......
......@@ -94,7 +94,7 @@ namespace PPTX
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("a:picLocks") == strName)
if (_T("picLocks") == strName)
{
ReadAttributesLocks(oReader);
}
......
......@@ -82,6 +82,9 @@ namespace PPTX
if (sName == L"a:avLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......@@ -97,6 +100,9 @@ namespace PPTX
}
else if (sName == L"a:gdLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......@@ -114,6 +120,9 @@ namespace PPTX
rect = oReader;
else if (sName == L"a:pathLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......@@ -129,6 +138,9 @@ namespace PPTX
}
else if (sName == L"a:ahLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......@@ -150,6 +162,9 @@ namespace PPTX
}
else if (sName == L"a:cxnLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......
......@@ -77,7 +77,7 @@ namespace PPTX
virtual void fromXML(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_else_if( oReader, _T("r:link"), link )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate )
......
......@@ -84,27 +84,15 @@ namespace PPTX
{
std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName());
if (_T("blip") == strName)
{
if (!blip.IsInit())
blip = oReader;
}
else if (_T("srcRect") == strName)
{
if (!srcRect.IsInit())
srcRect = oReader;
}
else if (_T("tile") == strName)
{
if (!tile.IsInit())
tile = oReader;
}
else if (_T("stretch") == strName)
{
if (!stretch.IsInit())
stretch = oReader;
}
}
}
virtual OOX::EElementType getType () const
{
return OOX::et_a_blipFill;
......
......@@ -98,6 +98,9 @@ namespace PPTX
tileRect = oReader;
else if (_T("gsLst") == strName)
{
if ( oReader.IsEmptyNode() )
continue;
int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{
......
......@@ -72,9 +72,48 @@ namespace PPTX
}
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)
{
m_namespace = XmlUtils::GetNamespace(node.GetName());
node.ReadAttributeBase(L"bwMode", bwMode);
XmlUtils::CXmlNodes oNodes;
......
......@@ -80,6 +80,9 @@ namespace PPTX
ph = oReader;
else if (strName == L"extLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......
......@@ -138,6 +138,9 @@ namespace PPTX
RunElems.push_back(RunElem(oReader));
else if (_T("AlternateContent") == strName)
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......
......@@ -75,6 +75,9 @@ namespace PPTX
if (sName == L"a:avLst")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......@@ -95,7 +98,7 @@ namespace PPTX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("r:prst"), prst)
WritingElement_ReadAttributes_ReadSingle( oReader, _T("prst"), prst)
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node)
......
......@@ -75,6 +75,9 @@ namespace PPTX
if (_T("a:avLst") == strName)
{
if ( oReader.IsEmptyNode() )
continue;
int nCurDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth1 ) )
{
......
......@@ -171,7 +171,7 @@ namespace PPTX
virtual std::wstring toXML() const
{
std::wstring name_;
if (m_namespace == L"wpg")
if (m_namespace == L"wp")
{
if (m_lGroupIndex == 0) name_ = L"wpg:wgp";
else name_ = L"wpg:grpSp";
......
......@@ -86,6 +86,9 @@ namespace PPTX
if (strName == L"tblGrid")
{
if ( oReader.IsEmptyNode() )
continue;
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
......
......@@ -107,25 +107,36 @@ namespace PPTX
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
std::wstring strName = oReader.GetName();
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
if (_T("a:noAutofit") == strName)
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)
{
nullable_string sFontScale;
nullable_string sLnSpcRed;
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 )
Normalize(sFontScale, sLnSpcRed);
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
type = FitEmpty;
std::wstring strName = XmlUtils::GetNameNoNS(node.GetName());
std::wstring strName = node.GetName();
if (_T("a:noAutofit") == strName)
type = FitNo;
......@@ -141,33 +152,7 @@ namespace PPTX
node.ReadAttributeBase(L"fontScale", sFontScale);
node.ReadAttributeBase(L"lnSpcReduction", 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;
}
}
Normalize(sFontScale, sLnSpcRed);
}
}
virtual std::wstring toXML() const
......@@ -287,6 +272,37 @@ namespace PPTX
nullable_int lnSpcReduction;
protected:
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 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