Compare commits

...

17 Commits

29 changed files with 320 additions and 84 deletions

View File

@ -585,7 +585,13 @@ void ods_conversion_context::end_drawings()
{
current_table().drawing_context()->clear();
}
void ods_conversion_context::add_external_reference(const std::wstring & ref)
{
ods_external_state external;
external.ref = ref;
externals_.push_back(external);
}
double ods_conversion_context::convert_symbol_width(double val)
{
//width = ((int)((column_width * Digit_Width + 5) / Digit_Width * 256 )) / 256.;

View File

@ -53,6 +53,11 @@ struct _font_metrix
double approx_symbol_size;//in pt
};
struct ods_external_state
{
std::wstring ref;
};
class ods_conversion_context : public odf_conversion_context
{
public:
@ -85,6 +90,8 @@ public:
void add_text_content(const std::wstring & text);
void end_cell_text();
void add_external_reference(const std::wstring & ref);
void add_merge_cells(const std::wstring & ref);
void add_hyperlink(std::wstring & ref, std::wstring & link, std::wstring & display);
@ -120,16 +127,13 @@ public:
void start_table_view(int view_id);
void end_table_view();
std::vector<ods_external_state> externals_;
private:
_font_metrix font_metrix_;
ods_table_context table_context_;
odf_text_context* current_text_context_;
office_spreadsheet* root_spreadsheet_;
};

View File

