Files
core/MsBinaryFile/Common/ODraw/CustomShapeConvert.h
Vikulov Dmitry 6a966c9cb9 xls, ppt, pptx changes
- implicit includes have been resolved
- preparation before common shapes(pri)
- x2t compiled
2022-12-17 14:19:53 +03:00

288 lines
12 KiB
C++

/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* 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 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* 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
*
*/
#pragma once
#include "FormulaShape.h"
#include "PathShape.h"
#include "BaseShape.h"
#include "../../XlsFile/Converter/ShapeType.h"
#include "XmlWriter.h"
namespace NSCustomShapesConvert
{
static int __wstrlen(const wchar_t* str)
{
const wchar_t* s = str;
for (; *s != 0; ++s);
return (LONG)(s - str);
}
static int g_guide_max_len = 80;
static wchar_t* g_guide_string1 = L"<a:gd name=\"gd";
static int g_guide_string1_len = __wstrlen(g_guide_string1);
static wchar_t* g_guide_string2 = L"\"/>";
static int g_guide_string2_len = __wstrlen(g_guide_string2);
static wchar_t* g_guide_string_val = L"\" fmla=\"val ";
static int g_guide_string_val_len = __wstrlen(g_guide_string_val);
static wchar_t* g_guide_string_sum = L"\" fmla=\"+- ";
static int g_guide_string_sum_len = __wstrlen(g_guide_string_sum);
static wchar_t* g_guide_string_prod = L"\" fmla=\"*/ ";
static int g_guide_string_prod_len = __wstrlen(g_guide_string_prod);
static wchar_t* g_guide_string_abs = L"\" fmla=\"abs ";
static int g_guide_string_abs_len = __wstrlen(g_guide_string_abs);
static wchar_t* g_guide_string_min = L"\" fmla=\"min ";
static int g_guide_string_min_len = __wstrlen(g_guide_string_min);
static wchar_t* g_guide_string_max = L"\" fmla=\"max ";
static int g_guide_string_max_len = __wstrlen(g_guide_string_max);
static wchar_t* g_guide_string__if = L"\" fmla=\"?: ";
static int g_guide_string__if_len = __wstrlen(g_guide_string__if);
static wchar_t* g_guide_string_sqrt = L"\" fmla=\"sqrt ";
static int g_guide_string_sqrt_len = __wstrlen(g_guide_string_sqrt);
static wchar_t* g_guide_string_at2 = L"\" fmla=\"at2 ";
static int g_guide_string_at2_len = __wstrlen(g_guide_string_at2);
static wchar_t* g_guide_string_sin = L"\" fmla=\"sin ";
static int g_guide_string_sin_len = __wstrlen(g_guide_string_sin);
static wchar_t* g_guide_string_cos = L"\" fmla=\"cos ";
static int g_guide_string_cos_len = __wstrlen(g_guide_string_cos);
static wchar_t* g_guide_string_cat2 = L"\" fmla=\"cat2 ";
static int g_guide_string_cat2_len = __wstrlen(g_guide_string_cat2);
static wchar_t* g_guide_string_sat2 = L"\" fmla=\"sat2 ";
static int g_guide_string_sat2_len = __wstrlen(g_guide_string_sat2);
static wchar_t* g_guide_string_mod = L"\" fmla=\"mod ";
static int g_guide_string_mod_len = __wstrlen(g_guide_string_mod);
static wchar_t* g_guide_string_tag = L"\" fmla=\"tag ";
static int g_guide_string_tag_len = __wstrlen(g_guide_string_tag);
#define GUIDE_PARAM_1(name) \
{ \
oWriter.m_oWriter.AddSize(g_guide_max_len); \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string1, g_guide_string1_len); \
oWriter.m_oWriter.AddIntNoCheck(m_lIndexDst); \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string_##name, g_guide_string_##name##_len); \
GetValue(lParam1, eType1, bExtShape1, oWriter); \
++m_lIndexDst; \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string2, g_guide_string2_len); \
}
#define GUIDE_PARAM_2(name) \
{ \
oWriter.m_oWriter.AddSize(g_guide_max_len); \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string1, g_guide_string1_len); \
oWriter.m_oWriter.AddIntNoCheck(m_lIndexDst); \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string_##name, g_guide_string_##name##_len); \
GetValue(lParam1, eType1, bExtShape1, oWriter); \
oWriter.m_oWriter.AddSpaceNoCheck(); \
GetValue(lParam2, eType2, bExtShape2, oWriter); \
++m_lIndexDst; \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string2, g_guide_string2_len); \
}
#define GUIDE_PARAM_3(name) \
{ \
oWriter.m_oWriter.AddSize(g_guide_max_len); \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string1, g_guide_string1_len); \
oWriter.m_oWriter.AddIntNoCheck(m_lIndexDst); \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string_##name, g_guide_string_##name##_len); \
GetValue(lParam1, eType1, bExtShape1, oWriter); \
oWriter.m_oWriter.AddSpaceNoCheck(); \
GetValue(lParam2, eType2, bExtShape2, oWriter); \
oWriter.m_oWriter.AddSpaceNoCheck(); \
GetValue(lParam3, eType3, bExtShape3, oWriter); \
++m_lIndexDst; \
oWriter.m_oWriter.WriteStringNoSafe(g_guide_string2, g_guide_string2_len); \
}
struct CFormParam
{
LONG m_lParam;
ParamType m_eType;
LONG m_lCoef;
};
class CSlicePath
{
public:
RulesType m_eRuler;
std::vector<Aggplus::POINT> m_arPoints;
std::vector<SPointType> m_arPointsType;
private:
int m_nCountElementsPoint;
public:
CSlicePath(RulesType eType = rtMoveTo);
void AddParam(LONG lParam, ParamType eParType);
};
class CFormulaConverter
{
private:
int m_lIndexSrc;
int m_lIndexDst;
std::vector<LONG> m_arIndexDst;
std::vector<CSlicePath> m_arSlicesPath;
std::vector<CPartPath> m_arParts;
std::wstring strFmlaNum;
std::wstring strSign;
std::wstring strFrmla;
std::wstring strResult;
Aggplus::POINT pCurPoint;
SPointType pCurPointType;
Aggplus::POINT pCurPoint1;
SPointType pCurPointType1;
Aggplus::POINT pTmpPoint;
CFormParam m_oParam;
int m_lMaxAdjUse;
public:
LONG m_lWidth;
LONG m_lHeight;
CXmlWriter m_oGuidsRes;
CXmlWriter m_oPathRes;
CXmlWriter m_oHandleRes;
CXmlWriter m_oAdjRes;
CXmlWriter m_oTextRect;
CXmlWriter m_oCoef;
public:
CFormulaConverter();
void ConvertCoef(NSCustomShapesConvert::CFormParam pCoef);
void ConvertCoef2(NSCustomShapesConvert::CFormParam pCoef);
void ConvertAdj(const std::vector<LONG>& arAdj);
void ConvertFormula(const std::vector<CFormula>& arFormulas);
void ConvertPath(std::wstring strPath, const CPath& oPath);
void ConvertHandle(const std::vector<CHandle_>& arHandles, std::vector<long>& arAdj, oox::MSOSPT oSType);
void ConvertTextRect ( std::wstring strRect);
private:
void GetValue(const LONG& lParam, const ParamType& eParamType, const bool& bExtShape, CXmlWriter& oWriter);
std::wstring GetValue2(const LONG& lParam, const ParamType& eParamType, const bool& bExtShape);
//---------------------------------------
void ConvertVal(const LONG& lParam1, const ParamType& eType1, const bool& bExtShape1, CXmlWriter& oWriter);
void ConvertSum(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const LONG& lParam3, const ParamType& eType3, const bool& bExtShape1, const bool& bExtShape2, const bool& bExtShape3, CXmlWriter& oWriter);
void ConvertProd(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const LONG& lParam3, const ParamType& eType3, const bool& bExtShape1, const bool& bExtShape2, const bool& bExtShape3, CXmlWriter& oWriter);
void ConvertAbs(const LONG& lParam1, const ParamType& eType1, const bool& bExtShape1, CXmlWriter& oWriter);
void ConvertMin(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const bool& bExtShape1, const bool& bExtShape2, CXmlWriter& oWriter);
void ConvertMax (const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const bool& bExtShape1, const bool& bExtShape2, CXmlWriter& oWriter);
void ConvertIf(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const LONG& lParam3, const ParamType& eType3, const bool& bExtShape1, const bool& bExtShape2, const bool& bExtShape3, CXmlWriter& oWriter);
void ConvertSqrt(const LONG& lParam1, const ParamType& eType1, const bool& bExtShape1, CXmlWriter& oWriter);
void ConvertAt2 (const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const bool& bExtShape1, const bool& bExtShape2, CXmlWriter& oWriter);
void ConvertSin (const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const bool& bExtShape1, const bool& bExtShape2, CXmlWriter& oWriter);
void ConvertCos (const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const bool& bExtShape1, const bool& bExtShape2, CXmlWriter& oWriter);
void ConvertCat2(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const LONG& lParam3, const ParamType& eType3, const bool& bExtShape1, const bool& bExtShape2, const bool& bExtShape3, CXmlWriter& oWriter);
void ConvertSat2(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const LONG& lParam3, const ParamType& eType3, const bool& bExtShape1, const bool& bExtShape2, const bool& bExtShape3, CXmlWriter& oWriter);
void ConvertMod(const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const LONG& lParam3, const ParamType& eType3, const bool& bExtShape1, const bool& bExtShape2, const bool& bExtShape3, CXmlWriter& oWriter);
void ConvertTag (const LONG& lParam1, const ParamType& eType1, const LONG& lParam2, const ParamType& eType2,
const bool& bExtShape1, const bool& bExtShape2, CXmlWriter& oWriter);
void ConvertProd(const std::wstring& strParam1, const std::wstring& strParam2, const LONG& lParam3, CXmlWriter& oWriter);
//-------------------------------------
void FromXML(std::wstring strPath, bool &m_bFill, bool &m_bStroke);
void CreateHandle ( SHandle oHnd );
LONG GetHandlePos(const std::wstring& strParam, const std::wstring& strBase, LONG lSize);
LONG GetHandleValue(const std::wstring& strParam, const LONG& lVal, ParamType& ptType);
void ConvertQuadrX(Aggplus::POINT pPoint, SPointType pPointType);
void ConvertQuadrY(Aggplus::POINT pPoint, SPointType pPointType);
//-------------------------------------
void ConvertSlice_MoveTo(const CSlicePath& oSlice);
void ConvertSlice_RMoveTo(const CSlicePath& oSlice);
void ConvertSlice_LineTo(const CSlicePath& oSlice);
void ConvertSlice_RLineTo(const CSlicePath& oSlice);
void ConvertSlice_ArcTo(const CSlicePath& oSlice);
void ConvertSlice_ClockwiseTo(const CSlicePath& oSlice);
void ConvertSlice_QuadrBesier(const CSlicePath& oSlice);
void ConvertSlice_CurveTo(const CSlicePath& oSlice);
void ConvertSlice_RCurveTo(const CSlicePath& oSlice);
void ConvertSlice_AngleEllipse(const CSlicePath& oSlice);
void ConvertSlice_EllipticalQuadrX(const CSlicePath& oSlice);
void ConvertSlice_EllipticalQuadrY(const CSlicePath& oSlice);
};
}