/* * (c) Copyright Ascensio System SIA 2010-2017 * * This program is a free software product. You can redistribute it and/or * modify it under the terms of the GNU Affero General Public License (AGPL) * version 3 as published by the Free Software Foundation. In accordance with * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect * that Ascensio System SIA expressly excludes the warranty of non-infringement * of any third-party rights. * * This program is distributed WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html * * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * EU, LV-1021. * * The interactive user interfaces in modified source and object code versions * of the Program must display Appropriate Legal Notices, as required under * Section 5 of the GNU AGPL version 3. * * Pursuant to Section 7(b) of the License you must retain the original Product * logo when distributing the program. Pursuant to Section 7(e) we decline to * grant you any rights under trademark law for use of our trademarks. * * All the Product's GUI elements, including illustrations and icon sets, as * well as technical writing content are licensed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International. See the License * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ #include "OOXPictureGraphicReader.h" #include "OOXDrawingGraphicReader.h" #include "OOXShapeReader.h" #include "../../../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Theme.h" int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput) { if (m_ooxGraphic == NULL) return 0; bool bTryPicture = false; switch(m_ooxGraphic->m_eGraphicType) { case OOX::Drawing::graphictypeShape: { for (size_t i = 0; i < m_ooxGraphic->m_arrItems.size(); i++) { if (m_ooxGraphic->m_arrItems[i] == NULL) continue; if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_w_Shape) { OOXShapeReader shapeReader(dynamic_cast(m_ooxGraphic->m_arrItems[i])); return (shapeReader.Parse(oParam, pOutput) ? 1 : 0); } } }break; case OOX::Drawing::graphictypeGroupShape: { for (size_t i = 0; i < m_ooxGraphic->m_arrItems.size(); i++) { if (m_ooxGraphic->m_arrItems[i] == NULL) continue; if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_w_GroupShape) { OOXShapeGroupReader groupReader(dynamic_cast(m_ooxGraphic->m_arrItems[i])); return (groupReader.Parse(oParam, pOutput) ? 1 : 0); } } }break; case OOX::Drawing::graphictypePicture: case OOX::Drawing::graphictypeLockedCanvas: case OOX::Drawing::graphictypeChart: case OOX::Drawing::graphictypeDiagram: {//find picture or replacement picture for (size_t i = 0; i < m_ooxGraphic->m_arrItems.size(); i++) { if (m_ooxGraphic->m_arrItems[i] == NULL) continue; if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_pic_pic) { pOutput->m_nShapeType = 75; OOX::Drawing::CPicture *picture = dynamic_cast(m_ooxGraphic->m_arrItems[i]); if (picture) if (OOXShapeReader::Parse(oParam, pOutput, &picture->m_oBlipFill)) return 1; } } }break; } return 2; } //OOX::Logic::CPicture* OOX::Logic::CDrawing* OOXDrawingGraphicConverter::Convert( ReaderParameter oParam , RtfShapePtr pOutput) { NSBinPptxRW::CDrawingConverter drawingConverter; OOX::CTheme *pTheme = oParam.oDocx->GetTheme(); if (pTheme) { NSCommon::smart_ptr theme(new PPTX::Theme()); PPTX::FileMap map; theme->read(pTheme->m_oReadPath, map); (*drawingConverter.m_pTheme) = theme.smart_dynamic_cast(); } drawingConverter.SetRelsPath(oParam.oDocx->m_pDocument->m_oReadPath.GetPath()); std::wstring sXml; sXml = drawingConverter.ObjectToDrawingML(m_sXml, XMLWRITER_DOC_TYPE_DOCX); // sXml = drawingConverter.ObjectToVML(m_sXml); if (sXml.empty())return NULL; std::wstring sBegin (L"
"); std::wstring sEnd (L"
"); std::wstring strXml = sBegin + sXml + sEnd; XmlUtils::CXmlLiteReader oSubReader; if (oSubReader.FromString(strXml) == false) return NULL; oSubReader.ReadNextNode(); int nStylesDepth1 = oSubReader.GetDepth(); while ( oSubReader.ReadNextSiblingNode( nStylesDepth1 ) ) { std::wstring sName = oSubReader.GetName(); //if (sName == L"w:pict") //{ // return new OOX::Logic::CPicture(oSubReader); //} if (sName == L"w:drawing") { return new OOX::Logic::CDrawing(oSubReader); } } return NULL; //return pPict; }