mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
add ansi to vsdx binary
This commit is contained in:
@ -319,7 +319,10 @@ namespace NSStringUtils
|
||||
{
|
||||
WriteEncodeXmlString(sString.c_str(), (int)sString.length());
|
||||
}
|
||||
|
||||
void CStringBuilder::WriteEncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(std::wstring(sString.begin(), sString.end()));
|
||||
}
|
||||
void CStringBuilder::WriteEncodeXmlString(const wchar_t* pString, int nCount)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
|
||||
@ -110,6 +110,8 @@ namespace NSStringUtils
|
||||
void WriteEncodeXmlString(const std::wstring& sString);
|
||||
void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
void WriteEncodeXmlString(const std::string& sString);
|
||||
|
||||
void WriteEncodeXmlStringHHHH(const std::wstring& sString);
|
||||
void WriteEncodeXmlStringHHHH(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
|
||||
@ -918,4 +918,87 @@ namespace NSCommon
|
||||
|
||||
std::wstring& get()const { return *m_pPointer; }
|
||||
};
|
||||
class nullable_astring : public nullable_base<std::string>
|
||||
{
|
||||
public:
|
||||
nullable_astring() : nullable_base<std::string>()
|
||||
{
|
||||
}
|
||||
nullable_astring(const nullable_astring& oOther)
|
||||
{
|
||||
if (NULL == oOther.m_pPointer)
|
||||
m_pPointer = NULL;
|
||||
else
|
||||
m_pPointer = new std::string(*oOther.m_pPointer);
|
||||
}
|
||||
void operator=(const std::string& value)
|
||||
{
|
||||
RELEASEOBJECT(m_pPointer);
|
||||
m_pPointer = new std::string(value);
|
||||
}
|
||||
void operator+=(const std::string& value)
|
||||
{
|
||||
if (NULL == m_pPointer)
|
||||
m_pPointer = new std::string(value);
|
||||
else
|
||||
*m_pPointer += value;
|
||||
}
|
||||
void operator=(std::string* value)
|
||||
{
|
||||
RELEASEOBJECT(m_pPointer);
|
||||
m_pPointer = value;
|
||||
}
|
||||
nullable_astring& operator=(const nullable_astring& oSrc)
|
||||
{
|
||||
RELEASEOBJECT(m_pPointer);
|
||||
|
||||
if (NULL != oSrc.m_pPointer)
|
||||
m_pPointer = new std::string(*oSrc);
|
||||
return *this;
|
||||
}
|
||||
const bool operator==(const nullable_astring& oOther) const
|
||||
{
|
||||
if (!this->m_pPointer)
|
||||
return false;
|
||||
|
||||
return (*this->m_pPointer) == *oOther;
|
||||
}
|
||||
const bool operator==(const std::string& oOther) const
|
||||
{
|
||||
if (!this->m_pPointer)
|
||||
return false;
|
||||
|
||||
return (*this->m_pPointer) == oOther;
|
||||
}
|
||||
std::string get_value_or(const std::string& value) const
|
||||
{
|
||||
if (NULL == m_pPointer)
|
||||
{
|
||||
std::string ret = value;
|
||||
return ret;
|
||||
}
|
||||
return *m_pPointer;
|
||||
}
|
||||
std::string ToAttribute(const std::string& name) const
|
||||
{
|
||||
if (m_pPointer)
|
||||
{
|
||||
return name + "=\"" + (*m_pPointer) + "\" ";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
std::string* GetPointerEmptyNullable()
|
||||
{
|
||||
std::string* pOldPointer = this->m_pPointer;
|
||||
this->m_pPointer = NULL;
|
||||
return pOldPointer;
|
||||
}
|
||||
std::string& operator*() { return *m_pPointer; }
|
||||
std::string* operator->() { return m_pPointer; }
|
||||
|
||||
std::string& operator*() const { return *m_pPointer; }
|
||||
std::string* operator->() const { return m_pPointer; }
|
||||
|
||||
std::string& get()const { return *m_pPointer; }
|
||||
};
|
||||
}
|
||||
|
||||
@ -1058,7 +1058,6 @@ namespace NSBinPptxRW
|
||||
pData += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void CBinaryFileWriter::WriteString1(int type, const std::wstring& val)
|
||||
{
|
||||
BYTE bType = (BYTE)type;
|
||||
@ -1067,6 +1066,14 @@ namespace NSBinPptxRW
|
||||
std::wstring* s = const_cast<std::wstring*>(&val);
|
||||
_WriteStringWithLength(s->c_str(), (_UINT32)s->length(), false);
|
||||
}
|
||||
void CBinaryFileWriter::WriteString1(int type, const std::string& val)
|
||||
{
|
||||
BYTE bType = (BYTE)type;
|
||||
WriteBYTE(bType);
|
||||
|
||||
std::string* s = const_cast<std::string*>(&val);
|
||||
_WriteStringWithLength(s->c_str(), (_UINT32)s->length());
|
||||
}
|
||||
void CBinaryFileWriter::WriteString2(int type, const NSCommon::nullable_string& val)
|
||||
{
|
||||
if (val.is_init())
|
||||
@ -1077,7 +1084,11 @@ namespace NSBinPptxRW
|
||||
std::wstring* s = const_cast<std::wstring*>(&val);
|
||||
_WriteStringWithLength(s->c_str(), (_UINT32)s->length(), false);
|
||||
}
|
||||
|
||||
void CBinaryFileWriter::WriteString2(int type, const NSCommon::nullable_astring& val)
|
||||
{
|
||||
if (val.is_init())
|
||||
WriteString1(type, *val);
|
||||
}
|
||||
void CBinaryFileWriter::WriteStringData(const WCHAR* pData, _UINT32 len)
|
||||
{
|
||||
_WriteStringWithLength(pData, len, false);
|
||||
@ -1281,6 +1292,18 @@ namespace NSBinPptxRW
|
||||
m_pStreamCur += lSizeMem;
|
||||
return lSizeMem;
|
||||
}
|
||||
_INT32 CBinaryFileWriter::_WriteString(const char* sBuffer, _UINT32 lCount)
|
||||
{
|
||||
_UINT32 lSizeMem = lCount * sizeof(char);
|
||||
|
||||
CheckBufferSize(UINT32_SIZEOF + lSizeMem);
|
||||
|
||||
memcpy(m_pStreamCur, sBuffer, lSizeMem);
|
||||
|
||||
m_lPosition += lSizeMem;
|
||||
m_pStreamCur += lSizeMem;
|
||||
return lSizeMem;
|
||||
}
|
||||
void CBinaryFileWriter::_WriteStringWithLength(const WCHAR* sBuffer, _UINT32 lCount, bool bByte)
|
||||
{
|
||||
if (sizeof(wchar_t) == 4)
|
||||
@ -1318,6 +1341,29 @@ namespace NSBinPptxRW
|
||||
m_lPosition += lSizeMem;
|
||||
m_pStreamCur += lSizeMem;
|
||||
}
|
||||
void CBinaryFileWriter::_WriteStringWithLength(const char* sBuffer, _UINT32 lCount)
|
||||
{
|
||||
CheckBufferSize(UINT32_SIZEOF + lCount);
|
||||
|
||||
//skip size
|
||||
m_lPosition += UINT32_SIZEOF;
|
||||
m_pStreamCur += UINT32_SIZEOF;
|
||||
//write string
|
||||
_INT32 lSizeMem = _WriteString(sBuffer, lCount);
|
||||
|
||||
//back to size
|
||||
m_lPosition -= lSizeMem;
|
||||
m_pStreamCur -= lSizeMem;
|
||||
m_lPosition -= UINT32_SIZEOF;
|
||||
m_pStreamCur -= UINT32_SIZEOF;
|
||||
|
||||
//write size
|
||||
WriteLONG(lSizeMem);
|
||||
|
||||
//skip string
|
||||
m_lPosition += lSizeMem;
|
||||
m_pStreamCur += lSizeMem;
|
||||
}
|
||||
|
||||
CStreamBinaryWriter::CStreamBinaryWriter(size_t bufferSize)
|
||||
{
|
||||
|
||||
@ -63,6 +63,7 @@ namespace NSCommon
|
||||
class nullable_uint;
|
||||
class nullable_double;
|
||||
class nullable_sizet;
|
||||
class nullable_astring;
|
||||
}
|
||||
namespace NSStringUtils
|
||||
{
|
||||
@ -315,7 +316,6 @@ namespace NSBinPptxRW
|
||||
void WriteDoubleReal(const double& dValue);
|
||||
|
||||
void WriteBYTEArray (const BYTE* pBuffer, size_t len);
|
||||
void WriteStringA (std::string& sBuffer);
|
||||
|
||||
void WriteStringW (const std::wstring& sBuffer);
|
||||
void WriteStringW2 (const std::wstring& sBuffer);
|
||||
@ -343,6 +343,10 @@ namespace NSBinPptxRW
|
||||
void WriteString (const std::wstring& val);
|
||||
void WriteStringData(const WCHAR* pData, _UINT32 len);
|
||||
|
||||
void WriteString1 (int type, const std::string& val);
|
||||
void WriteString2 (int type, const NSCommon::nullable_astring& val);
|
||||
void WriteStringA (std::string& val);
|
||||
|
||||
void WriteString1Data(int type, const WCHAR* pData, _UINT32 len);
|
||||
|
||||
void WriteBool1(int type, const bool& val);
|
||||
@ -439,7 +443,9 @@ namespace NSBinPptxRW
|
||||
bool GetSafearray(BYTE **ppArray, size_t& szCount);
|
||||
private:
|
||||
_INT32 _WriteString(const WCHAR* sBuffer, _UINT32 lCount);
|
||||
_INT32 _WriteString(const char* sBuffer, _UINT32 lCount);
|
||||
void _WriteStringWithLength(const WCHAR* sBuffer, _UINT32 lCount, bool bByte);
|
||||
void _WriteStringWithLength(const char* sBuffer, _UINT32 lCount);
|
||||
};
|
||||
|
||||
class CStreamBinaryWriter : public NSFile::CFileBinary, public CBinaryFileWriter
|
||||
|
||||
@ -199,6 +199,15 @@ void CXmlWriter::WriteAttribute2(const std::wstring& strAttributeName, const std
|
||||
m_oWriter.WriteEncodeXmlString(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute2(const std::wstring& strAttributeName, const std::string& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
m_oWriter.WriteEncodeXmlString(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const double& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
@ -428,6 +437,11 @@ void CXmlWriter::WriteAttribute2(const std::wstring& strName, const nullable_str
|
||||
if (value.IsInit())
|
||||
WriteAttribute2(strName, *value);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute2(const std::wstring& strName, const nullable_astring& value)
|
||||
{
|
||||
if (value.IsInit())
|
||||
WriteAttribute2(strName, *value);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strName, const nullable_bool& value)
|
||||
{
|
||||
if (value.IsInit())
|
||||
|
||||
@ -124,7 +124,8 @@ namespace NSBinPptxRW
|
||||
//
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const wchar_t* val);
|
||||
void WriteAttribute2(const std::wstring& strAttributeName, const std::wstring& val);
|
||||
void WriteAttribute2(const std::wstring& strAttributeName, const std::wstring& val); // xml
|
||||
void WriteAttribute2(const std::wstring& strAttributeName, const std::string& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const double& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const int& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const bool& val);
|
||||
@ -160,8 +161,9 @@ namespace NSBinPptxRW
|
||||
void WriteAttribute(const std::wstring& strName, const nullable_sizet& value);
|
||||
void WriteAttribute(const std::wstring& strName, const nullable_double& value);
|
||||
void WriteAttribute(const std::wstring& strName, const nullable_string& value);
|
||||
void WriteAttribute2(const std::wstring& strName, const nullable_string& value);
|
||||
void WriteAttribute2(const std::wstring& strName, const nullable_string& value); // xml
|
||||
void WriteAttribute(const std::wstring& strName, const nullable_bool& value);
|
||||
void WriteAttribute2(const std::wstring& strName, const nullable_astring& value);
|
||||
|
||||
template <typename T>
|
||||
void WriteAttribute(const std::wstring& strName, const nullable_limit<T>& value)
|
||||
|
||||
@ -188,7 +188,11 @@ namespace OOX
|
||||
{\
|
||||
Value = Reader.GetText();\
|
||||
}
|
||||
|
||||
#define WritingElement_ReadAttributesA_Read_ifChar(Reader, AttrName, Value) \
|
||||
if ( strcmp(AttrName, wsName) == 0 )\
|
||||
{\
|
||||
Value = Reader.GetTextA();\
|
||||
}
|
||||
#define WritingElement_ReadAttributes_Read_else_if(Reader, AttrName, Value) \
|
||||
else if ( AttrName == wsName )\
|
||||
Value = Reader.GetText();
|
||||
@ -197,6 +201,10 @@ namespace OOX
|
||||
else if ( strcmp(AttrName, wsName) == 0 )\
|
||||
Value = Reader.GetText();
|
||||
|
||||
#define WritingElement_ReadAttributesA_Read_else_ifChar(Reader, AttrName, Value) \
|
||||
else if ( strcmp(AttrName, wsName) == 0 )\
|
||||
Value = Reader.GetTextA();
|
||||
|
||||
#define WritingElement_ReadAttributes_ReadSingle(Reader, AttrName, Value) \
|
||||
if ( AttrName == wsName )\
|
||||
{\
|
||||
|
||||
@ -708,9 +708,9 @@ namespace OOX
|
||||
WritingElement_ReadAttributes_StartChar_No_NS(oReader)
|
||||
WritingElement_ReadAttributes_Read_ifChar(oReader, "IX", IX)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "Del", Del)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "LocalName", LocalName)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "T", T)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "T", T)
|
||||
WritingElement_ReadAttributes_EndChar_No_NS(oReader)
|
||||
}
|
||||
void CRow::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
@ -779,7 +779,7 @@ namespace OOX
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
N = pReader->GetString2();
|
||||
N = pReader->GetString2A();
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
@ -787,7 +787,7 @@ namespace OOX
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
T = pReader->GetString2();
|
||||
T = pReader->GetString2A();
|
||||
}break;
|
||||
case 4:
|
||||
{
|
||||
@ -843,7 +843,7 @@ namespace OOX
|
||||
WritingElement_ReadAttributes_StartChar_No_NS(oReader)
|
||||
WritingElement_ReadAttributes_Read_ifChar(oReader, "IX", IX)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "Del", Del)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributes_EndChar_No_NS(oReader)
|
||||
}
|
||||
void CSection::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
@ -915,7 +915,7 @@ namespace OOX
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
N = pReader->GetString2();
|
||||
N = pReader->GetString2A();
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
@ -1029,10 +1029,10 @@ namespace OOX
|
||||
void CCell::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_StartChar_No_NS(oReader)
|
||||
WritingElement_ReadAttributes_Read_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "U", U)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "E", E)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "F", F)
|
||||
WritingElement_ReadAttributesA_Read_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "U", U)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "E", E)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "F", F)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "V", V)
|
||||
WritingElement_ReadAttributes_EndChar_No_NS(oReader)
|
||||
}
|
||||
@ -1088,19 +1088,19 @@ namespace OOX
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
N = pReader->GetString2();
|
||||
N = pReader->GetString2A();
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
U = pReader->GetString2();
|
||||
U = pReader->GetString2A();
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
E = pReader->GetString2();
|
||||
E = pReader->GetString2A();
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
F = pReader->GetString2();
|
||||
F = pReader->GetString2A();
|
||||
}break;
|
||||
case 4:
|
||||
{
|
||||
@ -1158,7 +1158,7 @@ namespace OOX
|
||||
void CTrigger::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_StartChar_No_NS(oReader)
|
||||
WritingElement_ReadAttributes_Read_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributesA_Read_ifChar(oReader, "N", N)
|
||||
WritingElement_ReadAttributes_EndChar_No_NS(oReader)
|
||||
}
|
||||
void CTrigger::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
@ -1199,7 +1199,7 @@ namespace OOX
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
N = pReader->GetString2();
|
||||
N = pReader->GetString2A();
|
||||
}break;
|
||||
}
|
||||
}
|
||||
@ -1539,10 +1539,10 @@ namespace OOX
|
||||
{
|
||||
WritingElement_ReadAttributes_StartChar_No_NS(oReader)
|
||||
WritingElement_ReadAttributes_Read_ifChar(oReader, "FromSheet", FromSheet)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "FromCell", FromCell)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "FromCell", FromCell)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "FromPart", FromPart)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ToSheet", ToSheet)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ToCell", ToCell)
|
||||
WritingElement_ReadAttributesA_Read_else_ifChar(oReader, "ToCell", ToCell)
|
||||
WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ToPart", ToPart)
|
||||
WritingElement_ReadAttributes_EndChar_No_NS(oReader)
|
||||
}
|
||||
@ -1580,7 +1580,7 @@ namespace OOX
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
FromCell = pReader->GetString2();
|
||||
FromCell = pReader->GetString2A();
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
@ -1592,7 +1592,7 @@ namespace OOX
|
||||
}break;
|
||||
case 4:
|
||||
{
|
||||
ToCell = pReader->GetString2();
|
||||
ToCell = pReader->GetString2A();
|
||||
}break;
|
||||
case 5:
|
||||
{
|
||||
|
||||
@ -275,10 +275,10 @@ namespace OOX
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
virtual EElementType getType() const;
|
||||
|
||||
nullable_string N;
|
||||
nullable_astring N;
|
||||
nullable_string LocalName;
|
||||
nullable_uint IX;
|
||||
nullable_string T; // todooo GeometryRowTypes
|
||||
nullable_astring T; // todooo GeometryRowTypes
|
||||
nullable_bool Del;
|
||||
};
|
||||
class CSection : public WritingElementWithChilds<>
|
||||
@ -300,7 +300,7 @@ namespace OOX
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
virtual EElementType getType() const;
|
||||
|
||||
nullable_string N;
|
||||
nullable_astring N;
|
||||
nullable_bool Del;
|
||||
nullable_uint IX;
|
||||
};
|
||||
@ -353,10 +353,10 @@ namespace OOX
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
public:
|
||||
nullable_string N;
|
||||
nullable_string U; //todooo type
|
||||
nullable_string E; //todooo err
|
||||
nullable_string F;
|
||||
nullable_astring N;
|
||||
nullable_astring U; //todooo type
|
||||
nullable_astring E; //todooo err
|
||||
nullable_astring F;
|
||||
nullable_string V;
|
||||
|
||||
nullable<CRefBy> RefBy;
|
||||
@ -386,7 +386,7 @@ namespace OOX
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
public:
|
||||
nullable_string N;
|
||||
nullable_astring N;
|
||||
|
||||
nullable<CRefBy> RefBy;
|
||||
};
|
||||
@ -466,10 +466,10 @@ namespace OOX
|
||||
|
||||
public:
|
||||
nullable_uint FromSheet;
|
||||
nullable_string FromCell;
|
||||
nullable_astring FromCell;
|
||||
nullable_int FromPart;
|
||||
nullable_uint ToSheet;
|
||||
nullable_string ToCell;
|
||||
nullable_astring ToCell;
|
||||
nullable_int ToPart;
|
||||
};
|
||||
class CConnects : public WritingElementWithChilds<CConnect>
|
||||
|
||||
Reference in New Issue
Block a user