@ -610,7 +610,7 @@ void ods_table_state::add_definded_expression(office_element_ptr & elm)
{
if (!table_defined_expressions_)
{
create_element(L"table", L"named-expressions",table_defined_expressions_,context_);
create_element(L"table", L"named-expressions", table_defined_expressions_, context_);
office_table_->add_child_element(table_defined_expressions_);
}
if (!table_defined_expressions_)return;
@ -630,7 +630,7 @@ void ods_table_state::start_comment(int col, int row, std::wstring & author)
ods_comment_state state;
state.row=row; state.col =col; state.author = author;
create_element(L"office", L"annotation",state.elm,context_);
create_element(L"office", L"annotation", state.elm, context_);
comments_.push_back(state);
}
@ -661,7 +661,7 @@ void ods_table_state::end_comment(odf_text_context *text_context)
if (comments_.back().author.length() > 0 && comments_.back().elm)
{
office_element_ptr dc_elm;
create_element(L"dc", L"creator",dc_elm,context_);
create_element(L"dc", L"creator", dc_elm, context_);
if (dc_elm)
{
dc_elm->add_text(comments_.back().author);
@ -799,19 +799,52 @@ void ods_table_state::set_cell_spanned(int spanned_cols, int spanned_rows)
}
void ods_table_state::set_cell_formula(std::wstring & formula)
{
if (formula.length() < 1)return;
if (formula.empty())return;
//test external link
{
boost::wregex re(L"([\[]\\d+\[\]])+");
bool bExternal = true;
boost::wregex re(L"([\[]\\d+[\]])+");
while(bExternal)
{
boost::wsmatch result;
bool b = boost::regex_search(formula, result, re);
if (b) return; //todoooo
bExternal = boost::regex_search(formula, result, re);
if (!bExternal) break;
ods_conversion_context* ods_context = dynamic_cast<ods_conversion_context*>(context_);
std::wstring refExternal = result[1].str();
int idExternal = XmlUtils::GetInteger(refExternal.substr(1, refExternal.length() - 1)) - 1;
while(idExternal >= 0 && idExternal < ods_context->externals_.size())
{
size_t pos = formula.find(refExternal);
if (pos == std::wstring::npos)
break;
std::wstring new_formula;
if (pos > 0 && formula[pos - 1] == L'\'')
{
new_formula = formula.substr(0, pos - 1);
new_formula += L"'EXTERNALREF" + ods_context->externals_[idExternal].ref + L"'#";
new_formula += L"'";
}
else
{
new_formula = formula.substr(0, pos);
new_formula += L"'EXTERNALREF" + ods_context->externals_[idExternal].ref + L"'#";
}
pos += refExternal.length();
new_formula += formula.substr(pos, formula.length() - pos);
formula = new_formula;
}
}
std::wstring odfFormula = formulas_converter_table.convert_formula(formula);
XmlUtils::replace_all(odfFormula, L"EXTERNALREF", L"file://");//снятие экранирования
if (std::wstring::npos != odfFormula.find(L"["))
{
for (size_t i = 0; i < table_parts_.size(); i++)
@ -1338,7 +1371,7 @@ void ods_table_state::end_conditional_formats()
void ods_table_state::start_conditional_format(std::wstring ref)
{
office_element_ptr elm;
create_element(L"calcext", L"conditional-format",elm,context_);
create_element(L"calcext", L"conditional-format", elm, context_);
current_level_.back()->add_child_element(elm);
current_level_.push_back(elm);
@ -1363,13 +1396,13 @@ void ods_table_state::start_conditional_rule(int rule_type)
{
office_element_ptr elm;
if (rule_type == 3) create_element(L"calcext", L"color-scale",elm,context_);
else if (rule_type == 7)create_element(L"calcext", L"data-bar",elm,context_);
else if (rule_type ==10)create_element(L"calcext", L"icon-set",elm,context_);
else if (rule_type ==14)create_element(L"calcext", L"date-is",elm,context_);
if (rule_type == 3) create_element(L"calcext", L"color-scale", elm, context_);
else if (rule_type == 7)create_element(L"calcext", L"data-bar", elm ,context_);
else if (rule_type ==10)create_element(L"calcext", L"icon-set", elm, context_);
else if (rule_type ==14)create_element(L"calcext", L"date-is", elm, context_);
else
{
create_element(L"calcext", L"condition",elm,context_);
create_element(L"calcext", L"condition", elm, context_);
calcext_condition* condition = dynamic_cast<calcext_condition*> (elm.get());
if (condition)

View File

@ -163,11 +163,35 @@ void XlsxConverter::convert_sheets()
{
if (!ods_context) return;
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->m_pWorkbook;
OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->m_pWorkbook;
if (!Workbook) return;
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*> &mapWorksheets = xlsx_document->m_mapWorksheets;
xlsx_current_container = dynamic_cast<OOX::IFileContainer*>(Workbook);
if(Workbook->m_oExternalReferences.IsInit())
{
for (size_t i = 0; i < Workbook->m_oExternalReferences->m_arrItems.size(); i++)
{
OOX::Spreadsheet::CExternalReference *externalRef = dynamic_cast<OOX::Spreadsheet::CExternalReference*>(Workbook->m_oExternalReferences->m_arrItems[i]);
if((externalRef) && (externalRef->m_oRid.IsInit()))
{
smart_ptr<OOX::File> file = find_file_by_id(externalRef->m_oRid->GetValue());
smart_ptr<OOX::External> fileExternal = file.smart_dynamic_cast<OOX::External>();
if (fileExternal.IsInit())
{
ods_context->add_external_reference(fileExternal->Uri().GetPath());
}
else
{
smart_ptr<OOX::Spreadsheet::CExternalLink> externalLink = file.smart_dynamic_cast<OOX::Spreadsheet::CExternalLink>();
convert(externalLink.operator->());
}
}
}
}
if(Workbook->m_oBookViews.IsInit())
{
for (size_t i = 0; i < Workbook->m_oBookViews->m_arrItems.size(); i++)
@ -729,9 +753,32 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSi* oox_rtf_text)
ods_context->end_cell_text();
ods_context->current_table().set_cell_text( ods_context->text_context());
}
void XlsxConverter::convert(OOX::Spreadsheet::CExternalLink *oox_external_link)
{
if (!oox_external_link) return;
OOX::IFileContainer* old_container = xlsx_current_container;
xlsx_current_container = dynamic_cast<OOX::IFileContainer*>(oox_external_link);
if (oox_external_link->m_oExternalBook.IsInit())
{
if (oox_external_link->m_oExternalBook->m_oRid.IsInit())
{
smart_ptr<OOX::File> file = find_file_by_id(oox_external_link->m_oExternalBook->m_oRid->GetValue());
smart_ptr<OOX::External> fileExternal = file.smart_dynamic_cast<OOX::External>();
if (fileExternal.IsInit())
{
ods_context->add_external_reference(fileExternal->Uri().GetPath());
}
}
}
xlsx_current_container = old_container;
}
void XlsxConverter::convert(OOX::Spreadsheet::WritingElement *oox_unknown)
{
if (oox_unknown == NULL)return;
if (!oox_unknown)return;
switch(oox_unknown->getType())
{

View File

@ -93,6 +93,7 @@ namespace OOX
class CHeaderFooter;
class CSparklineGroups;
class CAltTextTable;
class CExternalLink;
}
}
@ -177,6 +178,7 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CPageSetup *oox_page);
void convert(OOX::Spreadsheet::CPageMargins *oox_page);
void convert(OOX::Spreadsheet::CWorkbookView *oox_book_views);
void convert(OOX::Spreadsheet::CExternalLink *oox_external_link);
void convert(OOX::Spreadsheet::CFont *font, odf_writer::style_text_properties *text_properties);
void convert(OOX::Spreadsheet::CBorder *border, odf_writer::style_table_cell_properties *cell_properties);

View File

@ -613,7 +613,12 @@ namespace NSBinPptxRW
AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_sizet& value)
{
if (value.IsInit())
WriteAttribute(strName, *value);
#ifdef __ANDROID__
WriteAttribute(strName, (int)(*value));
#else
WriteAttribute(strName, *value);
#endif
}
AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_double& value)
{

View File

@ -70,7 +70,7 @@ HRESULT convert_single(std::wstring srcFileName)
std::wstring dstPath;
bool bMacros = true;
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"2222", L"C:\\Windows\\Fonts", L"C:\\Windows\\Temp", NULL, bMacros);
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password", L"C:\\Windows\\Fonts", L"C:\\Windows\\Temp", NULL, bMacros);
if (bMacros)
{

View File

@ -708,7 +708,7 @@ NAMESPACE_END
// ***************** Miscellaneous ********************
// Nearly all Intel's and AMD's have SSE. Enable it independent of SSE ASM and intrinscs
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) && !defined(CRYPTOPP_DISABLE_ASM) && !(defined(_IOS) || defined(__ANDROID__))
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(_IOS) && !defined(__ANDROID__)
#define CRYPTOPP_BOOL_ALIGN16 1
#else
#define CRYPTOPP_BOOL_ALIGN16 0

View File

@ -223,6 +223,8 @@
8A404FCA2089FF7E00F2D5CF /* Base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A404FC92089FF7E00F2D5CF /* Base64.cpp */; };
8A404FCC2089FFE700F2D5CF /* Directory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A404FCB2089FFE700F2D5CF /* Directory.cpp */; };
8A404FCE208A001E00F2D5CF /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A404FCD208A001D00F2D5CF /* Path.cpp */; };
8AECC18F218C991900DEE19A /* App.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AECC18E218C991900DEE19A /* App.cpp */; };
8AECC191218C992900DEE19A /* Core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AECC190218C992900DEE19A /* Core.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -450,6 +452,8 @@
8A404FC92089FF7E00F2D5CF /* Base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Base64.cpp; path = ../../../../DesktopEditor/common/Base64.cpp; sourceTree = "<group>"; };
8A404FCB2089FFE700F2D5CF /* Directory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Directory.cpp; path = ../../../../DesktopEditor/common/Directory.cpp; sourceTree = "<group>"; };
8A404FCD208A001D00F2D5CF /* Path.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Path.cpp; path = ../../../../DesktopEditor/common/Path.cpp; sourceTree = "<group>"; };
8AECC18E218C991900DEE19A /* App.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = App.cpp; sourceTree = "<group>"; };
8AECC190218C992900DEE19A /* Core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Core.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -570,10 +574,12 @@
isa = PBXGroup;
children = (
17E6A01E1AC4262700F28F8B /* App.h */,
8AECC18E218C991900DEE19A /* App.cpp */,
17E6A01F1AC4262700F28F8B /* Bibliography.h */,
17E6A0201AC4262700F28F8B /* Comments.h */,
17E6A0211AC4262700F28F8B /* ContentTypes.h */,
17E6A0221AC4262700F28F8B /* Core.h */,
8AECC190218C992900DEE19A /* Core.cpp */,
17E6A0231AC4262700F28F8B /* CustomXml.h */,
17E6A0241AC4262700F28F8B /* Diagram */,
17E6A0261AC4262700F28F8B /* Document.h */,
@ -1173,6 +1179,7 @@
17C1FB9B1ACC4250006B99B3 /* Annotations.cpp in Sources */,
17C1FB9C1ACC4250006B99B3 /* FileFactory.cpp in Sources */,
17C1FB9D1ACC4250006B99B3 /* DateTime.cpp in Sources */,
8AECC191218C992900DEE19A /* Core.cpp in Sources */,
17C1FB9E1ACC4250006B99B3 /* Align.cpp in Sources */,
17C1FB9F1ACC4250006B99B3 /* Index.cpp in Sources */,
17C1FBA01ACC4250006B99B3 /* TxtFile.cpp in Sources */,
@ -1190,6 +1197,7 @@
17C1FBAC1ACC4250006B99B3 /* AlternateContent.cpp in Sources */,
17C1FBAD1ACC4250006B99B3 /* SmartTag.cpp in Sources */,
17C1FBAE1ACC4250006B99B3 /* oMath.cpp in Sources */,
8AECC18F218C991900DEE19A /* App.cpp in Sources */,
69E6AC892031AC3500795D9D /* SheetData.cpp in Sources */,
17C1FBAF1ACC4250006B99B3 /* ChartSerialize.cpp in Sources */,
17C1FBB11ACC4250006B99B3 /* Position.cpp in Sources */,

