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());
}
PPTX::Logic::PrstGeom* prstGeom = &oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
if (type < 0 && oox_shape->m_oSpPr->m_oCustGeom.IsInit())
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
{
......@@ -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"
>
......
......@@ -261,14 +261,15 @@ 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);
std::wstring GetDrawingMainProps (XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
......
......@@ -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,27 +82,27 @@ namespace PPTX
}
}
if (id_drawing.is_init())
{
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)
if (id_drawing.IsInit())
{
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
//пробуем по тому же пути с номером data.xml - ниже
}
}
if (oFileDrawing.IsInit())
{
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
}
if (!pDiagramDrawing)
{
// easy4cargo1.pptx - слайд 2 - в диаграмме Smart вместо ссылки на drawing.xml ссылка на стороннюю картинку
OOX::CPath pathDiagramData = pDiagramData->m_strFilename;
......@@ -112,29 +111,19 @@ namespace PPTX
OOX::CPath pathDiagramDrawing = pathDiagramData.GetDirectory() + FILE_SEPARATOR_STR + L"drawing" + strId + L".xml";
strPathDiagramDrawing = pathDiagramDrawing.GetPath();
oFileDrawing = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(new OOX::CDiagramDrawing(pathDiagramDrawing)));
if (oFileDrawing.IsInit())
pDiagramDrawing = dynamic_cast<OOX::CDiagramDrawing*>(oFileDrawing.operator->());
}
}
if (!strPathDiagramDrawing.empty())
{
XmlUtils::CXmlNode oNodeDW;
if (oNodeDW.FromXmlFile(strPathDiagramDrawing))
{
XmlUtils::CXmlNode oNodeS = oNodeDW.ReadNodeNoNS(L"spTree");
if (oNodeS.IsValid())
if (pDiagramDrawing)
{
m_diag = oNodeS;
CCommonRels* pRels = new CCommonRels();
OOX::CPath filename = strPathDiagramDrawing;
pRels->_read(filename);
m_oCommonRels = pRels;
return;
}
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 diff is collapsed.
......@@ -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)
{
......
......@@ -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