Compare commits

..

4 Commits

8 changed files with 66 additions and 12 deletions

View File

@ -33,6 +33,7 @@
#define DOC_BUILDER_ADDON_PRIVATE
#include <string>
#include "../docbuilder.h"
namespace NSDoctRenderer
{
@ -46,11 +47,11 @@ namespace NSDoctRenderer
m_sWorkDirectory = sWorkDir;
}
public:
std::wstring GetX2tSaveAddon()
std::wstring GetX2tSaveAddon(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
{
return L"";
}
int GetX2tPreSaveError()
int GetX2tPreSaveError(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
{
return 0;
}

View File

@ -33,6 +33,7 @@
#include "./../common_deploy.h"
#include "../docbuilder.h"
#include "../../common/File.h"
#include "../../common/SystemUtils.h"
#ifdef LINUX
#include "../../../DesktopEditor/common/File.h"
@ -78,6 +79,13 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
}
}
bool CheckLicense(const std::wstring& sSrc, const std::wstring& sDst)
{
NSFile::CFileBinary::Remove(sDst);
NSFile::CFileBinary::Copy(sSrc, sDst);
return NSFile::CFileBinary::Exists(sDst);
}
#ifdef WIN32
int wmain(int argc, wchar_t *argv[])
#else
@ -89,6 +97,7 @@ int main(int argc, char *argv[])
bool bIsHelp = false;
bool bIsFonts = false;
bool bIsLicense = false;
for (int i = 0; i < argc; ++i)
{
#ifdef WIN32
@ -121,6 +130,33 @@ int main(int argc, char *argv[])
{
bIsFonts = true;
}
else if (sParam == "-register")
{
bIsLicense = true;
}
else
{
if (bIsLicense)
{
std::wstring sLicensePathSrc = UTF8_TO_U(sParam);
if (!NSFile::CFileBinary::Exists(sLicensePathSrc))
return 1;
std::wstring sLicensePath = NSSystemUtils::GetEnvVariable(L"ONLYOFFICE_BUILDER_LICENSE");
if (CheckLicense(sLicensePathSrc, sLicensePath))
return 0;
sLicensePath = NSFile::GetProcessDirectory() + L"/license.xml";
if (CheckLicense(sLicensePathSrc, sLicensePath))
return 0;
sLicensePath = NSSystemUtils::GetAppDataDir() + L"/docbuilder/license.xml";
if (CheckLicense(sLicensePathSrc, sLicensePath))
return 0;
return 1;
}
}
}
if (bIsFonts)

View File

@ -612,4 +612,10 @@ builder_path = os.path.dirname(os.path.realpath(__file__))
_loadLibrary(builder_path)
CDocBuilder.Initialize(builder_path)
def registerLibrary(license_path):
docbuilder_bin = os.path.dirname(os.path.realpath(__file__)) + os.pathsep + "docbuilder"
if ("windows" == platform.system().lower()):
docbuilder_bin += ".exe"
return subprocess.call([docbuilder_bin, license_path], stderr=subprocess.STDOUT, shell=True)
atexit.register(CDocBuilder.Dispose)

View File

@ -1003,7 +1003,7 @@ namespace NSDoctRenderer
CDocBuilderAddon oSaveAddon(m_sX2tPath);
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
int nPreSaveError = oSaveAddon.GetX2tPreSaveError(m_pParent, m_nFileType);
if (0 != nPreSaveError)
return nPreSaveError;
@ -1090,7 +1090,7 @@ namespace NSDoctRenderer
if (!sOptions.empty())
oBuilder.WriteString(UTF8_TO_U(sOptions));
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon(m_pParent, m_nFileType));
oBuilder.WriteString(L"</TaskQueueDataConvert>");

View File

@ -693,6 +693,13 @@ namespace NSShaper
g_userfeatures_init = true;
}
// Turn on ligatures on arabic script
if (nScript == HB_SCRIPT_ARABIC ||
nScript == HB_SCRIPT_SYRIAC)
{
nFeatures |= 1;
}
// font
hb_font_t* pFont;
if (NULL == font)

View File

@ -594,6 +594,13 @@ WASM_EXPORT unsigned char* ASC_HB_ShapeText(FT_Face pFace, hb_font_t* pFont, cha
g_userfeatures_init = true;
}
// Turn on ligatures on arabic script
if (nScript == HB_SCRIPT_ARABIC ||
nScript == HB_SCRIPT_SYRIAC)
{
nFeatures |= 1;
}
// font
if (NULL == pFont)
{

View File

@ -963,10 +963,7 @@ bool CPdfEditor::EditPage(int nPageIndex, bool bSet, bool bActualPos)
{
Object oRes;
char* chKey2 = oTemp.dictGetKey(nIndex);
if (strcmp("Font", chKey2) == 0 || strcmp("ExtGState", chKey2) == 0 || strcmp("XObject", chKey2) == 0 || strcmp("Shading", chKey2) == 0 || strcmp("Pattern", chKey2) == 0)
oTemp.dictGetVal(nIndex, &oRes);
else
oTemp.dictGetValNF(nIndex, &oRes);
oTemp.dictGetVal(nIndex, &oRes);
DictToCDictObject(&oRes, pDict, false, chKey2);
oRes.free();
}

View File

@ -372,7 +372,7 @@ TEST_F(CPdfFileTest, EditPdf)
TEST_F(CPdfFileTest, EditPdfFromBase64)
{
//GTEST_SKIP();
GTEST_SKIP();
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NSFonts::NSApplicationFontStream::CreateDefaultGlobalMemoryStorage());
@ -417,14 +417,14 @@ TEST_F(CPdfFileTest, EditPdfFromBase64)
TEST_F(CPdfFileTest, EditPdfFromBin)
{
GTEST_SKIP();
// GTEST_SKIP();
LoadFromFile();
ASSERT_TRUE(pdfFile->EditPdf(wsDstFile));
// чтение бинарника
NSFile::CFileBinary oFile;
ASSERT_TRUE(oFile.OpenFile(NSFile::GetProcessDirectory() + L"/changes0.json"));
ASSERT_TRUE(oFile.OpenFile(NSFile::GetProcessDirectory() + L"/changes.bin"));
DWORD dwFileSize = oFile.GetFileSize();
BYTE* pFileContent = new BYTE[dwFileSize];
@ -440,7 +440,7 @@ TEST_F(CPdfFileTest, EditPdfFromBin)
CConvertFromBinParams* pParams = new CConvertFromBinParams();
pParams->m_sMediaDirectory = NSFile::GetProcessDirectory();
pdfFile->AddToPdfFromBinary(pFileContent, dwReaded, pParams);
pdfFile->AddToPdfFromBinary(pFileContent + 4, dwReaded - 4, pParams);
RELEASEOBJECT(pParams);
RELEASEARRAYOBJECTS(pFileContent);