Compare commits

..

5 Commits

Author SHA1 Message Date
967ab71adc XLsFormat - fix bug #41967 2019-06-26 15:37:01 +03:00
a48322f1cc [x2t] Fix CStreamBinaryWriter 2019-06-25 20:20:28 +03:00
bd41922f66 OdfFormatWriter - fix bug #41956 2019-06-25 17:55:49 +03:00
ccd73c8c68 [ios][x2t] fixed build 2019-06-25 15:33:38 +03:00
5b6659f816 [android][x2t] fix build 2019-06-25 14:40:02 +03:00
7 changed files with 239 additions and 221 deletions

View File

@ -303,14 +303,14 @@ void odf_text_context::start_element(office_element_ptr & elm, office_element_pt
text_elements_list_.push_back(state);
if (!current_level_.empty())
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(elm);
current_level_.push_back(state);
}
void odf_text_context::end_element()
{
if (single_paragraph_ == false && !current_level_.empty())
if (single_paragraph_ == false && false == current_level_.empty())
{
current_level_.pop_back();
}
@ -349,7 +349,7 @@ void odf_text_context::start_span(bool styled)
if (style_)
{
if (parent_span_style_.length() >0)
if (false == parent_span_style_.empty())
{
style_->style_parent_style_name_ = parent_span_style_;
}
@ -371,7 +371,7 @@ void odf_text_context::end_span()
{
if (styles_context_ == NULL || single_paragraph_)return;
if (current_level_.size() > 0)
if (false == current_level_.empty())
current_level_.pop_back();
text_properties_ = NULL;
@ -396,7 +396,7 @@ void odf_text_context::start_list_item()
text_elements_list_.push_back(state);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(list_elm);
current_level_.push_back(state);
@ -410,14 +410,14 @@ void odf_text_context::end_list_item()
if (list_state_.levels.back() == false) return;
if (current_level_.size() > 0)
if (false == current_level_.empty())
current_level_.pop_back();
list_state_.levels.back() = false;
}
void odf_text_context::start_list(std::wstring style_name) //todoooo add new_numbering ???
bool odf_text_context::start_list(std::wstring style_name) //todoooo add new_numbering ???
{
if (styles_context_ == NULL || single_paragraph_)return;
if (styles_context_ == NULL || single_paragraph_)return false;
office_element_ptr list_elm;
create_element(L"text", L"list", list_elm, odf_context_);
@ -427,7 +427,7 @@ void odf_text_context::start_list(std::wstring style_name) //todoooo add new_num
office_element_ptr style_elm;
odf_element_state state = { list_elm, style_name, style_elm, level};
if (style_name.length() > 0)
if (false == style_name.empty())
{
text_list* list = dynamic_cast<text_list*>(list_elm.get());
if (list)
@ -443,13 +443,15 @@ void odf_text_context::start_list(std::wstring style_name) //todoooo add new_num
}
text_elements_list_.push_back(state);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(list_elm);
current_level_.push_back(state);
list_state_.levels.push_back(false);
list_state_.started_list = true;
return true;
}
void odf_text_context::end_list()
{
@ -574,7 +576,7 @@ void odf_text_context::add_hyperlink (std::wstring ref, std::wstring display_tex
hyperlink->common_xlink_attlist_.href_ = ref;
hyperlink->common_xlink_attlist_.type_ = xlink_type::Simple;
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(elm);
}
@ -657,7 +659,7 @@ bool odf_text_context::set_type_break(int type, int clear)//todooo clear ???
office_element_ptr elm;
create_element(L"text", L"line-break", elm, odf_context_);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(elm);
}
return need_restart;

View File

@ -107,7 +107,7 @@ public:
void start_list_item ();
void end_list_item ();
void start_list (std::wstring style_name);
bool start_list (std::wstring style_name);
void end_list ();
bool is_need_break (){return bool(need_break_);}

View File

@ -1052,19 +1052,22 @@ void odt_conversion_context::start_list_item(int level, std::wstring style_name
if (text_context()->list_state_.started_list == false)
{
text_context()->start_list(style_name);
//text_context()->set_list_continue(true); //??? держать в памяти все списки????
add_to_root();
if (text_context()->start_list(style_name))
{
//text_context()->set_list_continue(true); //??? держать в памяти все списки????
add_to_root();
}
}
text_context()->start_list_item();
text_context()->start_list_item();
if (text_context()->list_state_.style_name == style_name)
style_name = L"";
while (text_context()->list_state_.levels.size() < level)
{
text_context()->start_list(style_name);
if (false == text_context()->start_list(style_name))
break;
text_context()->start_list_item();
}
}
@ -1076,7 +1079,7 @@ void odt_conversion_context::set_no_list()
{
if (text_context()->list_state_.started_list == false) return;
while (text_context()->list_state_.levels.size()>0)
while (false == text_context()->list_state_.levels.empty())
{
text_context()->end_list_item();
text_context()->end_list();
@ -1205,16 +1208,16 @@ void odt_conversion_context::end_comment_content()
}
void odt_conversion_context::end_comment(int oox_comm_id)
{
bool added = comment_context_.find_by_id(oox_comm_id);
int index_added = comment_context_.find_by_id(oox_comm_id);
if (added == true)
if (index_added > 0 )
{
office_element_ptr comm_elm;
create_element(L"office", L"annotation-end", comm_elm, this);
comment_context_.end_comment(comm_elm, oox_comm_id);
if (text_context()->current_level_.size() > 0)
if (false == text_context()->current_level_.empty())
text_context()->current_level_.back().elm->add_child_element(comm_elm);
}
}

View File

@ -1854,7 +1854,10 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
{
while ((int)odf_context()->text_context()->list_state_.levels.size() < list_level)
{
odf_context()->text_context()->start_list(list_style_name);
if (false == odf_context()->text_context()->start_list(list_style_name))
{
break;
}
odf_context()->text_context()->start_list_item();
if (odf_context()->text_context()->list_state_.style_name == list_style_name)

View File

@ -1129,7 +1129,17 @@ namespace NSBinPptxRW
}
void CBinaryFileWriter::_WriteStringWithLength(const WCHAR* sBuffer, _UINT32 lCount, bool bByte)
{
CheckBufferSize(UINT32_SIZEOF);
//CheckBufferSize at first to prevent negative m_lPosition after Flush in CStreamBinaryWriter
if (sizeof(wchar_t) == 4)
{
_INT32 lSizeMemMax = 4 * lCount + 2;//2 - for null terminator
CheckBufferSize(UINT32_SIZEOF + lSizeMemMax);
}
else
{
_INT32 lSizeMem = 2 * lCount;
CheckBufferSize(UINT32_SIZEOF + lSizeMem);
}
//skip size
m_lPosition += UINT32_SIZEOF;
m_pStreamCur += UINT32_SIZEOF;

View File

@ -212,7 +212,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
count = proc.repeated<BIGNAME>(0, 0);
while(count > 0)
{
m_arBIGNAME.insert(m_arNote.begin(), elements_.back());
m_arBIGNAME.insert(m_arBIGNAME.begin(), elements_.back());
elements_.pop_back();
count--;
}

View File

@ -1,196 +1,196 @@
/*
* (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
*
*/
#if defined(GetTempPath)
#undef GetTempPath
#endif
#if defined(CreateFile)
#undef CreateFile
#endif
#if defined(CopyFile)
#undef CopyFile
#endif
#if defined(DeleteFile)
#undef DeleteFile
#endif
#ifndef _BUILD_FILE_CROSSPLATFORM_H_
#define _BUILD_FILE_CROSSPLATFORM_H_
#include <string>
#include <string.h>
#include <stdio.h>
#include "Base64.h"
#include "../../Common/kernel_config.h"
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val.c_str(), (LONG)val.length())
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
std::wstring KERNEL_DECL CorrectPathW(const std::wstring& path);
namespace NSFile
{
#define WriteUtf16_WCHAR(code, p) \
if (code < 0x10000) \
*p++ = code; \
else \
{ \
code -= 0x10000; \
*p++ = 0xD800 | ((code >> 10) & 0x03FF); \
*p++ = 0xDC00 | (code & 0x03FF); \
}
class CStringUtf16
{
public:
BYTE* Data;
int Length;
public:
CStringUtf16()
{
Data = NULL;
Length = 0;
}
~CStringUtf16()
{
RELEASEARRAYOBJECTS(Data);
}
};
class KERNEL_DECL CUtf8Converter
{
public:
static std::wstring GetUnicodeFromCharPtr(const char* pData, LONG lCount, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeFromCharPtr(const std::string& sParam, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount );
static void GetUnicodeStringFromUTF8WithHHHH_4bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH_2bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static inline LONG GetUnicodeStringFromUTF8BufferSize( LONG lCount );
static void GetUtf8StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode_2bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode2(const wchar_t* pUnicodes, LONG lCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode(const std::wstring& sData);
// utf16
static void GetUtf16StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, int& lOutputCount, bool bIsBOM = false);
static void GetUtf16StringFromUnicode_4bytes2(const wchar_t* pUnicodes, LONG lCount, CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const unsigned short* pUtf16, LONG lCount);
static inline long CheckHHHHChar(const BYTE* pBuffer);
static inline long CheckHHHHChar(const wchar_t* pBuffer);
};
class KERNEL_DECL CFileBinary
{
protected:
FILE* m_pFile;
long m_lFilePosition;
long m_lFileSize;
public:
CFileBinary();
virtual ~CFileBinary();
virtual void CloseFile();
FILE* GetFileNative();
long GetFileSize();
long GetFilePosition();
bool OpenFile(const std::wstring& sFileName, bool bRewrite = false);
bool CreateFileW(const std::wstring& sFileName);
bool CreateTempFile();
bool SeekFile(int lFilePosition, int nSeekMode = 0);
bool ReadFile(BYTE* pData, DWORD nBytesToRead, DWORD& dwSizeRead);
bool WriteFile(const BYTE* pData, DWORD nBytesCount);
long TellFile();
long SizeFile();
void WriteStringUTF8(const std::wstring& strXml, bool bIsBOM = false);
static bool ReadAllBytes(const std::wstring& strFileName, BYTE** ppData, DWORD& nBytesCount);
static bool ReadAllTextUtf8(const std::wstring& strFileName, std::wstring& sData);
static bool ReadAllTextUtf8A(const std::wstring& strFileName, std::string& sData);
static bool SaveToFile(const std::wstring& strFileName, const std::wstring& strXml, bool bIsBOM = false);
static bool Exists(const std::wstring& strFileName);
static bool Copy(const std::wstring& strSrc, const std::wstring& strDst);
static bool Remove(const std::wstring& strFileName);
static bool Move(const std::wstring& strSrc, const std::wstring& strDst);
static bool Truncate(const std::wstring& sPath, size_t nNewSize);
static std::wstring GetTempPath();
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
static FILE* OpenFileNative(const std::wstring& sFileName, const std::wstring& sMode);
};
class KERNEL_DECL CBase64Converter
{
public:
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
};
}
namespace NSFile
{
#define NS_FILE_MAX_PATH 32768
KERNEL_DECL std::wstring GetProcessPath();
KERNEL_DECL std::wstring GetProcessDirectory();
// CommonFunctions
KERNEL_DECL std::wstring GetFileExtention(const std::wstring& sPath);
KERNEL_DECL std::wstring GetFileName(const std::wstring& sPath);
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& sPath);
}
#endif //_BUILD_FILE_CROSSPLATFORM_H_
/*
* (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
*
*/
#if defined(GetTempPath)
#undef GetTempPath
#endif
#if defined(CreateFile)
#undef CreateFile
#endif
#if defined(CopyFile)
#undef CopyFile
#endif
#if defined(DeleteFile)
#undef DeleteFile
#endif
#ifndef _BUILD_FILE_CROSSPLATFORM_H_
#define _BUILD_FILE_CROSSPLATFORM_H_
#include <string>
#include <string.h>
#include <stdio.h>
#include "Base64.h"
#include "../../Common/kernel_config.h"
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val.c_str(), (LONG)val.length())
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
std::wstring KERNEL_DECL CorrectPathW(const std::wstring& path);
namespace NSFile
{
#define WriteUtf16_WCHAR(code, p) \
if (code < 0x10000) \
*p++ = code; \
else \
{ \
code -= 0x10000; \
*p++ = 0xD800 | ((code >> 10) & 0x03FF); \
*p++ = 0xDC00 | (code & 0x03FF); \
}
class CStringUtf16
{
public:
BYTE* Data;
int Length;
public:
CStringUtf16()
{
Data = NULL;
Length = 0;
}
~CStringUtf16()
{
RELEASEARRAYOBJECTS(Data);
}
};
class KERNEL_DECL CUtf8Converter
{
public:
static std::wstring GetUnicodeFromCharPtr(const char* pData, LONG lCount, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeFromCharPtr(const std::string& sParam, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount );
static void GetUnicodeStringFromUTF8WithHHHH_4bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH_2bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static inline LONG GetUnicodeStringFromUTF8BufferSize( LONG lCount );
static void GetUtf8StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode_2bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode2(const wchar_t* pUnicodes, LONG lCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode(const std::wstring& sData);
// utf16
static void GetUtf16StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, int& lOutputCount, bool bIsBOM = false);
static void GetUtf16StringFromUnicode_4bytes2(const wchar_t* pUnicodes, LONG lCount, CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const unsigned short* pUtf16, LONG lCount);
static long CheckHHHHChar(const BYTE* pBuffer);
static long CheckHHHHChar(const wchar_t* pBuffer);
};
class KERNEL_DECL CFileBinary
{
protected:
FILE* m_pFile;
long m_lFilePosition;
long m_lFileSize;
public:
CFileBinary();
virtual ~CFileBinary();
virtual void CloseFile();
FILE* GetFileNative();
long GetFileSize();
long GetFilePosition();
bool OpenFile(const std::wstring& sFileName, bool bRewrite = false);
bool CreateFileW(const std::wstring& sFileName);
bool CreateTempFile();
bool SeekFile(int lFilePosition, int nSeekMode = 0);
bool ReadFile(BYTE* pData, DWORD nBytesToRead, DWORD& dwSizeRead);
bool WriteFile(const BYTE* pData, DWORD nBytesCount);
long TellFile();
long SizeFile();
void WriteStringUTF8(const std::wstring& strXml, bool bIsBOM = false);
static bool ReadAllBytes(const std::wstring& strFileName, BYTE** ppData, DWORD& nBytesCount);
static bool ReadAllTextUtf8(const std::wstring& strFileName, std::wstring& sData);
static bool ReadAllTextUtf8A(const std::wstring& strFileName, std::string& sData);
static bool SaveToFile(const std::wstring& strFileName, const std::wstring& strXml, bool bIsBOM = false);
static bool Exists(const std::wstring& strFileName);
static bool Copy(const std::wstring& strSrc, const std::wstring& strDst);
static bool Remove(const std::wstring& strFileName);
static bool Move(const std::wstring& strSrc, const std::wstring& strDst);
static bool Truncate(const std::wstring& sPath, size_t nNewSize);
static std::wstring GetTempPath();
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
static FILE* OpenFileNative(const std::wstring& sFileName, const std::wstring& sMode);
};
class KERNEL_DECL CBase64Converter
{
public:
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
};
}
namespace NSFile
{
#define NS_FILE_MAX_PATH 32768
KERNEL_DECL std::wstring GetProcessPath();
KERNEL_DECL std::wstring GetProcessDirectory();
// CommonFunctions
KERNEL_DECL std::wstring GetFileExtention(const std::wstring& sPath);
KERNEL_DECL std::wstring GetFileName(const std::wstring& sPath);
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& sPath);
}
#endif //_BUILD_FILE_CROSSPLATFORM_H_