Commit a75daf9d authored by ElenaSubbotina's avatar ElenaSubbotina

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

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