Commit fc97b32d authored by ElenaSubbotina's avatar ElenaSubbotina

x2t - smart art objects (move in pptx drawing); fix users file pptx with smart art

parent a63aa930
......@@ -33,16 +33,23 @@
#include "../utils.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
#include "../../../Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
#include "../OdfFormat/odf_conversion_context.h"
#include "../OdfFormat/odf_text_context.h"
#include "../OdfFormat/odf_drawing_context.h"
using namespace cpdoccore;
namespace Oox2Odf
{
void OoxConverter::convert(OOX::Diagram::CShapeTree *oox_shape_tree)
double Emu2Pt(int emu)
{
return (1.0 * emu / (635 * 20.0));
}
void OoxConverter::convert(PPTX::Logic::SpTree *oox_shape_tree)
{
if (oox_shape_tree == NULL) return;
......@@ -51,70 +58,63 @@ void OoxConverter::convert(OOX::Diagram::CShapeTree *oox_shape_tree)
cpdoccore::_CP_OPT(double) x, y , ch_x , ch_y ;
odf_context()->drawing_context()->set_group_position(x, y, ch_x, ch_y);
for (long i=0 ;i < oox_shape_tree->m_arrItems.size(); i++)
for (long i=0 ;i < oox_shape_tree->SpTreeElems.size(); i++)
{
convert(oox_shape_tree->m_arrItems[i]);
convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->());
}
odf_context()->drawing_context()->end_group();
}
void OoxConverter::convert(OOX::Diagram::CShape *oox_shape)
void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
{
if (oox_shape == NULL) return;
if (!oox_shape->m_oSpPr.IsInit()) return;
odf_context()->drawing_context()->start_drawing();
int type = -1;
int type = 1000;
if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
{
OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
type =(geometry->m_oPrst.GetValue());
}
if (type < 0 && oox_shape->m_oSpPr->m_oCustGeom.IsInit())
PPTX::Logic::PrstGeom* prstGeom = &oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
if ( prstGeom )
{
type = 1000;//6??? - poligon, path нужно пересчитывать
SimpleTypes::CShapeType<> preset;
preset.FromString(prstGeom->prst.get());
type = preset.GetValue();
}
//if (oox_shape->m_oNvSpPr.IsInit() && oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit() && ?????
// oox_shape->m_oNvSpPr->m_oCNvSpPr->m_otxBox.GetValue() == 1) type = 2000; //textBox
if (type == SimpleTypes::shapetypeRect && oox_shape->m_oTxBody.IsInit()) type = 2000;
if (type == SimpleTypes::shapetypeRect && oox_shape->txBody.IsInit()) type = 2000;
if (type == 2000 && oox_shape->m_oTxBody->m_oBodyPr.IsInit() && oox_shape->m_oTxBody->m_oBodyPr->m_oFromWordArt.ToBool())
if (type == 2000 && oox_shape->txBody->bodyPr.fromWordArt.get_value_or(false))
{
int wordart_type = convert(oox_shape->m_oTxBody->m_oBodyPr->m_oPrstTxWrap.GetPointer());
int wordart_type = convert(oox_shape->txBody->bodyPr.prstTxWarp.GetPointer());
if (wordart_type >0)type = wordart_type;
if (wordart_type > 0) type = wordart_type;
}
if (type < 0)return;
/////////////////////////////////////////////////////////////////////////////////
odf_context()->drawing_context()->start_shape(type);
convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
convert(&oox_shape->spPr, oox_shape->style.GetPointer());
//имя, описалово, номер ...
//if (oox_shape->m_oNvSpPr.IsInit())
// convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer());
convert(&oox_shape->nvSpPr.cNvSpPr);
if ( oox_shape->m_oTxBody.IsInit() && oox_shape->m_oTxBody->m_arrItems.size() >0)
if ( oox_shape->txBody.IsInit() && oox_shape->txBody->Paragrs.size() >0)
{
odf_context()->start_text_context();
for (long i=0 ; i < oox_shape->m_oTxBody->m_arrItems.size();i++)
for (long i=0 ; i < oox_shape->txBody->Paragrs.size();i++)
{
convert(oox_shape->m_oTxBody->m_arrItems[i]);
convert(&oox_shape->txBody->Paragrs[i]);
}
odf_context()->drawing_context()->set_text( odf_context()->text_context());
//наложим внешние настройки для текста
convert(oox_shape->m_oTxBody->m_oBodyPr.GetPointer());
//наложим внешние настройки для текста
convert(&oox_shape->txBody->bodyPr);
if (oox_shape->m_oShapeStyle.IsInit() && oox_shape->m_oShapeStyle->m_oFontRef.getType() == OOX::et_a_fontRef)
if (oox_shape->style.IsInit())
{
convert(&oox_shape->m_oShapeStyle->m_oFontRef);
convert(&oox_shape->style->fontRef);
}
......@@ -125,4 +125,93 @@ void OoxConverter::convert(OOX::Diagram::CShape *oox_shape)
odf_context()->drawing_context()->end_drawing();
}
void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle* oox_sp_style)
{
if (oox_spPr == NULL) return;
bool use_fill_from_style = false;
bool use_line_from_style = false;
if (oox_spPr->xfrm.IsInit()) //CTransform2D
{
_CP_OPT(double) x, y, width, height;
if (oox_spPr->xfrm->offX.IsInit()) x = Emu2Pt(*oox_spPr->xfrm->offX);
if (oox_spPr->xfrm->offY.IsInit()) y = Emu2Pt(*oox_spPr->xfrm->offY);
odf_context()->drawing_context()->set_position( x, y);
if (oox_spPr->xfrm->extX.IsInit()) width = Emu2Pt(*oox_spPr->xfrm->extX);
if (oox_spPr->xfrm->extY.IsInit()) height = Emu2Pt(*oox_spPr->xfrm->extY);
odf_context()->drawing_context()->set_size( width, height);
if (oox_spPr->xfrm->flipH.get_value_or(false))
odf_context()->drawing_context()->set_flip_H(true);
if (oox_spPr->xfrm->flipV.get_value_or(false))
odf_context()->drawing_context()->set_flip_V(true);
if (oox_spPr->xfrm->rot.get_value_or(0) > 0)
odf_context()->drawing_context()->set_rotate(360. - oox_spPr->xfrm->rot.get_value_or(0)/60000.);
}
PPTX::Logic::PrstGeom* prstGeom = &oox_spPr->Geometry.as<PPTX::Logic::PrstGeom>();
PPTX::Logic::CustGeom* custGeom = &oox_spPr->Geometry.as<PPTX::Logic::CustGeom>();
convert(prstGeom);
convert(custGeom);
odf_context()->drawing_context()->start_area_properties();
{
PPTX::Logic::NoFill* noFill = &oox_spPr->Fill.as<PPTX::Logic::NoFill>();
PPTX::Logic::BlipFill* blipFill = &oox_spPr->Fill.as<PPTX::Logic::BlipFill>();
PPTX::Logic::GradFill* gradFill = &oox_spPr->Fill.as<PPTX::Logic::GradFill>();
PPTX::Logic::SolidFill* solidFill = &oox_spPr->Fill.as<PPTX::Logic::SolidFill>();
PPTX::Logic::PattFill* pattFill = &oox_spPr->Fill.as<PPTX::Logic::PattFill>();
if (solidFill) convert(solidFill);
else if (blipFill) convert(blipFill);
else if (gradFill) convert(gradFill);
else if (pattFill) convert(pattFill);
else if (noFill) odf_context()->drawing_context()->set_no_fill();
else use_fill_from_style = true;
if ( use_fill_from_style && oox_sp_style )
{
convert(&oox_sp_style->fillRef);
}
}
odf_context()->drawing_context()->end_area_properties();
odf_context()->drawing_context()->start_line_properties();
{
if (oox_spPr->ln.IsInit())
{
convert(oox_spPr->ln.GetPointer()); //CLineProperties
}
else if (oox_sp_style)
{
convert(&oox_sp_style->lnRef);
}
}
odf_context()->drawing_context()->end_line_properties();
//-----------------------------------------------------------------------------------------------------------------------------
PPTX::Logic::EffectLst* effectLst = &oox_spPr->EffectList.as<PPTX::Logic::EffectLst>();
if (effectLst) convert(effectLst);
else if (oox_sp_style) convert(&oox_sp_style->effectRef);
//nullable<OOX::Drawing::CEffectContainer> EffectDag;
//nullable<OOX::Drawing::COfficeArtExtensionList> ExtLst;
//nullable<OOX::Drawing::CScene3D> Scene3D;
//nullable<OOX::Drawing::CShape3D> Sp3D;
//-----------------------------------------------------------------------------------------------------------------------------
}
int OoxConverter::convert(PPTX::Logic::PrstTxWarp *oox_text_preset)
{
if (oox_text_preset == NULL) return -1;
if (oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextNoShape) return 2000;
return 2001 + oox_text_preset->prst.GetBYTECode();
}
}
......@@ -271,11 +271,11 @@ namespace OOX
class CRichText;
class CTextProperties;
}
namespace Diagram
{
class CShape;
class CShapeTree;
}
//namespace Diagram
//{
// class CShape;
// class CShapeTree;
//}
namespace Vml
{
class CShapeType;
......@@ -311,6 +311,17 @@ namespace SimpleTypes
class CCssStyle;
}
}
namespace PPTX
{
namespace Logic
{
class SpTree;
class Shape;
class SpPr;
class ShapeStyle;
class PrstTxWarp;
}
}
namespace Oox2Odf
{
......@@ -346,7 +357,7 @@ public:
OOX::IFileContainer *oox_current_child_document;
//.......................................................................................................................
void convert(OOX::WritingElement *oox_unknown);
void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf_types::font_size) & odf_font_size);
void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf_types::font_size) & odf_font_size);
//.drawing......................................................................................................................
void convert(OOX::Drawing::CLockedCanvas *oox_canvas);
......@@ -391,9 +402,11 @@ public:
void convert(OOX::Drawing::CRun *oox_run);
void convert(OOX::Drawing::CRunProperty *oox_run_pr, cpdoccore::odf_writer::style_text_properties * text_properties);
void convert(OOX::Drawing::CLineSpacing *oox_spacing, cpdoccore::odf_types::length_or_percent & length_or_percent);
//.diagram................................................................................................................................
void convert(OOX::Diagram::CShapeTree *oox_shape_tree);
void convert(OOX::Diagram::CShape *oox_shape);
//.diagram(pptx)................................................................................................................................
void convert(PPTX::Logic::SpTree *oox_shape_tree);
void convert(PPTX::Logic::Shape *oox_shape);
void convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle* oox_sp_style = NULL);
int convert(PPTX::Logic::PrstTxWarp *oox_text_preset);
//.chart............................................................................................................................
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title);
......@@ -445,7 +458,6 @@ public:
void convert(OOX::Spreadsheet::CT_NumData *num_data, bool categories, bool label);
void convert(OOX::Spreadsheet::CT_StrData *str_data, bool categories, bool label);
//.vml............................................................................................................................
void convert(OOX::Vml::CShapeType *vml_shape_type);
void convert(OOX::Vml::CShape *vml_shape);
......
......@@ -2864,10 +2864,8 @@ void DocxConverter::convert(OOX::Drawing::CDiagrammParts *oox_diagramm)
oox_current_child_document = diag_drawing;
for (unsigned int i=0; i < diag_drawing->m_arrShapeTree.size(); i++)
{
OoxConverter::convert(diag_drawing->m_arrShapeTree[i]);
}
OoxConverter::convert(diag_drawing->m_oShapeTree.GetPointer());
oox_current_child_document = NULL;
}
}
......
......@@ -297,42 +297,6 @@
RelativePath="..\Oox2OdfConverter\DocxConverter.cpp"
>
</File>
<File
RelativePath="..\..\..\Common\DocxFormat\Source\XML\libxml2\libxml2.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\Oox2OdfConverter\XlsxConverter.cpp"
>
......
......@@ -990,10 +990,6 @@
RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Interactive.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Layout.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Layout.h"
>
......
......@@ -54,13 +54,11 @@
#include "../Common/DocxFormat/Source/Common/SimpleTypes_Base.h"
#include "../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h"
#include "../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
#include "../Common/DocxFormat/Source/DocxFormat/Media/Image.h"
const double g_emu_koef = 25.4 * 36000 / 72.0;
//#define AVS_OFFICE_DRAWING_DUMP_XML_TEST
//#define AVS_OFFICE_DRAWING_DUMP_PPTX_TO_PPT_TEST
using namespace NSGuidesVML;
void DUMP_MESSAGE_TO_FILE(const char* strMessage)
......@@ -1080,93 +1078,7 @@ bool CDrawingConverter::ParceObject(const std::wstring& strXml, std::wstring** p
if (L"dgm:relIds" == oNodeContent.GetName() && m_pBinaryWriter->m_pCommonRels->is_init())
{
nullable<OOX::RId> id_data;
oNodeContent.ReadAttributeBase(L"r:dm", id_data);
nullable<std::wstring> id_drawing;
if (id_data.is_init())
{
smart_ptr<OOX::File> oFile = (*m_pBinaryWriter->m_pCommonRels)->Find(*id_data);
if (oFile.is_init())
{
OOX::CDiagramData* pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFile.operator->());
if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit()))
{
for (int i = 0; i < pDiagramData->m_oExtLst->m_arrExt.size(); i++)
{
if (pDiagramData->m_oExtLst->m_arrExt[i]->m_oDataModelExt.IsInit())
{
id_drawing = pDiagramData->m_oExtLst->m_arrExt[i]->m_oDataModelExt->m_oRelId;
break;
}
}
}
if (id_drawing.is_init())
{
smart_ptr<OOX::Image> pDiagDW = (*m_pBinaryWriter->m_pCommonRels)->GetImage(OOX::RId(*id_drawing));
if (pDiagDW.is_init())
{
std::wstring strPathDiagDW = pDiagDW->filename().m_strFilename;
XmlUtils::CXmlNode oNodeDW;
oNodeDW.FromXmlFile(strPathDiagDW);
XmlUtils::CXmlNode oNodeS = oNodeDW.ReadNodeNoNS(L"spTree");
oElem = oNodeS;
if (oElem.is<PPTX::Logic::SpTree>())
{
PPTX::Logic::SpTree& _pElem = oElem.as<PPTX::Logic::SpTree>();
if (!_pElem.grpSpPr.xfrm.is_init())
{
_pElem.grpSpPr.xfrm = new PPTX::Logic::Xfrm();
_pElem.grpSpPr.xfrm->offX = (int)0;
_pElem.grpSpPr.xfrm->offY = (int)0;
_pElem.grpSpPr.xfrm->extX = m_pBinaryWriter->m_lWidthCurShape;
_pElem.grpSpPr.xfrm->extY = m_pBinaryWriter->m_lHeightCurShape;
_pElem.grpSpPr.xfrm->chOffX = (int)0;
_pElem.grpSpPr.xfrm->chOffY = (int)0;
_pElem.grpSpPr.xfrm->chExtX = m_pBinaryWriter->m_lWidthCurShape;
_pElem.grpSpPr.xfrm->chExtY = m_pBinaryWriter->m_lHeightCurShape;
}
else
{
if (!_pElem.grpSpPr.xfrm->offX.is_init())
_pElem.grpSpPr.xfrm->offX = (int)0;
if (!_pElem.grpSpPr.xfrm->offY.is_init())
_pElem.grpSpPr.xfrm->offY = (int)0;
if (!_pElem.grpSpPr.xfrm->extX.is_init())
_pElem.grpSpPr.xfrm->extX = m_pBinaryWriter->m_lWidthCurShape;
if (!_pElem.grpSpPr.xfrm->extY.is_init())
_pElem.grpSpPr.xfrm->extY = m_pBinaryWriter->m_lHeightCurShape;
if (!_pElem.grpSpPr.xfrm->chOffX.is_init())
_pElem.grpSpPr.xfrm->chOffX = (int)0;
if (!_pElem.grpSpPr.xfrm->chOffY.is_init())
_pElem.grpSpPr.xfrm->chOffY = (int)0;
if (!_pElem.grpSpPr.xfrm->chExtX.is_init())
_pElem.grpSpPr.xfrm->chExtX = m_pBinaryWriter->m_lWidthCurShape;
if (!_pElem.grpSpPr.xfrm->chExtY.is_init())
_pElem.grpSpPr.xfrm->chExtY = m_pBinaryWriter->m_lHeightCurShape;
}
}
m_strCurrentRelsPath = strPathDiagDW;
SetCurrentRelsPath();
}
}
else
{//BG-FSC1.docx
if (pDiagramData->m_oDgmPtLst.IsInit())
{
}
}
}
}
doc_LoadDiagram(&oElem, oNodeContent, pMainProps, true);
}
else if (L"wpc:wpc" == oNodeContent.GetName())
{
......@@ -1224,7 +1136,8 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
}
else if (strName == L"background")
{
PPTX::Logic::SpTreeElem oElem = doc_LoadShape(oParseNode, pMainProps, false);
PPTX::Logic::SpTreeElem oElem;
doc_LoadShape(&oElem, oParseNode, pMainProps, false);
m_pBinaryWriter->WriteRecord1(1, oElem);
break;
}
......@@ -1254,7 +1167,7 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
if(NULL == pElem)
{
pElem = new PPTX::Logic::SpTreeElem;
*pElem = doc_LoadShape(oNodeP, pMainProps, true);
doc_LoadShape(pElem, oNodeP, pMainProps, true);
#ifdef AVS_OFFICE_DRAWING_DUMP_XML_TEST
NSBinPptxRW::CXmlWriter oXmlW;
......@@ -1274,7 +1187,7 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
if(NULL == pElem)
{
pElem = new PPTX::Logic::SpTreeElem;
*pElem = doc_LoadGroup(oNodeP, pMainProps, true);
doc_LoadGroup(pElem, oNodeP, pMainProps, true);
#ifdef AVS_OFFICE_DRAWING_DUMP_XML_TEST
NSBinPptxRW::CXmlWriter oXmlW;
......@@ -1429,9 +1342,113 @@ rIns=\"91440\" bIns=\"45720\" numCol=\"1\" spcCol=\"0\" rtlCol=\"0\" fromWordArt
return true;
}
PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNodeShape, std::wstring**& pMainProps,bool bIsTop)
void CDrawingConverter::doc_LoadDiagram(PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop)
{
PPTX::Logic::SpTreeElem elem;
if (!result) return;
nullable<OOX::RId> id_data;
nullable<std::wstring> id_drawing;
smart_ptr<OOX::File> oFileData;
smart_ptr<OOX::File> oFileDrawing;
OOX::CDiagramData* pDiagramData = NULL;
OOX::CDiagramDrawing* pDiagramDrawing = NULL;
oNode.ReadAttributeBase(L"r:dm", id_data);
if (id_data.IsInit())
{
oFileData = (*m_pBinaryWriter->m_pCommonRels)->Find(*id_data);
if (oFileData.is_init())
{
pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->());
if (pDiagramData)
{
m_strCurrentRelsPath = pDiagramData->m_strFilename;
SetCurrentRelsPath();
for (int i = 0; (pDiagramData->m_oExtLst.IsInit()) && i < pDiagramData->m_oExtLst->m_arrExt.size(); i++)
{
if (pDiagramData->m_oExtLst->m_arrExt[i]->m_oDataModelExt.IsInit())
{
id_drawing = pDiagramData->m_oExtLst->m_arrExt[i]->m_oDataModelExt->m_oRelId;
break;
}
}
}
}
if (id_drawing.is_init())
{
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
}
if (!pDiagramDrawing)
{
OOX::CPath pathDiagramData = pDiagramData->m_strFilename;
int a1 = pathDiagramData.GetFilename().find(L".");
std::wstring strId = pathDiagramData.GetFilename().substr(4, pathDiagramData.GetFilename().length() - 8);
OOX::CPath pathDiagramDrawing = pathDiagramData.GetDirectory() + FILE_SEPARATOR_STR + L"drawing" + strId + L".xml";
oFileDrawing = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(new OOX::CDiagramDrawing(pathDiagramDrawing)));
if (oFileDrawing.IsInit())
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
}
}
if (pDiagramDrawing)
{
result->InitElem(pDiagramDrawing->m_oShapeTree.operator->());
}
else
{//BG-FSC1.docx
//parse pDiagramData !!
}
if (result->is<PPTX::Logic::SpTree>())
{
PPTX::Logic::SpTree& _pElem = result->as<PPTX::Logic::SpTree>();
if (!_pElem.grpSpPr.xfrm.is_init())
{
_pElem.grpSpPr.xfrm = new PPTX::Logic::Xfrm();
_pElem.grpSpPr.xfrm->offX = (int)0;
_pElem.grpSpPr.xfrm->offY = (int)0;
_pElem.grpSpPr.xfrm->extX = m_pBinaryWriter->m_lWidthCurShape;
_pElem.grpSpPr.xfrm->extY = m_pBinaryWriter->m_lHeightCurShape;
_pElem.grpSpPr.xfrm->chOffX = (int)0;
_pElem.grpSpPr.xfrm->chOffY = (int)0;
_pElem.grpSpPr.xfrm->chExtX = m_pBinaryWriter->m_lWidthCurShape;
_pElem.grpSpPr.xfrm->chExtY = m_pBinaryWriter->m_lHeightCurShape;
}
else
{
if (!_pElem.grpSpPr.xfrm->offX.is_init())
_pElem.grpSpPr.xfrm->offX = (int)0;
if (!_pElem.grpSpPr.xfrm->offY.is_init())
_pElem.grpSpPr.xfrm->offY = (int)0;
if (!_pElem.grpSpPr.xfrm->extX.is_init())
_pElem.grpSpPr.xfrm->extX = m_pBinaryWriter->m_lWidthCurShape;
if (!_pElem.grpSpPr.xfrm->extY.is_init())
_pElem.grpSpPr.xfrm->extY = m_pBinaryWriter->m_lHeightCurShape;
if (!_pElem.grpSpPr.xfrm->chOffX.is_init())
_pElem.grpSpPr.xfrm->chOffX = (int)0;
if (!_pElem.grpSpPr.xfrm->chOffY.is_init())
_pElem.grpSpPr.xfrm->chOffY = (int)0;
if (!_pElem.grpSpPr.xfrm->chExtX.is_init())
_pElem.grpSpPr.xfrm->chExtX = m_pBinaryWriter->m_lWidthCurShape;
if (!_pElem.grpSpPr.xfrm->chExtY.is_init())
_pElem.grpSpPr.xfrm->chExtY = m_pBinaryWriter->m_lHeightCurShape;
}
}
}
void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::CXmlNode& oNodeShape, std::wstring**& pMainProps,bool bIsTop)
{
if (!elem) return;
std::wstring strNameNode = oNodeShape.GetName();
bool bIsNeedCoordSizes = true;
......@@ -2507,19 +2524,18 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo
pShape->nvSpPr.cNvPr.id = -1;
}
elem.InitElem(pShape);
elem->InitElem(pShape);
if (!pPPTShape->IsWordArt())
CheckPenShape(elem, oNodeShape, pPPTShape->m_eType, pPPTShape);
CheckBrushShape(elem, oNodeShape, pPPTShape->m_eType, pPPTShape);
}
return elem;
}
PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadGroup(XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop)
void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop)
{
PPTX::Logic::SpTreeElem elem;
if (!result) return;
PPTX::Logic::SpTree* pTree = new PPTX::Logic::SpTree();
......@@ -2569,14 +2585,16 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadGroup(XmlUtils::CXmlNode& oNo
L"background" == strNameP ||
L"roundrect" == strNameP)
{
PPTX::Logic::SpTreeElem _el = doc_LoadShape(oNodeT, pMainProps, false);
PPTX::Logic::SpTreeElem _el;
doc_LoadShape(&_el, oNodeT, pMainProps, false);
if (_el.is_init())
pTree->SpTreeElems.push_back(_el);
}
else if (L"group" == strNameP)
{
PPTX::Logic::SpTreeElem _el = doc_LoadGroup(oNodeT, pMainProps, false);
PPTX::Logic::SpTreeElem _el;
doc_LoadGroup(&_el, oNodeT, pMainProps, false);
if (_el.is_init())
pTree->SpTreeElems.push_back(_el);
......@@ -2725,8 +2743,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadGroup(XmlUtils::CXmlNode& oNo
pTree->nvGrpSpPr.cNvPr.id = -1;
}
elem.InitElem(pTree);
return elem;
result->InitElem(pTree);
}
void CDrawingConverter::LoadCoordSize(XmlUtils::CXmlNode& oNode, CShape* pShape)
......@@ -3424,9 +3441,11 @@ void CDrawingConverter::SendMainProps(const std::wstring& strMainProps, std::wst
**pMainProps = strMainProps;
}
void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem& oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape)
void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape)
{
PPTX::Logic::Shape* pShape = (PPTX::Logic::Shape*)dynamic_cast<PPTX::Logic::Shape*>(oElem.GetElem().operator ->());
if (!oElem)return;
PPTX::Logic::Shape* pShape = (PPTX::Logic::Shape*)dynamic_cast<PPTX::Logic::Shape*>(oElem->GetElem().operator ->());
int R = 255;
int G = 255;
......@@ -3758,9 +3777,11 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem& oElem, XmlUtils
}
}
}
void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem& oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape)
void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape)
{
PPTX::Logic::Shape* pShape = (PPTX::Logic::Shape*)dynamic_cast<PPTX::Logic::Shape*>(oElem.GetElem().operator ->());
if (!oElem)return;
PPTX::Logic::Shape* pShape = (PPTX::Logic::Shape*)dynamic_cast<PPTX::Logic::Shape*>(oElem->GetElem().operator ->());
// attributes
nullable_string sStrokeColor;
......
......@@ -261,16 +261,17 @@ namespace NSBinPptxRW
bool ParceObject (const std::wstring& strXml, std::wstring** pMainProps);
void SendMainProps (const std::wstring& strMainProps, std::wstring**& pMainProps);
PPTX::Logic::SpTreeElem doc_LoadShape(XmlUtils::CXmlNode& oNodeShape, std::wstring**& pMainProps, bool bIsTop = true);
PPTX::Logic::SpTreeElem doc_LoadGroup(XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
void doc_LoadDiagram(PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
void doc_LoadShape (PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
void doc_LoadGroup (PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
std::wstring GetVMLShapeXml (CPPTShape* pPPTShape);
std::wstring GetVMLShapeXml (PPTX::Logic::SpTreeElem& oElem);
void CheckBrushShape (PPTX::Logic::SpTreeElem& oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape);
void CheckPenShape (PPTX::Logic::SpTreeElem& oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape);
void CheckBrushShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape);
void CheckPenShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, PPTShapes::ShapeType eType, CPPTShape* pPPTShape);
void LoadCoordSize (XmlUtils::CXmlNode& oNode, ::CShape* pShape);
void LoadCoordSize (XmlUtils::CXmlNode& oNode, ::CShape* pShape);
std::wstring GetDrawingMainProps (XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
void ConvertMainPropsToVML (const std::wstring& bsMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
......
......@@ -288,10 +288,6 @@ namespace PPTX2EditorAdvanced
namespace NSPresentationEditor
{
/**************************************************************
здесь все типы элементов
**************************************************************/
class CImageElement : public IElement
{
public:
......@@ -1182,276 +1178,4 @@ namespace NSPresentationEditor
};
}
namespace NSStrings
{
class CTextItem
{
protected:
wchar_t* m_pData;
size_t m_lSize;
wchar_t* m_pDataCur;
size_t m_lSizeCur;
public:
CTextItem()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
}
CTextItem(const CTextItem& oSrc)
{
m_pData = NULL;
*this = oSrc;
}
CTextItem& operator=(const CTextItem& oSrc)
{
RELEASEMEM(m_pData);
m_lSize = oSrc.m_lSize;
m_lSizeCur = oSrc.m_lSizeCur;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(m_pData, oSrc.m_pData, m_lSizeCur * sizeof(wchar_t));
m_pDataCur = m_pData + m_lSizeCur;
return *this;
}
CTextItem(const size_t& nLen)
{
m_lSize = nLen;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
}
CTextItem(wchar_t* pData, const size_t& nLen)
{
m_lSize = nLen;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(m_pData, pData, m_lSize * sizeof(wchar_t));
m_lSizeCur = m_lSize;
m_pDataCur = m_pData + m_lSize;
}
CTextItem(wchar_t* pData, BYTE* pUnicodeChecker = NULL)
{
size_t nLen = GetStringLen(pData);
m_lSize = nLen;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(m_pData, pData, m_lSize * sizeof(wchar_t));
m_lSizeCur = m_lSize;
m_pDataCur = m_pData + m_lSize;
if (NULL != pUnicodeChecker)
{
wchar_t* pMemory = m_pData;
while (pMemory < m_pDataCur)
{
if (!pUnicodeChecker[*pMemory])
*pMemory = wchar_t(' ');
++pMemory;
}
}
}
virtual ~CTextItem()
{
RELEASEMEM(m_pData);
}
AVSINLINE void AddSize(const size_t& nSize)
{
if (NULL == m_pData)
{
m_lSize = (std::max)(nSize, (size_t) 1000);
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
if (NULL != pRealloc)
{
// реаллок сработал
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
public:
AVSINLINE void operator+=(const CTextItem& oTemp)
{
WriteString(oTemp.m_pData, oTemp.m_lSizeCur);
}
AVSINLINE void operator+=(std::wstring& oTemp)
{
size_t nLen = (size_t)oTemp.length();
WriteString(oTemp.c_str(), nLen);
}
AVSINLINE wchar_t operator[](const size_t& nIndex)
{
if (nIndex < m_lSizeCur)
return m_pData[nIndex];
return 0;
}
AVSINLINE void SetText(const std::wstring& sText)
{
ClearNoAttack();
size_t nLen = sText.length();
WriteString(sText.c_str(), nLen);
for (size_t i = 0; i < nLen; ++i)
{
if (WCHAR(8233) == m_pData[i])
m_pData[i] = WCHAR(' ');
}
}
AVSINLINE void AddSpace()
{
AddSize(1);
*m_pDataCur = wchar_t(' ');
++m_lSizeCur;
++m_pDataCur;
}
AVSINLINE void CorrectUnicode(const BYTE* pUnicodeChecker)
{
if (NULL != pUnicodeChecker)
{
wchar_t* pMemory = m_pData;
while (pMemory < m_pDataCur)
{
if (!pUnicodeChecker[*pMemory])
*pMemory = wchar_t(' ');
++pMemory;
}
}
}
AVSINLINE void RemoveLastSpaces()
{
wchar_t* pMemory = m_pDataCur - 1;
while ((pMemory > m_pData) && (wchar_t(' ') == *pMemory))
{
--pMemory;
--m_lSizeCur;
--m_pDataCur;
}
}
AVSINLINE bool IsSpace()
{
if (1 != m_lSizeCur)
return false;
return (wchar_t(' ') == *m_pData);
}
public:
AVSINLINE void WriteString(const wchar_t* pString, const size_t& nLen)
{
AddSize(nLen);
memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t));
//memcpy(m_pDataCur, pString, nLen << 1);
m_pDataCur += nLen;
m_lSizeCur += nLen;
}
AVSINLINE size_t GetCurSize()
{
return m_lSizeCur;
}
AVSINLINE size_t GetSize()
{
return m_lSize;
}
AVSINLINE void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE size_t GetStringLen(wchar_t* pData)
{
wchar_t* s = pData;
for (; *s != 0; ++s);
return (size_t)(s - pData);
}
AVSINLINE std::wstring GetCString()
{
std::wstring str(m_pData, (int)m_lSizeCur);
return str;
}
AVSINLINE wchar_t* GetBuffer()
{
return m_pData;
}
};
class CStringWriter : public CTextItem
{
public:
CStringWriter() : CTextItem()
{
}
virtual ~CStringWriter()
{
}
public:
AVSINLINE void WriteString(std::wstring& sString)
{
size_t nLen = (size_t)sString.length();
CTextItem::WriteString(sString.c_str(), nLen);
}
AVSINLINE void WriteString(wchar_t* pString, const size_t& nLen)
{
CTextItem::WriteString(pString, nLen);
}
AVSINLINE void Write(CStringWriter& oWriter)
{
CTextItem::WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
}
};
}
/*
* (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 "Elements.h"
......@@ -32,32 +32,7 @@
#include "BinWriters.h"
/*
HRESULT COfficeFontPicker::GetBinaryData(LONG lType, SAFEARRAY** ppBinaryArray)
{
if (NULL == ppBinaryArray)
return S_FALSE;
*ppBinaryArray = NULL;
if (FONT_PICKER_BINARYDATA_SAVEEMBEDDED == lType)
{
NSBinPptxRW::CBinaryFileWriter oWriter;
m_oPicker.m_oEmbeddedFonts.CheckString(_T(".)abcdefghijklmnopqrstuvwxyz"));
m_oPicker.m_oEmbeddedFonts.CheckFont(_T("Wingdings 3"), m_oPicker.m_pFontManager);
m_oPicker.m_oEmbeddedFonts.CheckFont(_T("Arial"), m_oPicker.m_pFontManager);
oWriter.StartRecord(NSBinPptxRW::NSMainTables::FontsEmbedded);
m_oPicker.m_oEmbeddedFonts.WriteEmbeddedFonts(&oWriter);
oWriter.EndRecord();
*ppBinaryArray = oWriter.GetSafearray();
}
else if (FONT_PICKER_BINARYDATA_SAVEMAP == lType)
{
}
return S_OK;
}
*/
HRESULT COfficeFontPicker::GetBinaryData(LONG lType, BYTE** ppyArray, size_t& szCount)
{
if (NULL == ppyArray)
......
......@@ -37,7 +37,6 @@
#include "FontCutter.h"
//#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace NSFontCutter
......@@ -207,7 +206,6 @@ public:
return S_OK;
}
//HRESULT GetBinaryData(LONG lType, SAFEARRAY** ppBinaryArray);
HRESULT GetBinaryData(LONG lType, BYTE** ppyArray, size_t& szCount);
NSFontCutter::CFontDstManager* GetNativePicker()
......
......@@ -56,6 +56,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/VmlDrawing.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Image.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
......@@ -129,8 +130,8 @@ namespace PPTX
return smart_ptr<OOX::File>(new OOX::Video(filename));
else if (relation.Type() == OOX::FileTypes::Data)
return smart_ptr<OOX::File>(new OOX::CDiagramData(filename));
else if (relation.Type() == OOX::FileTypes::DiagDrawing) // нужен только filepath
return smart_ptr<OOX::File>(new OOX::Image(filename)); // нужен только filepath
else if (relation.Type() == OOX::FileTypes::DiagDrawing)
return smart_ptr<OOX::File>(new OOX::CDiagramDrawing(filename));
else if (relation.Type() == OOX::FileTypes::OleObject)
return smart_ptr<OOX::File>(new OOX::OleObject(filename));
......@@ -159,7 +160,6 @@ namespace PPTX
std::wstring strT = relation.Type();
if (strT == OOX::FileTypes::Image ||
strT == OOX::FileTypes::DiagDrawing ||
strT == OOX::FileTypes::Chart)
{
return smart_ptr<OOX::File>(new OOX::Image(filename));
......@@ -167,6 +167,9 @@ namespace PPTX
else if(strT == OOX::FileTypes::Data)
return smart_ptr<OOX::File>(new OOX::CDiagramData(relation.Target()));
else if(strT == OOX::FileTypes::DiagDrawing)
return smart_ptr<OOX::File>(new OOX::CDiagramDrawing(relation.Target()));
else if(strT == OOX::FileTypes::HyperLink)
return smart_ptr<OOX::File>(new OOX::HyperLink(relation.Target()));
......
......@@ -38,6 +38,7 @@
#include "../../ASCOfficeDrawingConverter.h"
#include "../../../ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
namespace PPTX
{
......@@ -49,27 +50,25 @@ namespace PPTX
if (pWriter->m_pCommonRels->is_init())
pRels = pWriter->m_pCommonRels->operator ->();
smart_ptr<OOX::File> oFile;
smart_ptr<OOX::File> oFileData;
smart_ptr<OOX::File> oFileDrawing;
nullable<std::wstring> id_drawing;
OOX::CDiagramData* pDiagramData = NULL;
OOX::CDiagramDrawing* pDiagramDrawing = NULL;
if(id_data.IsInit())
{
if(parentFileIs<Slide>())
oFile = parentFileAs<Slide>().Find(*id_data);
else if(parentFileIs<SlideLayout>())
oFile = parentFileAs<SlideLayout>().Find(*id_data);
else if(parentFileIs<SlideMaster>())
oFile = parentFileAs<SlideMaster>().Find(*id_data);
else if(parentFileIs<Theme>())
oFile = parentFileAs<Theme>().Find(*id_data);
else if (pRels != NULL)
oFile = pRels->Find(*id_data);
if (parentFileIs<Slide>()) oFileData = parentFileAs<Slide>().Find(*id_data);
else if (parentFileIs<SlideLayout>()) oFileData = parentFileAs<SlideLayout>().Find(*id_data);
else if (parentFileIs<SlideMaster>()) oFileData = parentFileAs<SlideMaster>().Find(*id_data);
else if (parentFileIs<Theme>()) oFileData = parentFileAs<Theme>().Find(*id_data);
else if (pRels != NULL) oFileData = pRels->Find(*id_data);
}
nullable<std::wstring> id_drawing;
std::wstring strPathDiagramDrawing;
if (oFile.is_init())
if (oFileData.IsInit())
{
OOX::CDiagramData* pDiagramData = (OOX::CDiagramData*)oFile.operator->();
pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->());
if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit()))
{
......@@ -83,58 +82,48 @@ namespace PPTX
}
}
if (id_drawing.is_init())
if (id_drawing.IsInit())
{
if(parentFileIs<Slide>())
strPathDiagramDrawing = parentFileAs<Slide>().GetMediaFullPathNameFromRId(*id_drawing);
else if(parentFileIs<SlideLayout>())
strPathDiagramDrawing = parentFileAs<SlideLayout>().GetMediaFullPathNameFromRId(*id_drawing);
else if(parentFileIs<SlideMaster>())
strPathDiagramDrawing = parentFileAs<SlideMaster>().GetMediaFullPathNameFromRId(*id_drawing);
else if(parentFileIs<Theme>())
strPathDiagramDrawing = parentFileAs<Theme>().GetMediaFullPathNameFromRId(*id_drawing);
else if (pRels != NULL)
{
smart_ptr<OOX::Image> p = pRels->GetImage(*id_drawing);
if (p.is_init())
strPathDiagramDrawing = p->filename().m_strFilename;
}
if (parentFileIs<Slide>()) oFileDrawing = parentFileAs<Slide>().Find(*id_drawing);
else if (parentFileIs<SlideLayout>()) oFileDrawing = parentFileAs<SlideLayout>().Find(*id_drawing);
else if (parentFileIs<SlideMaster>()) oFileDrawing = parentFileAs<SlideMaster>().Find(*id_drawing);
else if (parentFileIs<Theme>()) oFileDrawing = parentFileAs<Theme>().Find(*id_drawing);
else if (pRels != NULL) oFileDrawing = pRels->Find(*id_data);
}
else
{
//Monetizing_Innovation.pptx (слайд 13) - diagrams/data1.xml не ссылается на diagrams/drawing1.xml
//пробуем по тому же пути с номером data.xml
// easy4cargo1.pptx - слайд 2 - в диаграмме Smart вместо ссылки на drawing.xml ссылка на стороннюю картинку
OOX::CPath pathDiagramData = pDiagramData->m_strFilename;
int a1 = pathDiagramData.GetFilename().find(L".");
std::wstring strId = pathDiagramData.GetFilename().substr(4, pathDiagramData.GetFilename().length() - 8);
OOX::CPath pathDiagramDrawing = pathDiagramData.GetDirectory() + FILE_SEPARATOR_STR + L"drawing" + strId + L".xml";
strPathDiagramDrawing = pathDiagramDrawing.GetPath();
}
//пробуем по тому же пути с номером data.xml - ниже
}
}
if (!strPathDiagramDrawing.empty())
if (oFileDrawing.IsInit())
{
XmlUtils::CXmlNode oNodeDW;
if (oNodeDW.FromXmlFile(strPathDiagramDrawing))
{
XmlUtils::CXmlNode oNodeS = oNodeDW.ReadNodeNoNS(L"spTree");
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
}
if (oNodeS.IsValid())
{
m_diag = oNodeS;
if (!pDiagramDrawing)
{
// easy4cargo1.pptx - слайд 2 - в диаграмме Smart вместо ссылки на drawing.xml ссылка на стороннюю картинку
OOX::CPath pathDiagramData = pDiagramData->m_strFilename;
CCommonRels* pRels = new CCommonRels();
OOX::CPath filename = strPathDiagramDrawing;
pRels->_read(filename);
int a1 = pathDiagramData.GetFilename().find(L".");
std::wstring strId = pathDiagramData.GetFilename().substr(4, pathDiagramData.GetFilename().length() - 8);
OOX::CPath pathDiagramDrawing = pathDiagramData.GetDirectory() + FILE_SEPARATOR_STR + L"drawing" + strId + L".xml";
m_oCommonRels = pRels;
oFileDrawing = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(new OOX::CDiagramDrawing(pathDiagramDrawing)));
if (oFileDrawing.IsInit())
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
}
return;
}
}
if (pDiagramDrawing)
{
m_diag = pDiagramDrawing->m_oShapeTree;
m_oCommonRels = smart_ptr<PPTX::CCommonRels>(dynamic_cast<PPTX::CCommonRels*>(pDiagramDrawing));
}
else
{
//parse pDiagramData !!
}
}
......
......@@ -46,7 +46,6 @@ namespace PPTX
{
namespace Logic
{
class SpTree : public WrapperWritingElement
{
public:
......
......@@ -312,11 +312,11 @@ namespace PPTX
int nFind1 = sFormatDataString.find(_T("base64"));
if (nFind1 >=0 ) bBase64 = true;
nFind1 = sFormatDataString.find(_T("image/"));
nFind1 = (int)sFormatDataString.find(_T("image/"));
if (nFind1>=0)
{
int nFind2 = sFormatDataString.find(_T(";"));
if (nFind2 < 0) nFind2 = sFormatDataString.length();
if (nFind2 < 0) nFind2 = (int)sFormatDataString.length();
sImageExtension = sFormatDataString.substr(nFind1 + 6, nFind2 - 6 - nFind1);
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2171,8 +2171,8 @@ namespace SimpleTypes
virtual double FromString(std::wstring &sValue)
{
int nPos = sValue.find( '%' );
int nLen = sValue.length();
int nPos = (int)sValue.find( '%' );
int nLen = (int)sValue.length();
if ( -1 == nPos || nPos != sValue.length() - 1 || nLen <= 0 )
{
if ( -1 == nPos && nLen > 0)
......
......@@ -171,7 +171,7 @@ namespace OOX
}
CDiagramData(const CPath& uri)
{
read(CPath(), uri);
read(uri.GetDirectory(), uri);
}
CDiagramData(const CPath& oRootPath, const CPath& oPath)
{
......
......@@ -38,170 +38,172 @@
#include "../WritingElement.h"
#include "../Drawing/DrawingCoreInfo.h"
#include "../Drawing/DrawingText.h"
#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.h"
//#include "../Drawing/DrawingCoreInfo.h"
//#include "../Drawing/DrawingText.h"
namespace OOX
{
namespace Diagram
{
//--------------------------------------------------------------------------------
// ?????? sp (Shape)
//--------------------------------------------------------------------------------
class CShape : public WritingElement
{
public:
CShape(XmlUtils::CXmlNode &oNode)
{
fromXML( oNode );
}
CShape(XmlUtils::CXmlLiteReader& oReader)
{
fromXML( oReader );
}
CShape()
{
}
virtual ~CShape()
{
}
//namespace Diagram
//{
// //--------------------------------------------------------------------------------
// // ?????? sp (Shape)
// //--------------------------------------------------------------------------------
// class CShape : public WritingElement
// {
// public:
// CShape(XmlUtils::CXmlNode &oNode)
// {
// fromXML( oNode );
// }
// CShape(XmlUtils::CXmlLiteReader& oReader)
// {
// fromXML( oReader );
// }
// CShape()
// {
// }
// virtual ~CShape()
// {
// }
public:
virtual std::wstring toXML() const
{
return _T("");
}
virtual void toXML(XmlUtils::CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
// public:
// virtual std::wstring toXML() const
// {
// return _T("");
// }
// virtual void toXML(XmlUtils::CStringWriter& writer) const
// {
// }
// virtual void fromXML(XmlUtils::CXmlNode& node)
// {
// }
// virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
// {
// ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
// if ( oReader.IsEmptyNode() )
// return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
// int nCurDepth = oReader.GetDepth();
// while( oReader.ReadNextSiblingNode( nCurDepth ) )
// {
// std::wstring sName = oReader.GetName();
if ( _T("dsp:spPr") == sName )
m_oSpPr = oReader;
//else if ( _T("dsp:nvSpPr") == sName )
// m_oNvSpPr = oReader;
else if ( _T("dsp:style") == sName )
m_oShapeStyle = oReader;
else if (_T("dsp:txBody") == sName)
m_oTxBody = oReader;
else if (_T("dsp:txXfrm") == sName)
m_oTxXfrm = oReader;
}
}
// if ( _T("dsp:spPr") == sName )
// m_oSpPr = oReader;
// //else if ( _T("dsp:nvSpPr") == sName )
// // m_oNvSpPr = oReader;
// else if ( _T("dsp:style") == sName )
// m_oShapeStyle = oReader;
// else if (_T("dsp:txBody") == sName)
// m_oTxBody = oReader;
// else if (_T("dsp:txXfrm") == sName)
// m_oTxXfrm = oReader;
// }
// }
virtual EElementType getType () const
{
return et_dsp_Shape;
}
// virtual EElementType getType () const
// {
// return et_dsp_Shape;
// }
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
//nullable<OOX::Drawing::CShapeNonVisual> m_oNvSpPr;
// private:
// void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
// {
// }
// public:
// //nullable<OOX::Drawing::CShapeNonVisual> m_oNvSpPr;
nullable<OOX::Drawing::CShapeProperties> m_oSpPr;
nullable<OOX::Drawing::CShapeStyle> m_oShapeStyle;
nullable<OOX::Drawing::CTxBody> m_oTxBody;
nullable<OOX::Drawing::CTransform2D> m_oTxXfrm;
// nullable<OOX::Drawing::CShapeProperties> m_oSpPr;
// nullable<OOX::Drawing::CShapeStyle> m_oShapeStyle;
// nullable<OOX::Drawing::CTxBody> m_oTxBody;
// nullable<OOX::Drawing::CTransform2D> m_oTxXfrm;
//extLst (Extension List) І20.1.2.2.15
// //extLst (Extension List) І20.1.2.2.15
};
// };
class CShapeTree : public WritingElementWithChilds<OOX::Diagram::CShape>
{
public:
WritingElement_AdditionConstructors(CShapeTree)
CShapeTree()
{
}
virtual ~CShapeTree()
{
}
// class CShapeTree : public WritingElementWithChilds<OOX::Diagram::CShape>
// {
// public:
// WritingElement_AdditionConstructors(CShapeTree)
// CShapeTree()
// {
// }
// virtual ~CShapeTree()
// {
// }
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
// public:
// virtual void fromXML(XmlUtils::CXmlNode& oNode)
// {
// }
// virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
// {
// ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
// if ( oReader.IsEmptyNode() )
// return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
WritingElement *pItem = NULL;
// int nParentDepth = oReader.GetDepth();
// while( oReader.ReadNextSiblingNode( nParentDepth ) )
// {
// std::wstring sName = oReader.GetName();
// WritingElement *pItem = NULL;
if ( _T("dsp:sp") == sName )
m_arrItems.push_back( new Diagram::CShape( oReader ));
//else if ( _T("dsp:nvGrpSpPr") == sName )
// m_oGroupShapeNonVisual = oReader;
else if ( _T("dsp:grpSpPr") == sName )
m_oGroupShapeProperties = oReader;
}
}
virtual std::wstring toXML() const
{
std::wstring sResult = _T("");
return sResult;
}
// if ( _T("dsp:sp") == sName )
// m_arrItems.push_back( new Diagram::CShape( oReader ));
// //else if ( _T("dsp:nvGrpSpPr") == sName )
// // m_oGroupShapeNonVisual = oReader;
// else if ( _T("dsp:grpSpPr") == sName )
// m_oGroupShapeProperties = oReader;
// }
// }
// virtual std::wstring toXML() const
// {
// std::wstring sResult = _T("");
// return sResult;
// }
virtual EElementType getType() const
{
return et_dsp_ShapeTree;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
WritingElement_ReadAttributes_Start ( oReader )
WritingElement_ReadAttributes_End ( oReader )
}
// virtual EElementType getType() const
// {
// return et_dsp_ShapeTree;
// }
// private:
// void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
// {
// // Читаем атрибуты
// WritingElement_ReadAttributes_Start ( oReader )
// WritingElement_ReadAttributes_End ( oReader )
// }
public:
// public:
// Attributes
// // Attributes
// Childs
//nullable<Diagram::CGroupShapeNonVisual> m_oGroupShapeNonVisual;
nullable<Drawing::CGroupShapeProperties> m_oGroupShapeProperties;
};
}
// // Childs
// //nullable<Diagram::CGroupShapeNonVisual> m_oGroupShapeNonVisual;
// nullable<Drawing::CGroupShapeProperties> m_oGroupShapeProperties;
// };
//}
class CDiagramDrawing : public OOX::File, public OOX::IFileContainer
{
public:
CDiagramDrawing()
{
}
CDiagramDrawing(const CPath& oRootPath, const CPath& oPath)
CDiagramDrawing(const CPath& uri)
{
read(uri.GetDirectory(), uri);
}
CDiagramDrawing(const CPath& oRootPath, const CPath& oPath)
{
read( oRootPath, oPath );
}
virtual ~CDiagramDrawing()
{
for(int i = 0, length = m_arrShapeTree.size(); i < length; ++i)
delete m_arrShapeTree[i];
m_arrShapeTree.clear();
}
virtual void read(const CPath& oFilePath)
{
......@@ -212,28 +214,33 @@ namespace OOX
virtual void read(const CPath& oRootPath, const CPath& oFilePath)
{
IFileContainer::Read( oRootPath, oFilePath );
#ifdef USE_LITE_READER
//#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
// XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
return;
// if ( !oReader.FromFile( oFilePath.GetPath() ) )
// return;
if ( !oReader.ReadNextNode() )
return;
// if ( !oReader.ReadNextNode() )
// return;
std::wstring sName = oReader.GetName();
if ( _T("dsp:drawing") == sName && !oReader.IsEmptyNode() )
{
int nNumberingDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nNumberingDepth ) )
{
sName = oReader.GetName();
if ( _T("dsp:spTree") == sName )
m_arrShapeTree.push_back( new Diagram::CShapeTree(oReader) );
}
}
#endif
// std::wstring sName = oReader.GetName();
// if ( _T("dsp:drawing") == sName && !oReader.IsEmptyNode() )
// {
// int nNumberingDepth = oReader.GetDepth();
// while ( oReader.ReadNextSiblingNode( nNumberingDepth ) )
// {
// sName = oReader.GetName();
// if ( _T("dsp:spTree") == sName )
// m_arrShapeTree.push_back( new PPTX::Logic::SpTree(oReader) );
// }
// }
//#endif
XmlUtils::CXmlNode oNodeDW;
if (oNodeDW.FromXmlFile(oFilePath.GetPath() ))
{
m_oShapeTree = oNodeDW.ReadNodeNoNS(L"spTree");
}
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
......@@ -253,7 +260,7 @@ namespace OOX
return type().DefaultFileName();
}
std::vector<Diagram::CShapeTree*> m_arrShapeTree;
NSCommon::nullable<PPTX::Logic::SpTree> m_oShapeTree;
};
} // namespace OOX
......@@ -62,7 +62,8 @@ namespace OOX
//Учитывает только rid начинающиеся с rId, остальные сохраняем так как есть
//Tогда не будет проблем с добавление новый id, мы всегда будем генерировать их с префиксом rId
std::wstring sFindString(_T("rId"));
int nFindStringLength = sFindString.length();
int nFindStringLength = (int)sFindString.length();
if(0 == rid.find(sFindString) && rid.length() > nFindStringLength && 0 != isdigit(rid[nFindStringLength]))
{
std::wstring strParam = rid.substr(nFindStringLength);
......
......@@ -309,7 +309,7 @@ namespace NSStringExt
}
else
{
unLen = wsUnicodeText.size();
unLen = (unsigned int)wsUnicodeText.size();
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{
pUnicodes[unIndex] = (unsigned int)wsUnicodeText.at(unIndex);
......
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