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 @@ ...@@ -33,16 +33,23 @@
#include "../utils.h" #include "../utils.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.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_conversion_context.h"
#include "../OdfFormat/odf_text_context.h" #include "../OdfFormat/odf_text_context.h"
#include "../OdfFormat/odf_drawing_context.h" #include "../OdfFormat/odf_drawing_context.h"
using namespace cpdoccore;
namespace Oox2Odf namespace Oox2Odf
{ {
double Emu2Pt(int emu)
void OoxConverter::convert(OOX::Diagram::CShapeTree *oox_shape_tree) {
return (1.0 * emu / (635 * 20.0));
}
void OoxConverter::convert(PPTX::Logic::SpTree *oox_shape_tree)
{ {
if (oox_shape_tree == NULL) return; if (oox_shape_tree == NULL) return;
...@@ -51,70 +58,63 @@ void OoxConverter::convert(OOX::Diagram::CShapeTree *oox_shape_tree) ...@@ -51,70 +58,63 @@ void OoxConverter::convert(OOX::Diagram::CShapeTree *oox_shape_tree)
cpdoccore::_CP_OPT(double) x, y , ch_x , ch_y ; cpdoccore::_CP_OPT(double) x, y , ch_x , ch_y ;
odf_context()->drawing_context()->set_group_position(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(); 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 == NULL) return;
if (!oox_shape->m_oSpPr.IsInit()) return;
odf_context()->drawing_context()->start_drawing(); odf_context()->drawing_context()->start_drawing();
int type = -1; int type = 1000;
if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit()) PPTX::Logic::PrstGeom* prstGeom = &oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
{
OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer(); if ( prstGeom )
type =(geometry->m_oPrst.GetValue());
}
if (type < 0 && oox_shape->m_oSpPr->m_oCustGeom.IsInit())
{ {
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; if (type < 0)return;
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
odf_context()->drawing_context()->start_shape(type); 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->nvSpPr.cNvSpPr);
// convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer());
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(); 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()); 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) ...@@ -125,4 +125,93 @@ void OoxConverter::convert(OOX::Diagram::CShape *oox_shape)
odf_context()->drawing_context()->end_drawing(); 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 ...@@ -271,11 +271,11 @@ namespace OOX
class CRichText; class CRichText;
class CTextProperties; class CTextProperties;
} }
namespace Diagram //namespace Diagram
{ //{
class CShape; // class CShape;
class CShapeTree; // class CShapeTree;
} //}
namespace Vml namespace Vml
{ {
class CShapeType; class CShapeType;
...@@ -311,6 +311,17 @@ namespace SimpleTypes ...@@ -311,6 +311,17 @@ namespace SimpleTypes
class CCssStyle; class CCssStyle;
} }
} }
namespace PPTX
{
namespace Logic
{
class SpTree;
class Shape;
class SpPr;
class ShapeStyle;
class PrstTxWarp;
}
}
namespace Oox2Odf namespace Oox2Odf
{ {
...@@ -346,7 +357,7 @@ public: ...@@ -346,7 +357,7 @@ public:
OOX::IFileContainer *oox_current_child_document; OOX::IFileContainer *oox_current_child_document;
//....................................................................................................................... //.......................................................................................................................
void convert(OOX::WritingElement *oox_unknown); 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...................................................................................................................... //.drawing......................................................................................................................
void convert(OOX::Drawing::CLockedCanvas *oox_canvas); void convert(OOX::Drawing::CLockedCanvas *oox_canvas);
...@@ -391,9 +402,11 @@ public: ...@@ -391,9 +402,11 @@ public:
void convert(OOX::Drawing::CRun *oox_run); 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::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); void convert(OOX::Drawing::CLineSpacing *oox_spacing, cpdoccore::odf_types::length_or_percent & length_or_percent);
//.diagram................................................................................................................................ //.diagram(pptx)................................................................................................................................
void convert(OOX::Diagram::CShapeTree *oox_shape_tree); void convert(PPTX::Logic::SpTree *oox_shape_tree);
void convert(OOX::Diagram::CShape *oox_shape); 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............................................................................................................................ //.chart............................................................................................................................
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart); void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title); void convert(OOX::Spreadsheet::CT_Title *ct_title);
...@@ -445,7 +458,6 @@ public: ...@@ -445,7 +458,6 @@ public:
void convert(OOX::Spreadsheet::CT_NumData *num_data, bool categories, bool label); void convert(OOX::Spreadsheet::CT_NumData *num_data, bool categories, bool label);
void convert(OOX::Spreadsheet::CT_StrData *str_data, bool categories, bool label); void convert(OOX::Spreadsheet::CT_StrData *str_data, bool categories, bool label);
//.vml............................................................................................................................ //.vml............................................................................................................................
void convert(OOX::Vml::CShapeType *vml_shape_type); void convert(OOX::Vml::CShapeType *vml_shape_type);
void convert(OOX::Vml::CShape *vml_shape); void convert(OOX::Vml::CShape *vml_shape);
......
...@@ -2864,10 +2864,8 @@ void DocxConverter::convert(OOX::Drawing::CDiagrammParts *oox_diagramm) ...@@ -2864,10 +2864,8 @@ void DocxConverter::convert(OOX::Drawing::CDiagrammParts *oox_diagramm)
oox_current_child_document = diag_drawing; oox_current_child_document = diag_drawing;
for (unsigned int i=0; i < diag_drawing->m_arrShapeTree.size(); i++) OoxConverter::convert(diag_drawing->m_oShapeTree.GetPointer());
{
OoxConverter::convert(diag_drawing->m_arrShapeTree[i]);
}
oox_current_child_document = NULL; oox_current_child_document = NULL;
} }
} }
......
...@@ -297,42 +297,6 @@ ...@@ -297,42 +297,6 @@
RelativePath="..\Oox2OdfConverter\DocxConverter.cpp" RelativePath="..\Oox2OdfConverter\DocxConverter.cpp"
> >
</File> </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 <File
RelativePath="..\Oox2OdfConverter\XlsxConverter.cpp" RelativePath="..\Oox2OdfConverter\XlsxConverter.cpp"
> >
......
...@@ -990,10 +990,6 @@ ...@@ -990,10 +990,6 @@
RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Interactive.h" RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Interactive.h"
> >
</File> </File>
<File
RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Layout.cpp"
>
</File>
<File <File
RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Layout.h" RelativePath="..\..\..\ASCOfficePPTXFile\Editor\Drawing\Layout.h"
> >
......
...@@ -261,16 +261,17 @@ namespace NSBinPptxRW ...@@ -261,16 +261,17 @@ namespace NSBinPptxRW
bool ParceObject (const std::wstring& strXml, std::wstring** pMainProps); bool ParceObject (const std::wstring& strXml, std::wstring** pMainProps);
void SendMainProps (const std::wstring& strMainProps, 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); void doc_LoadDiagram(PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
PPTX::Logic::SpTreeElem doc_LoadGroup(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 (CPPTShape* pPPTShape);
std::wstring GetVMLShapeXml (PPTX::Logic::SpTreeElem& oElem); std::wstring GetVMLShapeXml (PPTX::Logic::SpTreeElem& oElem);
void CheckBrushShape (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 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); std::wstring GetDrawingMainProps (XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
void ConvertMainPropsToVML (const std::wstring& bsMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem); void ConvertMainPropsToVML (const std::wstring& bsMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
......
...@@ -288,10 +288,6 @@ namespace PPTX2EditorAdvanced ...@@ -288,10 +288,6 @@ namespace PPTX2EditorAdvanced
namespace NSPresentationEditor namespace NSPresentationEditor
{ {
/**************************************************************
здесь все типы элементов
**************************************************************/
class CImageElement : public IElement class CImageElement : public IElement
{ {
public: public:
...@@ -1182,276 +1178,4 @@ namespace NSPresentationEditor ...@@ -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 @@ ...@@ -32,32 +32,7 @@
#include "BinWriters.h" #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) HRESULT COfficeFontPicker::GetBinaryData(LONG lType, BYTE** ppyArray, size_t& szCount)
{ {
if (NULL == ppyArray) if (NULL == ppyArray)
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "FontCutter.h" #include "FontCutter.h"
//#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h" #include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace NSFontCutter namespace NSFontCutter
...@@ -207,7 +206,6 @@ public: ...@@ -207,7 +206,6 @@ public:
return S_OK; return S_OK;
} }
//HRESULT GetBinaryData(LONG lType, SAFEARRAY** ppBinaryArray);
HRESULT GetBinaryData(LONG lType, BYTE** ppyArray, size_t& szCount); HRESULT GetBinaryData(LONG lType, BYTE** ppyArray, size_t& szCount);
NSFontCutter::CFontDstManager* GetNativePicker() NSFontCutter::CFontDstManager* GetNativePicker()
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/VmlDrawing.h" #include "../../Common/DocxFormat/Source/DocxFormat/VmlDrawing.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.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/Image.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
...@@ -129,8 +130,8 @@ namespace PPTX ...@@ -129,8 +130,8 @@ namespace PPTX
return smart_ptr<OOX::File>(new OOX::Video(filename)); return smart_ptr<OOX::File>(new OOX::Video(filename));
else if (relation.Type() == OOX::FileTypes::Data) else if (relation.Type() == OOX::FileTypes::Data)
return smart_ptr<OOX::File>(new OOX::CDiagramData(filename)); return smart_ptr<OOX::File>(new OOX::CDiagramData(filename));
else if (relation.Type() == OOX::FileTypes::DiagDrawing) // нужен только filepath else if (relation.Type() == OOX::FileTypes::DiagDrawing)
return smart_ptr<OOX::File>(new OOX::Image(filename)); // нужен только filepath return smart_ptr<OOX::File>(new OOX::CDiagramDrawing(filename));
else if (relation.Type() == OOX::FileTypes::OleObject) else if (relation.Type() == OOX::FileTypes::OleObject)
return smart_ptr<OOX::File>(new OOX::OleObject(filename)); return smart_ptr<OOX::File>(new OOX::OleObject(filename));
...@@ -159,7 +160,6 @@ namespace PPTX ...@@ -159,7 +160,6 @@ namespace PPTX
std::wstring strT = relation.Type(); std::wstring strT = relation.Type();
if (strT == OOX::FileTypes::Image || if (strT == OOX::FileTypes::Image ||
strT == OOX::FileTypes::DiagDrawing ||
strT == OOX::FileTypes::Chart) strT == OOX::FileTypes::Chart)
{ {
return smart_ptr<OOX::File>(new OOX::Image(filename)); return smart_ptr<OOX::File>(new OOX::Image(filename));
...@@ -167,6 +167,9 @@ namespace PPTX ...@@ -167,6 +167,9 @@ namespace PPTX
else if(strT == OOX::FileTypes::Data) else if(strT == OOX::FileTypes::Data)
return smart_ptr<OOX::File>(new OOX::CDiagramData(relation.Target())); 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) else if(strT == OOX::FileTypes::HyperLink)
return smart_ptr<OOX::File>(new OOX::HyperLink(relation.Target())); return smart_ptr<OOX::File>(new OOX::HyperLink(relation.Target()));
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "../../ASCOfficeDrawingConverter.h" #include "../../ASCOfficeDrawingConverter.h"
#include "../../../ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h" #include "../../../ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h" #include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
namespace PPTX namespace PPTX
{ {
...@@ -49,27 +50,25 @@ namespace PPTX ...@@ -49,27 +50,25 @@ namespace PPTX
if (pWriter->m_pCommonRels->is_init()) if (pWriter->m_pCommonRels->is_init())
pRels = pWriter->m_pCommonRels->operator ->(); 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(id_data.IsInit())
{ {
if(parentFileIs<Slide>()) if (parentFileIs<Slide>()) oFileData = parentFileAs<Slide>().Find(*id_data);
oFile = parentFileAs<Slide>().Find(*id_data); else if (parentFileIs<SlideLayout>()) oFileData = parentFileAs<SlideLayout>().Find(*id_data);
else if(parentFileIs<SlideLayout>()) else if (parentFileIs<SlideMaster>()) oFileData = parentFileAs<SlideMaster>().Find(*id_data);
oFile = parentFileAs<SlideLayout>().Find(*id_data); else if (parentFileIs<Theme>()) oFileData = parentFileAs<Theme>().Find(*id_data);
else if(parentFileIs<SlideMaster>()) else if (pRels != NULL) oFileData = pRels->Find(*id_data);
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);
} }
nullable<std::wstring> id_drawing;
std::wstring strPathDiagramDrawing; if (oFileData.IsInit())
if (oFile.is_init())
{ {
OOX::CDiagramData* pDiagramData = (OOX::CDiagramData*)oFile.operator->(); pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->());
if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit())) if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit()))
{ {
...@@ -83,58 +82,48 @@ namespace PPTX ...@@ -83,58 +82,48 @@ namespace PPTX
} }
} }
if (id_drawing.is_init()) if (id_drawing.IsInit())
{ {
if(parentFileIs<Slide>()) if (parentFileIs<Slide>()) oFileDrawing = parentFileAs<Slide>().Find(*id_drawing);
strPathDiagramDrawing = parentFileAs<Slide>().GetMediaFullPathNameFromRId(*id_drawing); else if (parentFileIs<SlideLayout>()) oFileDrawing = parentFileAs<SlideLayout>().Find(*id_drawing);
else if(parentFileIs<SlideLayout>()) else if (parentFileIs<SlideMaster>()) oFileDrawing = parentFileAs<SlideMaster>().Find(*id_drawing);
strPathDiagramDrawing = parentFileAs<SlideLayout>().GetMediaFullPathNameFromRId(*id_drawing); else if (parentFileIs<Theme>()) oFileDrawing = parentFileAs<Theme>().Find(*id_drawing);
else if(parentFileIs<SlideMaster>()) else if (pRels != NULL) oFileDrawing = pRels->Find(*id_data);
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;
}
} }
else else
{ {
//Monetizing_Innovation.pptx (слайд 13) - diagrams/data1.xml не ссылается на diagrams/drawing1.xml //Monetizing_Innovation.pptx (слайд 13) - diagrams/data1.xml не ссылается на diagrams/drawing1.xml
//пробуем по тому же пути с номером data.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();
}
} }
if (!strPathDiagramDrawing.empty()) if (oFileDrawing.IsInit())
{ {
XmlUtils::CXmlNode oNodeDW; pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
if (oNodeDW.FromXmlFile(strPathDiagramDrawing)) }
{
XmlUtils::CXmlNode oNodeS = oNodeDW.ReadNodeNoNS(L"spTree");
if (oNodeS.IsValid()) if (!pDiagramDrawing)
{ {
m_diag = oNodeS; // easy4cargo1.pptx - слайд 2 - в диаграмме Smart вместо ссылки на drawing.xml ссылка на стороннюю картинку
OOX::CPath pathDiagramData = pDiagramData->m_strFilename;
CCommonRels* pRels = new CCommonRels(); int a1 = pathDiagramData.GetFilename().find(L".");
OOX::CPath filename = strPathDiagramDrawing; std::wstring strId = pathDiagramData.GetFilename().substr(4, pathDiagramData.GetFilename().length() - 8);
pRels->_read(filename);
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 ...@@ -46,7 +46,6 @@ namespace PPTX
{ {
namespace Logic namespace Logic
{ {
class SpTree : public WrapperWritingElement class SpTree : public WrapperWritingElement
{ {
public: public:
......
...@@ -312,11 +312,11 @@ namespace PPTX ...@@ -312,11 +312,11 @@ namespace PPTX
int nFind1 = sFormatDataString.find(_T("base64")); int nFind1 = sFormatDataString.find(_T("base64"));
if (nFind1 >=0 ) bBase64 = true; if (nFind1 >=0 ) bBase64 = true;
nFind1 = sFormatDataString.find(_T("image/")); nFind1 = (int)sFormatDataString.find(_T("image/"));
if (nFind1>=0) if (nFind1>=0)
{ {
int nFind2 = sFormatDataString.find(_T(";")); 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); sImageExtension = sFormatDataString.substr(nFind1 + 6, nFind2 - 6 - nFind1);
} }
......
This diff is collapsed.
...@@ -2171,8 +2171,8 @@ namespace SimpleTypes ...@@ -2171,8 +2171,8 @@ namespace SimpleTypes
virtual double FromString(std::wstring &sValue) virtual double FromString(std::wstring &sValue)
{ {
int nPos = sValue.find( '%' ); int nPos = (int)sValue.find( '%' );
int nLen = sValue.length(); int nLen = (int)sValue.length();
if ( -1 == nPos || nPos != sValue.length() - 1 || nLen <= 0 ) if ( -1 == nPos || nPos != sValue.length() - 1 || nLen <= 0 )
{ {
if ( -1 == nPos && nLen > 0) if ( -1 == nPos && nLen > 0)
......
...@@ -171,7 +171,7 @@ namespace OOX ...@@ -171,7 +171,7 @@ namespace OOX
} }
CDiagramData(const CPath& uri) CDiagramData(const CPath& uri)
{ {
read(CPath(), uri); read(uri.GetDirectory(), uri);
} }
CDiagramData(const CPath& oRootPath, const CPath& oPath) CDiagramData(const CPath& oRootPath, const CPath& oPath)
{ {
......
...@@ -62,7 +62,8 @@ namespace OOX ...@@ -62,7 +62,8 @@ namespace OOX
//Учитывает только rid начинающиеся с rId, остальные сохраняем так как есть //Учитывает только rid начинающиеся с rId, остальные сохраняем так как есть
//Tогда не будет проблем с добавление новый id, мы всегда будем генерировать их с префиксом rId //Tогда не будет проблем с добавление новый id, мы всегда будем генерировать их с префиксом rId
std::wstring sFindString(_T("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])) if(0 == rid.find(sFindString) && rid.length() > nFindStringLength && 0 != isdigit(rid[nFindStringLength]))
{ {
std::wstring strParam = rid.substr(nFindStringLength); std::wstring strParam = rid.substr(nFindStringLength);
......
...@@ -309,7 +309,7 @@ namespace NSStringExt ...@@ -309,7 +309,7 @@ namespace NSStringExt
} }
else else
{ {
unLen = wsUnicodeText.size(); unLen = (unsigned int)wsUnicodeText.size();
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++) for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{ {
pUnicodes[unIndex] = (unsigned int)wsUnicodeText.at(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