Commit bd3ae6a7 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFormat - конвертация шейпов - linux build

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68271 954022d7-b5bf-4e40-9824-e11837661b57
parent e78482a1
#pragma once
#include "BaseShape.h"
#include PPTShape.h"
NSGuidesVML::CBaseShape* NSPresentationEditor::CBaseShape::CreateByType(NSPresentationEditor::NSBaseShape::ClassType ClassType, int ShapeType)
{
#if defined(PPTX_DEF)
if(ClassType == pptx)
{
return CPPTXShape::CreateByType((OOXMLShapes::ShapeType)ShapeType);
}
#endif
#if defined(PPT_DEF)
if (ClassType == ppt)
{
return CPPTShape::CreateByType((PPTShapes::ShapeType)ShapeType);
}
#endif
return NULL;
}
bool NSGuidesVML::CBaseShape::SetType(NSPresentationEditor::NSBaseShape::ClassType ClassType, int ShapeType)
{
if (ClassType != GetClassType())
return false;
#if defined(PPTX_DEF)
if(ClassType == pptx)
{
return ((CPPTXShape*)this)->SetShapeType((OOXMLShapes::ShapeType)ShapeType);
}
#endif
#if defined(PPT_DEF)
if(ClassType == ppt)
{
return ((CPPTShape*)this)->SetShapeType((PPTShapes::ShapeType)ShapeType);
}
#endif
return false;
}
\ No newline at end of file
#pragma once
#include "BaseShape.h"
#include "CustomShape.h"
NSGuidesVML::CBaseShape* NSGuidesVML::CBaseShape::CreateByType( int ShapeType)
{
return CCustomShape::CreateByType((oox::MSOSPT)ShapeType);
}
bool NSGuidesVML::CBaseShape::SetType( int ShapeType)
{
return ((CCustomShape*)this)->SetShapeType((oox::MSOSPT)ShapeType);
}
......@@ -297,26 +297,21 @@ namespace NSCustomVML
if (lMaxF > m_arVertices[nIndex].x ) nGuideIndex_x = (DWORD)m_arVertices[nIndex].x - (DWORD)lMinF;
if (lMaxF > m_arVertices[nIndex].y ) nGuideIndex_y = (DWORD)m_arVertices[nIndex].y - (DWORD)lMinF;
wchar_t buf[2]={};
if (nGuideIndex_x >= 0 )
{
_itow(m_arGuides[nGuideIndex_x].m_param_value1, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
}
else
{
_itow(m_arVertices[nIndex].x, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arVertices[nIndex].x) + L",";
}
if (nGuideIndex_y >= 0)
{
_itow(m_arGuides[nGuideIndex_y].m_param_value1, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
}
else
{
_itow(m_arVertices[nIndex].y, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arVertices[nIndex].y) + L",";
}
}
strPath.erase(strPath.length() - 1);
......@@ -378,26 +373,21 @@ namespace NSCustomVML
if (lMaxF > m_arVertices[nV].x ) nGuideIndex_x = (DWORD)m_arVertices[nV].x - (DWORD)lMinF;
if (lMaxF > m_arVertices[nV].y ) nGuideIndex_y = (DWORD)m_arVertices[nV].y - (DWORD)lMinF;
wchar_t buf[20]={};
if (nGuideIndex_x >= 0 )
{
_itow(m_arGuides[nGuideIndex_x].m_param_value1, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
}
else
{
_itow(m_arVertices[nV].x, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arVertices[nV].x) + L",";
}
if (nGuideIndex_y >= 0)
{
_itow(m_arGuides[nGuideIndex_y].m_param_value1, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
}
else
{
_itow(m_arVertices[nV].y, buf, 10);
strPath += std::wstring(buf) + L",";
strPath += NSStringUtils::ToString(m_arVertices[nV].y) + L",";
}
}
......
......@@ -21,7 +21,6 @@ public:
CCustomShape() : CBaseShape()
{
m_eType = oox::msosptNotPrimitive;
}
~CCustomShape()
......
#pragma once
#include "PPTShape.h"
#include "PresetShapesHeader.h"
const double EMU_MM = 36000;
//-------------------------------------------------------------------------------
#define CREATE_BY_SPT(SHAPE_TYPE, CLASS_SHAPE_NAME) \
case SHAPE_TYPE: { pShape = new CLASS_SHAPE_NAME(); break; } \
//-------------------------------------------------------------------------------
using namespace NSOfficeDrawing;
CPPTShape* CPPTShape::CreateByType(ShapeType type)
{
CPPTShape* pShape = NULL;
switch (type)
{
// msosptNotchedCircularArrow 0x00000064 A value that SHOULD NOT be used.
// msosptHostControl 0x000000C9 A value that SHOULD NOT be used.
case sptNotchedCircularArrow:
case sptHostControl:
case 0: { pShape = new CRectangleType(); break; }
//CREATE_BY_SPT(sptMin, CLineType)
CREATE_BY_SPT(sptAccentBorderCallout90, CAccentBorderCallout90Type)
CREATE_BY_SPT(sptAccentBorderCallout1, CAccentBorderCallout1Type)
CREATE_BY_SPT(sptAccentBorderCallout2, CAccentBorderCallout2Type)
CREATE_BY_SPT(sptAccentBorderCallout3, CAccentBorderCallout3Type)
CREATE_BY_SPT(sptAccentCallout90, CAccentCallout90Type)
CREATE_BY_SPT(sptAccentCallout1, CAccentCallout1Type)
CREATE_BY_SPT(sptAccentCallout2, CAccentCallout2Type)
CREATE_BY_SPT(sptAccentCallout3, CAccentCallout3Type)
CREATE_BY_SPT(sptBorderCallout90, CBorderCallout90Type)
CREATE_BY_SPT(sptBorderCallout1, CBorderCallout1Type)
CREATE_BY_SPT(sptBorderCallout2, CBorderCallout2Type)
CREATE_BY_SPT(sptBorderCallout3, CBorderCallout3Type)
CREATE_BY_SPT(sptCallout90, CCallout90Type)
CREATE_BY_SPT(sptCallout1, CCallout1Type)
CREATE_BY_SPT(sptCallout2, CCallout2Type)
CREATE_BY_SPT(sptCallout3, CCallout3Type)
CREATE_BY_SPT(sptActionButtonBlank, CActionButtonBlankType)
CREATE_BY_SPT(sptActionButtonHome, CActionButtonHomeType)
CREATE_BY_SPT(sptActionButtonHelp, CActionButtonHelpType)
CREATE_BY_SPT(sptActionButtonInformation, CActionButtonInfoType)
CREATE_BY_SPT(sptActionButtonBackPrevious, CActionButtonBackType)
CREATE_BY_SPT(sptActionButtonForwardNext, CActionButtonNextType)
CREATE_BY_SPT(sptActionButtonBeginning, CActionButtonBeginType)
CREATE_BY_SPT(sptActionButtonEnd, CActionButtonEndType)
CREATE_BY_SPT(sptActionButtonReturn, CActionButtonReturnType)
CREATE_BY_SPT(sptActionButtonDocument, CActionButtonDocType)
CREATE_BY_SPT(sptActionButtonSound, CActionButtonSoundType)
CREATE_BY_SPT(sptActionButtonMovie, CActionButtonMovieType)
CREATE_BY_SPT(sptArc, CArcType)
CREATE_BY_SPT(sptLine, CLineType)
CREATE_BY_SPT(sptBentArrow, CBentArrowType)
CREATE_BY_SPT(sptBentUpArrow, CBentUpArrowType)
CREATE_BY_SPT(sptBevel, CBevelType)
CREATE_BY_SPT(sptBlockArc, CBlockArcType)
CREATE_BY_SPT(sptBracePair, CBracePairType)
CREATE_BY_SPT(sptBracketPair, CBracketPairType)
CREATE_BY_SPT(sptCan, CCanType)
CREATE_BY_SPT(sptChevron, CChevronType)
CREATE_BY_SPT(sptCircularArrow, CCircularArrowType)
CREATE_BY_SPT(sptCloudCallout, CCloudCalloutType)
CREATE_BY_SPT(sptCube, CCubeType)
CREATE_BY_SPT(sptCurvedDownArrow, CCurvedDownArrowType)
CREATE_BY_SPT(sptCurvedLeftArrow, CCurvedLeftArrowType)
CREATE_BY_SPT(sptCurvedRightArrow, CCurvedRightArrowType)
CREATE_BY_SPT(sptCurvedUpArrow, CCurvedUpArrowType)
CREATE_BY_SPT(sptDiamond, CDiamondType)
CREATE_BY_SPT(sptDonut, CDonutType)
CREATE_BY_SPT(sptDownArrowCallout, CDownArrowCalloutType)
CREATE_BY_SPT(sptDownArrow, CDownArrowType)
CREATE_BY_SPT(sptEllipse, CEllipseType)
CREATE_BY_SPT(sptEllipseRibbon, CEllipceRibbonType)
CREATE_BY_SPT(sptEllipseRibbon2, CEllipceRibbon2Type)
CREATE_BY_SPT(sptFlowChartAlternateProcess, CFlowChartAlternateProcessType)
CREATE_BY_SPT(sptFlowChartCollate, CFlowChartCollateType)
CREATE_BY_SPT(sptFlowChartConnector, CFlowChartConnectorType)
CREATE_BY_SPT(sptFlowChartDecision, CFlowChartDecisionType)
CREATE_BY_SPT(sptFlowChartDisplay, CFlowChartDisplayType)
CREATE_BY_SPT(sptFlowChartDelay, CFlowChartDelayType)
CREATE_BY_SPT(sptFlowChartDocument, CFlowChartDocumentType)
CREATE_BY_SPT(sptFlowChartExtract, CFlowChartExtractType)
CREATE_BY_SPT(sptFlowChartInputOutput, CFlowChartInputOutputType)
CREATE_BY_SPT(sptFlowChartInternalStorage, CFlowChartInternalStorageType)
CREATE_BY_SPT(sptFlowChartMagneticDisk, CFlowChartMagneticDiskType)
CREATE_BY_SPT(sptFlowChartMagneticDrum, CFlowChartMagneticDrumType)
CREATE_BY_SPT(sptFlowChartMagneticTape, CFlowChartMagneticTapeType)
CREATE_BY_SPT(sptFlowChartManualInput, CFlowChartManualInputType)
CREATE_BY_SPT(sptFlowChartManualOperation, CFlowChartManualOperationType)
CREATE_BY_SPT(sptFlowChartMerge, CFlowChartMergeType)
CREATE_BY_SPT(sptFlowChartMultidocument, CFlowChartMultidocumentType)
CREATE_BY_SPT(sptFlowChartOffpageConnector, CFlowChartOffpageConnectorType)
CREATE_BY_SPT(sptFlowChartOnlineStorage, CFlowChartOnlineStorageType)
CREATE_BY_SPT(sptFlowChartOr, CFlowChartOrType)
CREATE_BY_SPT(sptFlowChartPredefinedProcess, CFlowChartPredefinedProcessType)
CREATE_BY_SPT(sptFlowChartPreparation, CFlowChartPreparationType)
CREATE_BY_SPT(sptFlowChartProcess, CFlowChartProcessType)
CREATE_BY_SPT(sptFlowChartPunchedCard, CFlowChartPunchedCardType)
CREATE_BY_SPT(sptFlowChartPunchedTape, CFlowChartPunchedTapeType)
CREATE_BY_SPT(sptFlowChartSort, CFlowChartSortType)
CREATE_BY_SPT(sptFlowChartSummingJunction, CFlowChartSummingJunctionType)
CREATE_BY_SPT(sptFlowChartTerminator, CFlowChartTerminatorType)
CREATE_BY_SPT(sptFoldedCorner, CFoldedCornerType)
CREATE_BY_SPT(sptHeart, CHeartType)
CREATE_BY_SPT(sptHexagon, CHexagonType)
CREATE_BY_SPT(sptHomePlate, CHomePlateType)
CREATE_BY_SPT(sptIrregularSeal1, CIrregularSealOneType)
CREATE_BY_SPT(sptIrregularSeal2, CIrregularSealTwo)
CREATE_BY_SPT(sptIsocelesTriangle, CIsoscelesTriangleType)
CREATE_BY_SPT(sptLeftArrowCallout, CLeftArrowCalloutType)
CREATE_BY_SPT(sptLeftArrow, CLeftArrowType)
CREATE_BY_SPT(sptLeftBrace, CLeftBraceType)
CREATE_BY_SPT(sptLeftBracket, CLeftBracketType)
CREATE_BY_SPT(sptLeftRightArrowCallout, CLeftRightArrowCalloutType)
CREATE_BY_SPT(sptLeftRightArrow, CLeftRightArrowType)
CREATE_BY_SPT(sptLeftRightUpArrow, CLeftRightUpArrow)
CREATE_BY_SPT(sptLeftUpArrow, CLeftUpArrowType)
CREATE_BY_SPT(sptLightningBolt, CLightningBoltType)
CREATE_BY_SPT(sptMoon, CMoonType)
CREATE_BY_SPT(sptNoSmoking, CNoSmokingType)
CREATE_BY_SPT(sptNotchedRightArrow, CNotchedRightArrowType)
CREATE_BY_SPT(sptOctagon, COctagonType)
CREATE_BY_SPT(sptParallelogram, CParallelogramType)
CREATE_BY_SPT(sptPentagon, CPentagonType)
CREATE_BY_SPT(sptPlaque, CPlaqueType)
CREATE_BY_SPT(sptPlus, CPlusType)
CREATE_BY_SPT(sptQuadArrowCallout, CQuadArrowCalloutType)
CREATE_BY_SPT(sptQuadArrow, CQuadArrowType)
CREATE_BY_SPT(sptRectangle, CRectangleType)
CREATE_BY_SPT(sptRibbon, CRibbonDownType)
CREATE_BY_SPT(sptRibbon2, CRibbonUpType)
CREATE_BY_SPT(sptRightArrowCallout, CRightArrowCalloutType)
CREATE_BY_SPT(sptArrow, CRightArrowType)
CREATE_BY_SPT(sptRightBrace, CRightBracetype)
CREATE_BY_SPT(sptRightBracket, CRightBracketType)
CREATE_BY_SPT(sptRightTriangle, CRightTriangleType)
CREATE_BY_SPT(sptRoundRectangle, CRoundedRectangleType)
CREATE_BY_SPT(sptSeal16, CSeal16Type)
CREATE_BY_SPT(sptSeal24, CSeal24Type)
CREATE_BY_SPT(sptSeal32, CSeal32Type)
CREATE_BY_SPT(sptSeal4, CSeal4Type)
CREATE_BY_SPT(sptSeal8, CSeal8Type)
CREATE_BY_SPT(sptSmileyFace, CSmileyFaceType)
CREATE_BY_SPT(sptStar, CStarType)
CREATE_BY_SPT(sptStraightConnector1, CStraightConnectorType)
CREATE_BY_SPT(sptStripedRightArrow, CStripedRightArrowType)
CREATE_BY_SPT(sptSun, CSunType)
CREATE_BY_SPT(sptTextBox, CTextboxType)
CREATE_BY_SPT(sptTrapezoid, CTrapezoidType)
CREATE_BY_SPT(sptUpArrowCallout, CUpArrowCalloutType)
CREATE_BY_SPT(sptUpArrow, CUpArrowType)
CREATE_BY_SPT(sptUpDownArrowCallout, CUpDownArrowCalloutType)
CREATE_BY_SPT(sptUpDownArrow, CUpDownArrowType)
CREATE_BY_SPT(sptUturnArrow, CUturnArrowType)
CREATE_BY_SPT(sptVerticalScroll, CVerticalScrollType)
CREATE_BY_SPT(sptHorizontalScroll, CHorizontalScrollType)
CREATE_BY_SPT(sptWedgeEllipseCallout, CWedgeEllipseCalloutType)
CREATE_BY_SPT(sptWedgeRectCallout, CWedgeRectCalloutType)
CREATE_BY_SPT(sptWedgeRRectCallout, CWedgeRoundedRectCalloutType)
CREATE_BY_SPT(sptWave, CWaveType)
CREATE_BY_SPT(sptDoubleWave, CWaveDoubleType)
case sptBentConnector2:
case sptBentConnector3:
case sptBentConnector4:
case sptBentConnector5:
{
pShape = new CBentConnectorType();
break;
}
case sptCurvedConnector2:
case sptCurvedConnector3:
case sptCurvedConnector4:
case sptCurvedConnector5:
{
pShape = new CCurvedConnectorType();
break;
}
case sptTextPlainText:
case sptTextStop:
case sptTextTriangle:
case sptTextTriangleInverted:
case sptTextChevron:
case sptTextChevronInverted:
case sptTextRingInside:
case sptTextRingOutside:
case sptTextArchUpCurve:
case sptTextArchDownCurve:
case sptTextCircleCurve:
case sptTextButtonCurve:
case sptTextArchUpPour:
case sptTextArchDownPour:
case sptTextCirclePour:
case sptTextButtonPour:
case sptTextCurveUp:
case sptTextCurveDown:
case sptTextCascadeUp:
case sptTextCascadeDown:
case sptTextWave1:
case sptTextWave2:
case sptTextWave3:
case sptTextWave4:
case sptTextInflate:
case sptTextDeflate:
case sptTextInflateBottom:
case sptTextDeflateBottom:
case sptTextInflateTop:
case sptTextDeflateTop:
case sptTextDeflateInflate:
case sptTextDeflateInflateDeflate:
case sptTextFadeRight:
case sptTextFadeLeft:
case sptTextFadeUp:
case sptTextFadeDown:
case sptTextSlantUp:
case sptTextSlantDown:
case sptTextCanUp:
case sptTextCanDown:
{
pShape = new CTextboxType();
}
default: break;
};
if (NULL != pShape)
pShape->m_eType = type;
return pShape;
}
#pragma once
#include "BaseShape.h"
#include "CustomGeomShape.h"
#include "PPTShapeEnum.h"
#include "../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/Enums.h"
class CPPTShape : public NSGuidesVML::CBaseShape
{
public:
ShapeType m_eType;
NSGuidesVML::CFormulasManager m_oManager;
NSCustomVML::CCustomVML m_oCustomVML;
std::wstring m_strPathLimoX;
std::wstring m_strPathLimoY;
std::vector<std::wstring> m_arStringTextRects;
public:
CPPTShape() : CBaseShape()
{
m_eType = sptMin;
}
~CPPTShape()
{
}
//virtual bool LoadFromXML(const std::wstring& xml)
//{
// XmlUtils::CXmlNode oNodePict;
// if (oNodePict.FromXmlString(xml))
// {
// if (_T("shape") == oNodePict.GetName())
// {
// std::wstring id = oNodePict.GetAttributeOrValue(_T("type"));
// if (id != _T(""))
// {
// SetShapeType((PPTShapes::ShapeType)Strings::ToInteger(id));
// }
// else
// {
// XmlUtils::CXmlNode oNodeTemplate;
// if (oNodePict.GetNode(_T("template"), oNodeTemplate))
// {
// std::wstring strAdj = oNodeTemplate.GetAttributeOrValue(_T("adj"));
// LoadAdjustValuesList(strAdj);
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodeTemplate.GetNode(_T("v:formulas"), oNodeGuides))
// {
// LoadGuidesList(oNodeGuides.GetXml());
// }
// std::wstring strPath = oNodeTemplate.GetAttributeOrValue(_T("path"));
// LoadPathList(strPath);
// }
// }
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodePict.GetNode(_T("path"), oNodeGuides))
// {
// std::wstring strPath = oNodeGuides.GetAttributeOrValue(_T("val"));
// LoadPathList(strPath);
// }
// /*XmlUtils::CXmlNode oNodeShapeType;
// if (oNodePict.GetNode(_T("v:shapetype"), oNodeShapeType))
// {
// std::wstring strAdj = oNodeShapeType.GetAttributeOrValue(_T("adj"));
// LoadAdjustValuesList(strAdj);
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodeShapeType.GetNode(_T("v:formulas"), oNodeGuides))
// {
// LoadGuidesList(oNodeGuides.GetXml());
// }
// std::wstring strPath = oNodeShapeType.GetAttributeOrValue(_T("path"));
// LoadAdjustValuesList(strPath);
// }
// else
// {
// XmlUtils::CXmlNode oNodeShape;
// if (oNodePict.GetNode(_T("v:shape"), oNodeShape))
// {
// std::wstring strAdj = oNodeShape.GetAttributeOrValue(_T("adj"));
// LoadAdjustValuesList(strAdj);
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodeShape.GetNode(_T("v:formulas"), oNodeGuides))
// {
// LoadGuidesList(oNodeGuides.GetXml());
// }
// std::wstring strPath = oNodeShape.GetAttributeOrValue(_T("path"));
// LoadPathList(strPath);
// }
// }*/
// return true;
// }
// }
// return false;
//}
//virtual bool LoadFromXML(XmlUtils::CXmlNode& oNodePict)
//{
// std::wstring id = oNodePict.GetAttributeOrValue(_T("type"));
// bool isPathList = false;
// if (id != _T(""))
// {
// SetShapeType((PPTShapes::ShapeType)XmlUtils::GetInteger(id));
// }
// else
// {
// XmlUtils::CXmlNode oNodeTemplate;
// if (oNodePict.GetNode(_T("template"), oNodeTemplate))
// {
// std::wstring strAdj = oNodeTemplate.GetAttributeOrValue(_T("adj"));
// LoadAdjustValuesList(strAdj);
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodeTemplate.GetNode(_T("v:formulas"), oNodeGuides))
// {
// LoadGuidesList(oNodeGuides.GetXml());
// }
// std::wstring strPath = oNodeTemplate.GetAttributeOrValue(_T("path"));
// if (strPath != _T(""))
// {
// LoadPathList(strPath);
// isPathList = true;
// }
// }
// }
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodePict.GetNode(_T("path"), oNodeGuides))
// {
// std::wstring strPath = oNodeGuides.GetAttributeOrValue(_T("val"));
// if (strPath != _T(""))
// {
// LoadPathList(strPath);
// isPathList = true;
// }
// }
// if (!isPathList)
// ReCalculate();
// return true;
//}
//virtual bool LoadFromXMLShapeType(XmlUtils::CXmlNode& oNodeShapeType) // vml object
//{ // vmlDrawing - value ..
// std::wstring sId = oNodeShapeType.GetAttribute(_T("o:spt"));
// bool bIsNeedRecalc = true;
// if (sId != _T(""))
// {
// int id = XmlUtils::GetInteger(sId);
// if (id > 0)
// {
// SetShapeType((PPTShapes::ShapeType)id);
// //ReCalculate();
// m_eType = (PPTShapes::ShapeType)id;
// }
// }
// //else
// {
// std::wstring strAdj = oNodeShapeType.GetAttribute(_T("adj"));
// if (strAdj != _T(""))
// LoadAdjustValuesList(strAdj);
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodeShapeType.GetNode(_T("v:formulas"), oNodeGuides))
// {
// LoadGuidesList(oNodeGuides.GetXml());
// }
// XmlUtils::CXmlNode oNodePath;
// if (oNodeShapeType.GetNode(_T("v:path"), oNodePath))
// {
// std::wstring strTextR = oNodePath.GetAttribute(_T("textboxrect"));
// if (strTextR != _T(""))
// LoadTextRect(strTextR);
// }
// XmlUtils::CXmlNode oNodeAHs;
// if (oNodeShapeType.GetNode(_T("v:handles"), oNodeAHs))
// {
// LoadAHList(oNodeAHs);
// }
// std::wstring strPath = oNodeShapeType.GetAttribute(_T("path"));
// if (strPath != _T(""))
// {
// LoadPathList(strPath);
// }
// }
// std::wstring strFilled = oNodeShapeType.GetAttribute(_T("filled"));
// std::wstring strStroked = oNodeShapeType.GetAttribute(_T("stroked"));
// if (strFilled != _T(""))
// {
// if (strFilled == _T("false") || strFilled == _T("f"))
// m_bIsFilled = false;
// else
// m_bIsFilled = true;
// }
//
// if (strStroked != _T(""))
// {
// if (strStroked == _T("false") || strStroked == _T("f"))
// m_bIsStroked = false;
// else
// m_bIsStroked = true;
// }
// ReCalculate();
// return true;
//}
//virtual bool LoadAdjustValuesList(const std::wstring& xml)
//{
// std::wstring strXml = xml;
// if (0 == strXml.Find((TCHAR)','))
// strXml = (_T("defaultAdj") + strXml);
// LONG lLastIndex = strXml.GetLength() - 1;
// if (lLastIndex >= 0 && lLastIndex == strXml.ReverseFind((TCHAR)','))
// {
// strXml = strXml + _T("defaultAdj");
// }
// strXml.Replace(_T(",,"), _T(",defaultAdj,"));
// std::vector<std::wstring> arAdj;
// NSStringUtils::ParseString(_T(","), strXml, &arAdj);
//
// std::vector<long> oOldAdj;
// int nOldLen = m_arAdjustments.size();
// for (int ii = 0; ii < nOldLen; ++ii)
// oOldAdj.push_back(m_arAdjustments[ii]);
// m_arAdjustments.clear();
// for (int nIndex = 0; nIndex < arAdj.size(); ++nIndex)
// {
// if (_T("defaultAdj") == arAdj[nIndex])
// {
// if (nIndex >= nOldLen)
// m_arAdjustments.push_back(0);
// else
// m_arAdjustments.push_back(oOldAdj[nIndex]);
// }
// else
// {
// m_arAdjustments.push_back((LONG)XmlUtils::GetInteger(arAdj[nIndex]));
// }
// }
// int newLen = m_arAdjustments.size();
// for (int i = newLen; i < nOldLen; ++i)
// m_arAdjustments.push_back(oOldAdj[i]);
// return true;
//}
//virtual bool LoadGuidesList(const std::wstring& xml)
//{
// // std::wstring sFormulasTemp;
// // sFormulasTemp.Format(_T("<root xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">%ls</root>"),xml);
//
//
// std::wstring sBegin(_T("<root xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">"));
//
// std::wstring sEnd(_T("</root>"));
// std::wstring sFormulasTemp = sBegin + xml+ sEnd;
//
// XmlUtils::CXmlNode oNodeRoot;
// if (oNodeRoot.FromXmlString(sFormulasTemp) == false) return false;
// XmlUtils::CXmlNode oNodeGuides;
// if (oNodeRoot.GetNode(_T("v:formulas"),oNodeGuides) == false) return false;
// if ((_T("v:formulas") == oNodeGuides.GetName()))
// {
// m_oManager.Clear();
// XmlUtils::CXmlNodes oList;
// if (oNodeGuides.GetNodes(_T("v:f"), oList))
// {
// int lCount = oList.GetCount();
// for (int nIndex = 0; nIndex < lCount; ++nIndex)
// {
// XmlUtils::CXmlNode oNodeFormula;
// oList.GetAt(nIndex, oNodeFormula);
// m_oManager.AddFormula(oNodeFormula.GetAttributeOrValue(_T("eqn")));
// }
// }
// m_oManager.Clear(&m_arAdjustments);
// m_oManager.CalculateResults();
// return true;
// }
// return false;
//}
virtual void AddGuide(const std::wstring& strGuide)
{
m_oManager.AddFormula(strGuide);
}
virtual bool LoadAdjustHandlesList(const std::wstring& xml)
{
return true;
}
//void LoadAHList(XmlUtils::CXmlNode& oNode)
//{
// m_arHandles.clear();
// XmlUtils::CXmlNodes oNodes;
// if (oNode.GetNodes(_T("v:h"), oNodes))
// {
// int nCount = oNodes.GetCount();
// for (int i = 0; i < nCount; ++i)
// {
// XmlUtils::CXmlNode oNodeH;
// oNodes.GetAt(i, oNodeH);
// CHandle_ oH;
// oH.polar = oNodeH.GetAttribute(_T("polar"));
// oH.position = oNodeH.GetAttribute(_T("position"));
// oH.radiusrange = oNodeH.GetAttribute(_T("radiusrange"));
// oH.switchHandle = oNodeH.GetAttribute(_T("switch"));
// oH.xrange = oNodeH.GetAttribute(_T("xrange"));
// oH.yrange = oNodeH.GetAttribute(_T("yrange"));
// m_arHandles.push_back(oH);
// }
// }
//}
virtual bool LoadConnectorsList(const std::wstring& xml)
{
return true;
}
virtual bool LoadTextRect(const std::wstring& xml)
{
std::vector<std::wstring> oArray;
NSStringUtils::ParseString(_T(";"), xml, &oArray);
LONG lCount = (LONG)oArray.size();
if (lCount <= 0)
return true;
m_arStringTextRects.clear();
for (LONG i = 0; i < lCount; ++i)
{
m_arStringTextRects.push_back(oArray[i]);
}
return true;
}
virtual bool LoadPathList(const std::wstring& xml)
{
m_strPath = xml;
//if (!m_bIsShapeType)
// m_oPath.FromXML(xml, m_oManager);
return true;
}
virtual bool SetAdjustment(long index, long value)
{
if (index < m_arAdjustments.size() && index >= 0)
{
m_arAdjustments[index] = value;
return TRUE;
}
return FALSE;
}
//virtual std::wstring ToXML(CGeomShapeInfo& GeomInfo, CMetricInfo& MetricInfo, double StartTime, double EndTime, CBrush& Brush, CPen& Pen)
//{
// if ((_T("") != m_strPathLimoX) || _T("") != m_strPathLimoY)
// {
// m_strPath = (GeomInfo.m_dWidth >= GeomInfo.m_dHeight) ? m_strPathLimoX : m_strPathLimoY;
// ReCalculate();
// m_oPath.SetCoordsize(21600, 21600);
// }
//
// return m_oPath.ToXml(GeomInfo, StartTime, EndTime, Pen, Brush, MetricInfo, NSBaseShape::ppt);
//}
virtual void ReCalculate()
{
m_oManager.Clear(&m_arAdjustments);
m_oManager.CalculateResults();
if (_T("") == m_strPath)
return;
LoadPathList(m_strPath);
}
static CPPTShape* CreateByType(ShapeType type);
virtual bool SetProperties(CBaseShape* Shape)
{
if(Shape == NULL)
return false;
m_oManager = ((CPPTShape*)Shape)->m_oManager;
//m_strPathLimoX = ((CPPTShape*)Shape)->m_strPathLimoX;
//m_strPathLimoY = ((CPPTShape*)Shape)->m_strPathLimoY;
//m_arStringTextRects.clear();
//m_arStringTextRects.insert(m_arStringTextRects.end(), ((CPPTShape*)Shape)->m_arStringTextRects.begin(), ((CPPTShape*)Shape)->m_arStringTextRects.end());
return true;// CBaseShape::SetProperties(Shape);
}
bool SetShapeType(ShapeType type)
{
CPPTShape* l_pShape = CreateByType(type);
if(l_pShape != NULL)
{
m_eType = type;
SetProperties(l_pShape);
delete l_pShape;
return true;
}
m_eType = sptCustom;
return false;
}
//protected:
//
// bool GetPos(std::wstring str, LONG& lValue)
// {
// if (str.GetLength() == 0)
// return false;
//
// TCHAR mem = str.GetAt(0);
//
// bool bFormula = false;
// if ('@' == mem)
// {
// bFormula = true;
// str.Delete(0);
// }
//
// if (!NSStringUtils::IsNumber(str))
// return false;
//
// lValue = 0;
// lValue = _ttoi(str);
//
// if (bFormula)
// {
// if (lValue >= 0 || lValue < m_oManager.m_arResults.size())
// {
// lValue = m_oManager.m_arResults[lValue];
// return true;
// }
// return false;
// }
//
// return true;
// }
};
......@@ -5,9 +5,10 @@
#include <vector>
#include <boost/algorithm/string.hpp>
#include <stdlib.h>
#include "../../../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../../../DesktopEditor/graphics/GraphicsPath.h"
#include "../../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../../DesktopEditor/graphics/GraphicsPath.h"
const double ShapeSize = 43200.0;
const int ShapeSizeVML = 21600;
......@@ -21,13 +22,6 @@ const double RadKoef = M_PI/10800000.0;
#define pow3_16 60000
#endif
inline LONG round(double dVal)
{
return (LONG)(2 * dVal) - (LONG)(dVal);
}
namespace NSStringUtils
{
#define IS_ALPHA(c) (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))
......@@ -55,9 +49,13 @@ namespace NSStringUtils
static std::wstring ToString(LONG val)
{
wchar_t buf[20]={};
_itow(val, buf, 10);
return std::wstring(buf);
#if defined(_WIN32) || defined (_WIN64)
wchar_t buff[32] ={};
_itow(val, buff, 10);
return std::wstring(buff);
#else
return (std::to_wstring(val));
#endif
}
static void ParseString(std::wstring strDelimeters, std::wstring strSource,
......
#pragma once
//#include "./BinReaderWriterDefines.h"
//#include "./Drawing/Shapes/BaseShape/Common.h"
//
//#include "../../../DesktopEditor/graphics/IRenderer.h"
#include "../../../Common/DocxFormat/Source/Base/Nullable.h"
#include "../../../DesktopEditor/Common/File.h"
//#include "../../../Common/DocxFormat/Source/Base/Nullable.h"
#include "../../../DesktopEditor/common/File.h"
namespace NSGuidesVML
{
......@@ -47,10 +42,6 @@ namespace NSGuidesVML
{
return (dVal >= 0) ? dVal : -dVal;
}
static int round(double dVal)
{
return (int)(dVal + 0.5);
}
class CStringWriter
{
......@@ -304,59 +295,8 @@ namespace NSGuidesVML
}
void WriteBool(const bool& val)
{
m_oWriter.WriteString(boost::lexical_cast<std::wstring>(val));
;
m_oWriter.WriteString(boost::lexical_cast<std::wstring>(val));
}
// write attribute
//void WriteAttributeCSS(const std::wstring& strAttributeName, const std::wstring& val)
//{
// m_oWriter.WriteString(strAttributeName);
// m_oWriter.AddSize(15);
// m_oWriter.AddCharNoCheck(WCHAR(':'));
// m_oWriter.WriteString(val);
// m_oWriter.AddCharNoCheck(WCHAR(';'));
//}
//void WriteAttributeCSS_int(const std::wstring& strAttributeName, const int& val)
//{
// m_oWriter.WriteString(strAttributeName);
// m_oWriter.AddSize(15);
// m_oWriter.AddCharNoCheck(WCHAR(':'));
// m_oWriter.AddIntNoCheck(val);
// m_oWriter.AddCharNoCheck(WCHAR(';'));
//}
//void WriteAttributeCSS_double1(const std::wstring& strAttributeName, const double& val)
//{
// m_oWriter.WriteString(strAttributeName);
// m_oWriter.AddSize(15);
// std::wstring s = _T("");
// s.Format(_T("%.1lf"), val);
// m_oWriter.AddCharNoCheck(WCHAR(':'));
// m_oWriter.WriteString(s);
// m_oWriter.AddCharNoCheck(WCHAR(';'));
//}
//void WriteAttributeCSS_int_pt(const std::wstring& strAttributeName, const int& val)
//{
// m_oWriter.WriteString(strAttributeName);
// m_oWriter.AddSize(15);
// m_oWriter.AddCharNoCheck(WCHAR(':'));
// m_oWriter.AddIntNoCheck(val);
// m_oWriter.AddCharNoCheck(WCHAR('p'));
// m_oWriter.AddCharNoCheck(WCHAR('t'));
// m_oWriter.AddCharNoCheck(WCHAR(';'));
//}
//void WriteAttributeCSS_double1_pt(const std::wstring& strAttributeName, const double& val)
//{
// m_oWriter.WriteString(strAttributeName);
// m_oWriter.AddSize(20);
// std::wstring s = _T("");
// s.Format(_T("%.1lf"), val);
// m_oWriter.AddCharNoCheck(WCHAR(':'));
// m_oWriter.WriteString(s);
// m_oWriter.AddCharNoCheck(WCHAR('p'));
// m_oWriter.AddCharNoCheck(WCHAR('t'));
// m_oWriter.AddCharNoCheck(WCHAR(';'));
//}
//
void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& val)
{
m_oWriter.WriteString(g_bstr_node_space);
......@@ -503,99 +443,8 @@ namespace NSGuidesVML
WriteNodeEnd(strNodeName);
}
/* bool SaveToFile(std::wstring strFilePath, bool bEncodingToUTF8 = true, bool bIsClearNoAttack = true)
{
std::wstring strData = m_oWriter.GetData();
if (!bEncodingToUTF8)
{
NSFile::CFileBinary oFile;
oFile.CreateFile(strFilePath);
oFile.WriteFile((BYTE*)strData.c_str(), strData.length());
oFile.CloseFile();
}
else
{
CDirectory::SaveToFile(strFilePath, strData);
NSFile::CFileBinary oFile;
oFile.CreateFile(strFilePath.c_str());
std::wstring strHead = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
oFile.WriteStringUTF8(strHead);
oFile.WriteStringUTF8(strData);
oFile.CloseFile();
}
if (bIsClearNoAttack)
{
m_oWriter.ClearNoAttack();
}
return true;
}*/
public:
// ATTRIBUTES --------------------------------------------------------------------------
void WriteAttribute(const std::wstring& strName, const nullable_int& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
void WriteAttribute(const std::wstring& strName, const nullable_double& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
void WriteAttribute(const std::wstring& strName, const nullable_string& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
void WriteAttribute2(const std::wstring& strName, const nullable_string& value)
{
if (value.IsInit())
WriteAttribute2(strName, value->GetBuffer());
}
void WriteAttribute(const std::wstring& strName, const nullable_bool& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
}
template <typename T>
void WriteAttribute(const std::wstring& strName, const nullable_limit<T>& value)
{
if (value.IsInit())
WriteAttribute(strName, (*value).get());
}
// -------------------------------------------------------------------------------------
// NODES -------------------------------------------------------------------------------
void WriteNodeValue(const std::wstring& strName, const nullable_int& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
void WriteNodeValue(const std::wstring& strName, const nullable_double& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
void WriteNodeValue(const std::wstring& strName, const nullable_string& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
void WriteNodeValue(const std::wstring& strName, const nullable_bool& value)
{
if (value.IsInit())
WriteNodeValue(strName, *value);
}
template <typename T>
void WriteNodeValue(const std::wstring& strName, const nullable_limit<T>& value)
{
if (value.IsInit())
WriteNodeValue(strName, (*value).get);
}
// -------------------------------------------------------------------------------------
// DOCUMENT ----------------------------------------------------------------------------
void StartNode(const std::wstring& name)
{
m_oWriter.WriteString(g_bstr_nodeopen);
......@@ -641,12 +490,7 @@ namespace NSGuidesVML
}
}
template<typename T>
void Write(const nullable<T>& val)
{
if (val.is_init())
val->toXmlWriter(this);
}
// -------------------------------------------------------------------------------------
void ReplaceString(std::wstring from, std::wstring to)
......
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