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()
......
......@@ -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