View File

@ -1,9 +1,31 @@
VERSION = $$cat(version.txt)
PRODUCT_VERSION = $$(PRODUCT_VERSION)
BUILD_NUMBER = $$(BUILD_NUMBER)
!isEmpty(PRODUCT_VERSION){
!isEmpty(BUILD_NUMBER){
VERSION = $$PRODUCT_VERSION.$$BUILD_NUMBER
}
}
DEFINES += INTVER=$$VERSION
QMAKE_TARGET_COMPANY = $$cat(copyright.txt)
QMAKE_TARGET_COPYRIGHT = $$cat(copyright.txt) (c) 2018
PUBLISHER_NAME = $$(PUBLISHER_NAME)
isEmpty(PUBLISHER_NAME){
PUBLISHER_NAME = $$cat(copyright.txt)
}
win32 {
CURRENT_YEAR = $$system("echo %Date:~6,4%")
}
!win32 {
CURRENT_YEAR = $$system(date +%Y)
}
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved
# CONFIGURATION
CONFIG(debug, debug|release) {

View File

@ -784,4 +784,6 @@
#define ASC_MENU_EVENT_TYPE_SET_PASSWORD 22001
#define ASC_MENU_EVENT_TYPE_SET_TRANSLATIONS 22002
#define ASC_MENU_EVENT_TYPE_ON_EDIT_TEXT 22003
#endif //_BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_

View File

@ -146,7 +146,7 @@ private:
#else
#include <stdlib.h>
#ifdef _IOS
#if defined(_IOS) || defined(__ANDROID__)
#include <new>
#endif

View File

@ -3,6 +3,8 @@ PRODUCT_VERSION ?= 0.0.0
BUILD_NUMBER ?= 0
PACKAGE_NAME := $(PRODUCT_NAME)
PUBLISHER_NAME ?= Ascensio System SIA
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
ARCHITECTURE := 64
@ -288,7 +290,12 @@ $(PDFREADER): $(PDFREADER_DEP)
$(PDFWRITER): $(PDFWRITER_DEP)
%.build/Makefile: %.pro
mkdir -p $(dir $@) && cd $(dir $@) && qmake -r $<
mkdir -p $(dir $@) && \
cd $(dir $@) && \
PUBLISHER_NAME="$(PUBLISHER_NAME)" \
PRODUCT_VERSION=$(PRODUCT_VERSION) \
BUILD_NUMBER=$(BUILD_NUMBER) \
qmake -r $<
$(ARCHIVE) :
$(AR) $@ $(ARTIFACTS)

View File

@ -586,7 +586,7 @@ bool ECMADecryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(verifierInputKey.ptr, verifierInputKey.size);
rc4Decryption.SetKey(verifierInputKey.ptr, cryptData.keySize);
}
//--------------------------------------------
_buf decryptedVerifierHashInputBytes;
@ -596,7 +596,7 @@ bool ECMADecryptor::SetPassword(std::wstring _password)
//--------------------------------------------
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(verifierHashKey.ptr, verifierHashKey.size);
rc4Decryption.SetKey(verifierHashKey.ptr, cryptData.keySize);
}
_buf decryptedVerifierHashBytes;
DecryptCipher(verifierHashKey, pSalt, pEncVerValue, decryptedVerifierHashBytes, cryptData.cipherAlgorithm);
@ -609,7 +609,7 @@ bool ECMADecryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(verifierKey.ptr, verifierKey.size);
rc4Decryption.SetKey(verifierKey.ptr, cryptData.keySize);
}
//--------------------------------------------
_buf decryptedVerifierHashInputBytes;
@ -673,7 +673,7 @@ void ECMADecryptor::Decrypt(char* data , const size_t size, const unsigned long
_buf hashKey = GenerateHashKey(pSalt, pPassword, cryptData.hashSize, cryptData.keySize, cryptData.spinCount, cryptData.hashAlgorithm, block_index);
rc4Decryption.SetKey(hashKey.ptr, hashKey.size);
rc4Decryption.SetKey(hashKey.ptr, cryptData.keySize);
}
const long offset = nCurrPos % block_size;
@ -764,7 +764,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*&
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(agileKey.ptr, agileKey.size);
rc4Decryption.SetKey(agileKey.ptr, cryptData.keySize);
}
_buf pDecryptedKey;
DecryptCipher( agileKey, pSalt, pKeyValue, pDecryptedKey, cryptData.cipherAlgorithm);
@ -775,7 +775,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*&
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(pDecryptedKey.ptr, pDecryptedKey.size);
rc4Decryption.SetKey(pDecryptedKey.ptr, cryptData.keySize);
}
while (pos < size)
{
@ -801,7 +801,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*&
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(hashKey.ptr, hashKey.size);
rc4Decryption.SetKey(hashKey.ptr, cryptData.keySize);
}
_buf pInp(data_inp, size, false);
@ -860,7 +860,7 @@ void ECMAEncryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(agileKey.ptr, agileKey.size);
rc4Encryption.SetKey(agileKey.ptr, cryptData.keySize);
}
_buf pKeyValue;
EncryptCipher( agileKey, pSalt, pDecryptedKey, pKeyValue, cryptData.cipherAlgorithm);
@ -871,7 +871,7 @@ void ECMAEncryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(verifierInputKey.ptr, verifierInputKey.size);
rc4Encryption.SetKey(verifierInputKey.ptr, cryptData.keySize);
}
_buf pEncVerInput;
EncryptCipher( verifierInputKey, pSalt, decryptedVerifierHashInputBytes, pEncVerInput, cryptData.cipherAlgorithm);
@ -882,7 +882,7 @@ void ECMAEncryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(verifierHashKey.ptr, verifierHashKey.size);
rc4Encryption.SetKey(verifierHashKey.ptr, cryptData.keySize);
}
else if (decryptedVerifierHashBytes.size % PADDING_SIZE != 0)
{
@ -903,7 +903,7 @@ void ECMAEncryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(verifierKey.ptr, verifierKey.size);
rc4Encryption.SetKey(verifierKey.ptr, cryptData.keySize);
}
_buf decryptedVerInput(seed_verify.data(), seed_verify.size());
@ -955,7 +955,7 @@ void ECMAEncryptor::UpdateDataIntegrity(unsigned char* data, int size)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(agileKey.ptr, agileKey.size);
rc4Encryption.SetKey(agileKey.ptr, cryptData.keySize);
}
_buf secretKey;
@ -981,7 +981,7 @@ void ECMAEncryptor::UpdateDataIntegrity(unsigned char* data, int size)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(secretKey.ptr, secretKey.size);
rc4Encryption.SetKey(secretKey.ptr, cryptData.keySize);
}
if (pSaltHmac.size % PADDING_SIZE != 0)
{
@ -1033,14 +1033,14 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(agileKey.ptr, agileKey.size);
rc4Decryption.SetKey(agileKey.ptr, cryptData.keySize);
}
_buf pDecryptedKey;
DecryptCipher( agileKey, pSalt, pKeyValue, pDecryptedKey, cryptData.cipherAlgorithm);
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Encryption.SetKey(pDecryptedKey.ptr, agileKey.size);
rc4Encryption.SetKey(pDecryptedKey.ptr, cryptData.keySize);
}
//-------------------------------------------------------------------------------------------------
_buf iv(cryptData.blockSize, true);
@ -1094,8 +1094,8 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{
rc4Decryption.SetKey(hashKey.ptr, hashKey.size);
rc4Encryption.SetKey(hashKey.ptr, hashKey.size);
rc4Decryption.SetKey(hashKey.ptr, cryptData.keySize);
rc4Encryption.SetKey(hashKey.ptr, cryptData.keySize);
}
_buf pInp(data_inp, size, false);

