Commit a75daf9d authored by ElenaSubbotina's avatar ElenaSubbotina

x2t binary - dont write unsupported graphicData (sle:slicer)

parent dc81f97b
...@@ -5506,18 +5506,18 @@ namespace BinDocxRW ...@@ -5506,18 +5506,18 @@ namespace BinDocxRW
m_oBcw.m_oStream.StartRecord(0); m_oBcw.m_oStream.StartRecord(0);
m_oBcw.m_oStream.StartRecord(1); m_oBcw.m_oStream.StartRecord(1);
if (pGraphic->olePic.IsInit()) if (pGraphic->olePic.is_init())
{ {
pGraphic->olePic->toPPTY(&m_oBcw.m_oStream); pGraphic->olePic->toPPTY(&m_oBcw.m_oStream);
} }
else if (pGraphic->smartArt.IsInit()) else if (pGraphic->smartArt.is_init())
{ {
pGraphic->smartArt->LoadDrawing(&m_oBcw.m_oStream); pGraphic->smartArt->LoadDrawing(&m_oBcw.m_oStream);
pGraphic->smartArt->toPPTY(&m_oBcw.m_oStream); pGraphic->smartArt->toPPTY(&m_oBcw.m_oStream);
} }
else if (pGraphic->element.IsInit()) else if (pGraphic->element.is_init())
{ {
pGraphic->element->toPPTY(&m_oBcw.m_oStream); pGraphic->element.toPPTY(&m_oBcw.m_oStream);
} }
m_oBcw.m_oStream.EndRecord(); m_oBcw.m_oStream.EndRecord();
m_oBcw.m_oStream.EndRecord(); m_oBcw.m_oStream.EndRecord();
......
...@@ -85,27 +85,27 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame) ...@@ -85,27 +85,27 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
convert(&oox_graphic_frame->nvGraphicFramePr); convert(&oox_graphic_frame->nvGraphicFramePr);
convert(oox_graphic_frame->xfrm.GetPointer()); convert(oox_graphic_frame->xfrm.GetPointer());
if ( oox_graphic_frame->chartRec.IsInit()) if ( oox_graphic_frame->chartRec.is_init())
{ {
convert(oox_graphic_frame->chartRec.GetPointer()); convert(oox_graphic_frame->chartRec.GetPointer());
} }
else if ( oox_graphic_frame->smartArt.IsInit()) else if ( oox_graphic_frame->smartArt.is_init())
{ {
OoxConverter::convert(oox_graphic_frame->smartArt.GetPointer()); OoxConverter::convert(oox_graphic_frame->smartArt.GetPointer());
} }
else if ( oox_graphic_frame->olePic.IsInit()) else if ( oox_graphic_frame->olePic.is_init())
{ {
OoxConverter::convert(oox_graphic_frame->olePic.GetPointer()); OoxConverter::convert(oox_graphic_frame->olePic.GetPointer());
} }
else if ( oox_graphic_frame->table.IsInit()) else if ( oox_graphic_frame->table.is_init())
{ {
PptxConverter *pptx_converter = dynamic_cast<PptxConverter *>(this); PptxConverter *pptx_converter = dynamic_cast<PptxConverter *>(this);
if (pptx_converter) if (pptx_converter)
pptx_converter->convert(oox_graphic_frame->table.GetPointer()); pptx_converter->convert(oox_graphic_frame->table.GetPointer());
} }
else if ( oox_graphic_frame->element.IsInit()) else if ( oox_graphic_frame->element.is_init())
{ {
OoxConverter::convert(oox_graphic_frame->element->GetElem().operator->()); OoxConverter::convert(oox_graphic_frame->element.GetElem().operator->());
} }
odf_context()->drawing_context()->end_drawing(); odf_context()->drawing_context()->end_drawing();
} }
......
...@@ -219,8 +219,8 @@ namespace PPTX ...@@ -219,8 +219,8 @@ namespace PPTX
} }
else else
{ {
element = oReader; element.fromXML( oReader );
if (element.IsInit()) if (element.is_init())
result = true; result = true;
} }
} }
...@@ -359,15 +359,21 @@ namespace PPTX ...@@ -359,15 +359,21 @@ namespace PPTX
pWriter->EndNode(namespace_ + L":graphicFrame"); pWriter->EndNode(namespace_ + L":graphicFrame");
} }
bool GraphicFrame::IsEmpty() const
{
return !olePic.is_init() && !smartArt.is_init() && !table.is_init() && !chartRec.is_init() && !oleSpid.is_init() && !element.is_init();
}
void GraphicFrame::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const void GraphicFrame::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{ {
if (IsEmpty())
return;
if (olePic.is_init()) if (olePic.is_init())
{ {
olePic->toPPTY(pWriter); olePic->toPPTY(pWriter);
return; return;
} }
if (!smartArt.is_init() && !table.is_init() && !chartRec.is_init() && !oleSpid.is_init() )
return;
std::wstring xml_object_vml; std::wstring xml_object_vml;
std::wstring xml_object_rels; std::wstring xml_object_rels;
...@@ -465,14 +471,22 @@ namespace PPTX ...@@ -465,14 +471,22 @@ namespace PPTX
pWriter->WriteRecord1(0, nvGraphicFramePr); pWriter->WriteRecord1(0, nvGraphicFramePr);
pWriter->WriteRecord2(1, xfrm); pWriter->WriteRecord2(1, xfrm);
pWriter->WriteRecord2(2, table);
if (chartRec.is_init()) if (table.is_init())
{
pWriter->WriteRecord2(2, table);
}
else if (chartRec.is_init())
{ {
pWriter->WriteRecord2(3, chartRec); pWriter->WriteRecord2(3, chartRec);
} }
else if (xml_object_vml.empty() == false) else if (element.is_init())
{
pWriter->WriteRecord1(4, element);
}
else
{ {
//????
} }
pWriter->EndRecord(); pWriter->EndRecord();
......
...@@ -82,6 +82,8 @@ namespace PPTX ...@@ -82,6 +82,8 @@ namespace PPTX
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
bool IsEmpty()const;
std::wstring m_namespace; std::wstring m_namespace;
NvGraphicFramePr nvGraphicFramePr; NvGraphicFramePr nvGraphicFramePr;
...@@ -94,7 +96,8 @@ namespace PPTX ...@@ -94,7 +96,8 @@ namespace PPTX
nullable<Table> table; nullable<Table> table;
nullable<SmartArt> smartArt; nullable<SmartArt> smartArt;
nullable<ChartRec> chartRec; nullable<ChartRec> chartRec;
nullable<SpTreeElem> element;
SpTreeElem element;
std::wstring GetVmlXmlBySpid(std::wstring & rels) const; std::wstring GetVmlXmlBySpid(std::wstring & rels) const;
protected: protected:
......
...@@ -244,7 +244,14 @@ namespace PPTX ...@@ -244,7 +244,14 @@ namespace PPTX
else if (name == _T("grpSp") || name == _T("wgp") || name == _T("spTree") || name == _T("lockedCanvas")) else if (name == _T("grpSp") || name == _T("wgp") || name == _T("spTree") || name == _T("lockedCanvas"))
m_elem.reset(new Logic::SpTree(oReader)); m_elem.reset(new Logic::SpTree(oReader));
else if (name == _T("graphicFrame")) else if (name == _T("graphicFrame"))
m_elem.reset(new Logic::GraphicFrame(oReader)); {
Logic::GraphicFrame *pGraphic = new Logic::GraphicFrame(oReader);
if (pGraphic && pGraphic->IsEmpty() == false)
m_elem.reset(pGraphic);
else
RELEASEOBJECT(pGraphic);
}
else if (name == _T("AlternateContent")) else if (name == _T("AlternateContent"))
{ {
if ( oReader.IsEmptyNode() ) if ( oReader.IsEmptyNode() )
......
...@@ -40,16 +40,16 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput) ...@@ -40,16 +40,16 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
{ {
if (m_ooxGraphic == NULL) return 0; if (m_ooxGraphic == NULL) return 0;
if (m_ooxGraphic->element.IsInit()) if (m_ooxGraphic->element.is_init())
{ {
if (m_ooxGraphic->element->getType() == OOX::et_p_ShapeTree) if (m_ooxGraphic->element.getType() == OOX::et_p_ShapeTree)
{ {
OOXShapeReader shapeReader(m_ooxGraphic->element->GetElem().operator->()); OOXShapeReader shapeReader(m_ooxGraphic->element.GetElem().operator->());
return (shapeReader.Parse(oParam, pOutput) ? 1 : 0); return (shapeReader.Parse(oParam, pOutput) ? 1 : 0);
} }
else else
{ {
OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->element->GetElem().operator->())); OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->element.GetElem().operator->()));
return (groupReader.Parse(oParam, pOutput) ? 1 : 0); return (groupReader.Parse(oParam, pOutput) ? 1 : 0);
} }
} }
......
...@@ -190,7 +190,9 @@ namespace OOX ...@@ -190,7 +190,9 @@ namespace OOX
SimpleTypes::Spreadsheet::ECellAnchorType eAnchorType = m_oAnchorType.GetValue(); SimpleTypes::Spreadsheet::ECellAnchorType eAnchorType = m_oAnchorType.GetValue();
if(!((m_oFrom.IsInit() && m_oTo.IsInit()) || (m_oFrom.IsInit() && m_oExt.IsInit()) || (m_oPos.IsInit() && m_oExt.IsInit()))) if(!((m_oFrom.IsInit() && m_oTo.IsInit()) || (m_oFrom.IsInit() && m_oExt.IsInit()) || (m_oPos.IsInit() && m_oExt.IsInit())))
return false; return false;
if(false == m_oElement.IsInit()) if(false == m_oElement.is_init())
return false;
if(false == m_oElement->is_init())
return false; return false;
return true; return true;
} }
......
...@@ -2779,6 +2779,9 @@ namespace BinXlsxRW ...@@ -2779,6 +2779,9 @@ namespace BinXlsxRW
void WriteDrawing(const OOX::Spreadsheet::CWorksheet& oWorksheet, OOX::Spreadsheet::CDrawing* pDrawing, OOX::Spreadsheet::CCellAnchor* pCellAnchor, std::wstring& sDrawingRelsPath, OOX::CVmlDrawing *pVmlDrawing = NULL, OOX::Spreadsheet::COleObject* pOleObject = NULL) void WriteDrawing(const OOX::Spreadsheet::CWorksheet& oWorksheet, OOX::Spreadsheet::CDrawing* pDrawing, OOX::Spreadsheet::CCellAnchor* pCellAnchor, std::wstring& sDrawingRelsPath, OOX::CVmlDrawing *pVmlDrawing = NULL, OOX::Spreadsheet::COleObject* pOleObject = NULL)
{ {
if (!pCellAnchor) return; if (!pCellAnchor) return;
if (pCellAnchor->m_oElement.IsInit() == false &&
pCellAnchor->m_sSpId.IsInit() == false) return;
//Type //Type
int nCurPos; int nCurPos;
nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::Type); nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::Type);
...@@ -2819,13 +2822,12 @@ namespace BinXlsxRW ...@@ -2819,13 +2822,12 @@ namespace BinXlsxRW
if (pFind != pVmlDrawing->m_mapShapes.end() && !pFind->second.bUsed) if (pFind != pVmlDrawing->m_mapShapes.end() && !pFind->second.bUsed)
{ {
pFind->second.bUsed = true; pFind->second.bUsed = true;
std::wstring sVmlXml;
std::wstring sVmlXml = L"<v:object>";
sVmlXml += pFind->second.sXml; //add vml shape xml
if (pCellAnchor->m_bShapeOle && NULL != pOleObject) if (pCellAnchor->m_bShapeOle && NULL != pOleObject)
{ {
sVmlXml += L"<v:object>";
sVmlXml += pFind->second.sXml; //add vml shape xml
//ищем физический файл, потому что rId относительно sheet.xml, а SetRelsPath(pVmlDrawing //ищем физический файл, потому что rId относительно sheet.xml, а SetRelsPath(pVmlDrawing
smart_ptr<OOX::File> pFile = oWorksheet.Find(OOX::RId(pOleObject->m_oRid->GetValue())); smart_ptr<OOX::File> pFile = oWorksheet.Find(OOX::RId(pOleObject->m_oRid->GetValue()));
pOleObject->m_OleObjectFile = pFile.smart_dynamic_cast<OOX::OleObject>(); pOleObject->m_OleObjectFile = pFile.smart_dynamic_cast<OOX::OleObject>();
...@@ -2834,10 +2836,8 @@ namespace BinXlsxRW ...@@ -2834,10 +2836,8 @@ namespace BinXlsxRW
pOleObject->toXMLPptx(writer, L""); pOleObject->toXMLPptx(writer, L"");
sVmlXml += writer.GetData(); sVmlXml += writer.GetData();
sVmlXml += L"</v:object>";
} }
else sVmlXml += L"</v:object>";
sVmlXml = pFind->second.sXml; //add vml shape xml
std::wstring keepRels = m_pOfficeDrawingConverter->GetRelsPath(); std::wstring keepRels = m_pOfficeDrawingConverter->GetRelsPath();
m_pOfficeDrawingConverter->SetRelsPath(pVmlDrawing->GetReadPath().GetPath()); m_pOfficeDrawingConverter->SetRelsPath(pVmlDrawing->GetReadPath().GetPath());
......
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