View File

@ -108,7 +108,7 @@ namespace PdfWriter
if (eType <= InfoModaDate)
return;
Add(sName, new CStringObject(sValue));
Add(sName, new CStringObject(sValue, true));
}
const char* CInfoDict::GetInfo(EInfoType eType)
{
@ -216,4 +216,4 @@ namespace PdfWriter
{
return m_oDate;
}
}
}

View File

@ -137,10 +137,11 @@ namespace PdfWriter
//----------------------------------------------------------------------------------------
// CStringObject
//----------------------------------------------------------------------------------------
CStringObject::CStringObject(const char* sValue)
CStringObject::CStringObject(const char* sValue, bool isUTF16)
{
m_pValue = NULL;
m_unLen = 0;
m_bUTF16 = isUTF16;
Set(sValue);
}
CStringObject::~CStringObject()

View File

@ -232,7 +232,7 @@ namespace PdfWriter
class CStringObject : public CObjectBase
{
public:
CStringObject(const char* sValue);
CStringObject(const char* sValue, bool isUTF16 = false);
virtual ~CStringObject();
void Set(const char* sValue);
const BYTE* GetString() const
@ -246,11 +246,16 @@ namespace PdfWriter
EObjectType GetType() const
{
return object_type_STRING;
}
}
bool IsUTF16() const
{
return m_bUTF16;
}
private:
BYTE* m_pValue;
unsigned int m_unLen;
bool m_bUTF16;
};
class CBinaryObject : public CObjectBase
{

View File

@ -38,6 +38,7 @@
#include <sstream>
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../UnicodeConverter/UnicodeConverter.h"
#define DEFLATE_BUF_SIZ ((int)(STREAM_BUF_SIZ * 1.1) + 13)
@ -281,7 +282,7 @@ namespace PdfWriter
Write((BYTE*)sTmpChar, StrLen(sTmpChar, -1));
}
void CStream::WriteEscapeText(const BYTE* sText, unsigned int unLen)
void CStream::WriteEscapeText(const BYTE* sText, unsigned int unLen, bool isUTF16)
{
if (!unLen || !sText)
return;
@ -294,6 +295,21 @@ namespace PdfWriter
unsigned long nRet = 0;
sBuf[nIndex++] = '(';
if (isUTF16)
{
std::string sUtf8((char*)sText, unLen);
std::wstring sUnicode = UTF8_TO_U(sUtf8);
NSUnicodeConverter::CUnicodeConverter oConverter;
std::string sUtf16BE = oConverter.fromUnicode(sUnicode, "UTF-16BE");
unLen = (unsigned int)sUtf16BE.length();
sTxt = (BYTE*)sUtf16BE.c_str();
sBuf[nIndex++] = 0xFE;
sBuf[nIndex++] = 0xFF;
}
for (int nCounter = 0; nCounter < unLen; nCounter++)
{
BYTE nChar = (BYTE)*sTxt++;
@ -324,7 +340,7 @@ namespace PdfWriter
sBuf[nIndex++] = ')';
Write((BYTE*)sBuf, nIndex);
}
}
void CStream::WriteBinary(const BYTE* pData, unsigned int unLen, CEncrypt* pEncrypt)
{
char sBuf[TEXT_DEFAULT_LEN];
@ -508,8 +524,8 @@ namespace PdfWriter
WriteChar('>');
}
else
{
WriteEscapeText(pString->GetString(), pString->GetLength());
{
WriteEscapeText(pString->GetString(), pString->GetLength(), pString->IsUTF16());
}
}
void CStream::Write(CBinaryObject* pBinary, CEncrypt* pEncrypt)

View File

@ -116,7 +116,7 @@ namespace PdfWriter
void WriteReal (float fValue);
void WriteReal (double dValue);
void WriteEscapeName(const char* sValue);
void WriteEscapeText(const BYTE* sText, unsigned int unLen);
void WriteEscapeText(const BYTE* sText, unsigned int unLen, bool isUTF16 = false);
void WriteBinary(const BYTE* pData, unsigned int unLen, CEncrypt* pEncrypt);
void WriteStream(CStream* pStream, unsigned int unFilter, CEncrypt* pEncrypt);

View File

@ -1,6 +1,6 @@
#ifndef X2T_VERSION_H
#define X2T_VERSION_H
#define X2T_VERSION "2.4.547.0"
#define X2T_VERSION "2.4.554.0"
#endif

View File

@ -9,9 +9,11 @@ keystore-release.properties
/build
/captures
/gradle
/android-ndk*
/extra-builds/native/libs
/extra-builds/native/toolchain
/extra-builds/native/src/iconv
.zip
.gradle
.idea
.DS_Store

View File

@ -1,3 +1,11 @@
# README #
New android Documents app...
Android x2t app example.
For run app you must:
1) Download all 3party libraries from folder ../core/Common/3dParty
2) Once! Run gradle task preBuildTask().
That task download last NDK 17c with deprecated GCC.
Build all 3d party dependencies with that NDK
3) Build app

View File

@ -10,11 +10,14 @@ apply from: "$rootProject.projectDir/extra-builds/gradle/common.gradle"
// Common native libs path
def TOOLCHAIN_VERSION = 4.9
def HOST_PLATFORM = "linux-x86_64"
def PATH_NDK = getBackSlash(android.ndkDirectory.path)
def NDK_VERSION = "android-ndk-r17c"
def HOST_PLATFORM = getHostName()
def PATH_NDK = "${project.rootDir.path}/${NDK_VERSION}"
def PATH_TOOLCHAIN = "$PATH_NDK/toolchains/\$1/prebuilt/$HOST_PLATFORM/bin"
def PATH_STANDALONE_SCRIPT = "$PATH_NDK/build/tools"
def PATH_3PARTY = "$project.ext.SRC_CORE/Common/3dParty"
def NDK_URL = "https://dl.google.com/android/repository/${NDK_VERSION}-${HOST_PLATFORM}.zip"
def NDK_DOWNLOAD = "${PATH_NDK}.zip"
// Keys for constant
def MASK_LIB = 'lib*.*'
@ -302,6 +305,34 @@ task unpackingLibs(type: Copy) {
}
}
/*
* Download NDK ver.17c with deprecated support of GCC
* */
task downloadNdk() {
doLast {
if (!file(PATH_NDK).exists()) {
if (!file(NDK_DOWNLOAD).exists()) {
download {
println "\nDownload NDK..."
src NDK_URL
dest NDK_DOWNLOAD
overwrite false
onlyIfModified true
quiet false
}
}
copy {
println "\nUnpack NDK..."
eachFile { println it.file }
from zipTree(NDK_DOWNLOAD)
into project.rootDir.path
}
}
}
}
/*
* https://wiki.openssl.org/index.php/Android
* Success for: OpenSSL 1.1.1-pre10-dev
@ -353,7 +384,7 @@ task buildOpenSsl() {
environment "PATH", PATH
commandLine "./Configure", "--prefix=$OPENSSL_LIBS_INSTALL", "--openssldir=$OPENSSL_LIBS_INSTALL", \
"android-" + value.TCN, "-D__ANDROID_API__=$project.ext.SDK_MIN", \
"no-shared", "no-ssl2", "no-ssl3", "no-comp", "no-hw", "no-engine"
"no-shared", "no-ssl3", "no-comp", "no-hw", "no-engine"
}
// Clean build files
@ -878,15 +909,13 @@ task buildBoost() {
/*
* Add here pre build tasks
* */
task build3dPArty() {
buildOpenSsl.execute()
buildCurl.execute()
buildIconv.execute()
buildIcu.execute()
buildBoost.execute()
task preBuildTask() {
doLast {
downloadNdk.execute()
buildOpenSsl.execute()
buildCurl.execute()
buildIconv.execute()
buildIcu.execute()
buildBoost.execute()
}
}
/*
* Add task for run before build
* */
preBuild.dependsOn build3dPArty

View File

@ -9,7 +9,6 @@ set(CMAKE_VERBOSE_MAKEFILE on)
# Set global definition
add_definitions(
-D__ANDROID__
-D_LINUX
)
# Add checks arguments here

View File

@ -162,7 +162,8 @@ target_include_directories(${LIB_NAME_CRYPTOPP} PUBLIC ${CRYPTOPP_DIR})
# Set target definition
target_compile_definitions(${LIB_NAME_CRYPTOPP}
PRIVATE
PUBLIC
_LINUX
UNICODE
CRYPTOPPLIB_LIBRARY
CRYPTOPP_DISABLE_ASM

View File

@ -12,39 +12,39 @@ if (NOT DEFINED LIB_NAME_OFFICE_UTILS)
message(FATAL_ERROR "You must set library name in \"LIB_NAME_OFFICE_UTILS\"!")
endif()
# Zlib name
set(ZLIB_NAME zlib-1.2.11)
# Library source .h .cpp
file(GLOB OFFICE_UTILS_CPP
${OFFICE_UTILS_DIR}src/*.cpp
${OFFICE_UTILS_DIR}src/zlib-1.2.3/*.c
${OFFICE_UTILS_DIR}src/zlib-1.2.3/contrib/minizip/*.c
${OFFICE_UTILS_DIR}src/${ZLIB_NAME}/*.c
${OFFICE_UTILS_DIR}src/${ZLIB_NAME}/contrib/minizip/*.c
)
# Exclude sources
list(REMOVE_ITEM OFFICE_UTILS_CPP
${OFFICE_UTILS_DIR}src/zlib-1.2.3/contrib/minizip/iowin32.c
${OFFICE_UTILS_DIR}src/${ZLIB_NAME}/contrib/minizip/iowin32.c
)
# Set targer as static library
add_library(${LIB_NAME_OFFICE_UTILS} STATIC ${OFFICE_UTILS_CPP})
# Add dependency library
#target_link_libraries(${LIB_NAME_OFFICE_UTILS}
# PRIVATE
# ${LIB_NAME_EDITOR_COMMON}
#)
# Add include files .h
target_include_directories(${LIB_NAME_OFFICE_UTILS}
PUBLIC
${OFFICE_UTILS_DIR}
${OFFICE_UTILS_DIR}zlib-1.2.3/
${OFFICE_UTILS_DIR}${ZLIB_NAME}/
PRIVATE
${OFFICE_UTILS_DIR}zlib-1.2.3/contrib/minizip/
${OFFICE_UTILS_DIR}${ZLIB_NAME}/contrib/minizip/
)
# Set target definition
target_compile_definitions(${LIB_NAME_OFFICE_UTILS}
PRIVATE
_LINUX
USE_FILE32API
NOCRYPT
NOUNCRYPT
BUILD_ZLIB_AS_SOURCES
)

View File

@ -102,4 +102,10 @@ target_compile_options(${LIB_NAME_FONT_ENGINE}
PUBLIC
-Wno-register
-Wno-c++11-narrowing
)
# Set target definition
target_compile_definitions(${LIB_NAME_FONT_ENGINE}
PRIVATE
_LINUX
)

View File

@ -40,6 +40,7 @@ target_include_directories(${LIB_NAME_PDF_WRITER}
# Set target definition
target_compile_definitions(${LIB_NAME_PDF_WRITER}
PRIVATE
_LINUX
PDFWRITER_USE_DYNAMIC_LIBRARY
)

View File

@ -102,6 +102,37 @@ def getDirNameExt(String path) {
return countFolders == 1? nameFolder : ''
}
def getHostNameExt() {
final String value = System.getProperty("os.name").toLowerCase();
println "System: ${value}"
if (value.contains("linux")) {
return ("linux");
} else if (value.contains("mac os x") || value.contains("darwin") || value.contains("osx")) {
return ("darwin");
} else if (value.contains("windows")) {
return ("windows");
}
throw new GradleException("UNKNOWN SYSTEM FOR ANDROID NDK: ${value}!")
}
def getHostArchExt() {
final String value = System.getProperty("os.arch");
println "Architecture: ${value}"
if ("x86" == value) {
return value
} else if ("amd64" == value || "x86_64" == value) {
return "x86_64"
}
throw new GradleException("UNKNOWN ARCHITECTRE FOR ANDROID NDK: ${value}!")
}
def getHostNameFullExt() {
return "${getHostNameExt()}-${getHostArchExt()}"
}
/*
* Add methods/values here for export
@ -141,5 +172,6 @@ ext {
isFolderNotEmpty = this.&isFolderNotEmptyCheck
getBackSlash = this.&getBackSlashExt
getDirName = this.&getDirNameExt
getHostName = this.&getHostNameFullExt
}