mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ace3e2e80 | |||
| 1baf789bb5 | |||
| c239040756 | |||
| b89d16691a | |||
| 9788d38a69 | |||
| bf6d4b00e3 | |||
| 4a452ee47f | |||
| 3a46d8a909 | |||
| 8539dc168b | |||
| d651d5166b | |||
| 699acd0516 | |||
| 5e9e15be57 | |||
| 2eec32df98 | |||
| 77ea7fd3df | |||
| cb40323b31 | |||
| 85817c68c1 | |||
| 284d2730e2 | |||
| 075d6c849b | |||
| a0ff455786 | |||
| 9fc7aa5bca | |||
| 80e2c75a54 |
@ -68,6 +68,9 @@ public:
|
||||
inline void close() override {
|
||||
std::fstream::close();
|
||||
}
|
||||
inline bool isError() override {
|
||||
return (std::fstream::bad() || std::fstream::fail());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ namespace CFCPP
|
||||
virtual void write (const char* buffer, _INT64 len) = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual bool isError() = 0;
|
||||
};
|
||||
|
||||
using Stream = std::shared_ptr<IStream>;
|
||||
|
||||
@ -67,9 +67,9 @@ std::shared_ptr<CFStorage> CompoundFile::RootStorage()
|
||||
{
|
||||
return _impl->RootStorage();
|
||||
}
|
||||
void CompoundFile::Save(std::wstring wFileName)
|
||||
bool CompoundFile::Save(std::wstring wFileName)
|
||||
{
|
||||
_impl->Save(wFileName);
|
||||
return _impl->Save(wFileName);
|
||||
}
|
||||
void CompoundFile::Save(Stream stream)
|
||||
{
|
||||
@ -316,15 +316,23 @@ void CompoundFile_impl::Load(Stream stream)
|
||||
}
|
||||
}
|
||||
|
||||
void CompoundFile_impl::Save(std::wstring wFileName)
|
||||
{
|
||||
if (isDisposed)
|
||||
throw CFException("Compound File closed: cannot save data");
|
||||
bool CompoundFile_impl::Save(std::wstring wFileName)
|
||||
{
|
||||
if (isDisposed)
|
||||
{
|
||||
//throw CFException("Compound File closed: cannot save data");
|
||||
return false;
|
||||
}
|
||||
|
||||
Stream file = OpenFileStream(wFileName, true, true);
|
||||
file->seek(0, std::ios::beg);
|
||||
|
||||
try
|
||||
if (!file) return false;
|
||||
if (file->isError()) return false;
|
||||
|
||||
file->seek(0, std::ios::beg);
|
||||
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
Save(file);
|
||||
|
||||
@ -343,7 +351,9 @@ void CompoundFile_impl::Save(std::wstring wFileName)
|
||||
file->close();
|
||||
|
||||
throw CFException("Error saving file [" + fileName + "]", ex);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public:
|
||||
|
||||
std::shared_ptr<CFStorage> RootStorage();
|
||||
|
||||
void Save(std::wstring wFileName);
|
||||
bool Save(std::wstring wFileName);
|
||||
void Save(Stream stream);
|
||||
|
||||
void Commit(bool releaseMemory = false);
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
// Main methods
|
||||
std::shared_ptr<CFStorage> RootStorage();
|
||||
|
||||
void Save(std::wstring wFileName);
|
||||
bool Save(std::wstring wFileName);
|
||||
void Save(Stream stream);
|
||||
|
||||
void Commit(bool releaseMemory = false);
|
||||
|
||||
@ -123,6 +123,14 @@ void StreamView::close()
|
||||
if (std::dynamic_pointer_cast<std::iostream>(stream) != nullptr)
|
||||
stream->close();
|
||||
}
|
||||
bool StreamView::isError()
|
||||
{
|
||||
if (std::dynamic_pointer_cast<std::iostream>(stream) == nullptr) return true;
|
||||
if ((std::dynamic_pointer_cast<std::iostream>(stream))->bad()) return true;
|
||||
if ((std::dynamic_pointer_cast<std::iostream>(stream))->fail()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_INT64 StreamView::read(char *buffer, _INT64 len)
|
||||
{
|
||||
|
||||
@ -46,14 +46,13 @@ public:
|
||||
StreamView(const SVector<Sector> §orChain, _INT32 sectorSize, _INT64 length,
|
||||
SList<Sector> &availableSectors, Stream stream, bool isFatStream = false);
|
||||
|
||||
|
||||
_INT64 tell() override;
|
||||
_INT64 seek(_INT64 offset, std::ios_base::seekdir mode = std::ios::beg) override;
|
||||
_INT64 read(char *buffer, _INT64 count) override;
|
||||
void write(const char *buffer, _INT64 count) override;
|
||||
void flush() override {}
|
||||
void close() override;
|
||||
|
||||
bool isError() override;
|
||||
|
||||
_INT64 getPosition() const;
|
||||
void SetLength(_INT64 value);
|
||||
|
||||
@ -60,11 +60,11 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Ascensio System SIA 2022"
|
||||
VALUE "CompanyName", "Ascensio System SIA 2023"
|
||||
VALUE "FileDescription", "ONLYOFFICE docbuilder ActiveX DLL"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "InternalName", "docbuilder.com.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2022. All rights reserved."
|
||||
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2023. All rights reserved."
|
||||
VALUE "OriginalFilename", "docbuilder.com.dll"
|
||||
VALUE "ProductName", "docbuilder.com"
|
||||
VALUE "ProductVersion", "1.0.0.1"
|
||||
|
||||
@ -71,7 +71,7 @@ BEGIN
|
||||
VALUE "FileDescription", "Document Builder .NET"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "InternalName", "docbuilder.net"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2023. All rights reserved."
|
||||
VALUE "OriginalFilename", "docbuilder.net"
|
||||
VALUE "ProductName", "docbuilder.net"
|
||||
VALUE "ProductVersion", "1.0.0.1"
|
||||
|
||||
@ -128,6 +128,69 @@ std::wstring CV8RealTimeWorker::GetJSVariable(std::wstring sParam)
|
||||
return L"jsValue(" + sParam + L")";
|
||||
}
|
||||
|
||||
std::string GetCorrectArgument(const std::string& sInput)
|
||||
{
|
||||
if (sInput.empty())
|
||||
return "{}";
|
||||
|
||||
const char* input = sInput.c_str();
|
||||
std::string::size_type len = sInput.length();
|
||||
|
||||
std::string sResult;
|
||||
sResult.reserve(len);
|
||||
|
||||
bool bIsInsideString = false;
|
||||
int nQouteMarkCounter = 0;
|
||||
for (std::string::size_type pos = 0; pos < len; ++pos)
|
||||
{
|
||||
char cur = input[pos];
|
||||
if (bIsInsideString)
|
||||
{
|
||||
if ('\\' == cur)
|
||||
++nQouteMarkCounter;
|
||||
else if ('\"' == cur)
|
||||
{
|
||||
if (nQouteMarkCounter & 1)
|
||||
{
|
||||
// внутренняя кавычка - ничего не делаем
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsInsideString = false;
|
||||
nQouteMarkCounter = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nQouteMarkCounter = 0;
|
||||
}
|
||||
sResult += cur;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cur)
|
||||
{
|
||||
case '\\':
|
||||
{
|
||||
while (pos < (len - 1) && isalpha(input[pos + 1]))
|
||||
++pos;
|
||||
break;
|
||||
}
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
break;
|
||||
case '\"':
|
||||
bIsInsideString = true;
|
||||
default:
|
||||
sResult += cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
@ -145,9 +208,8 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
|
||||
if (true)
|
||||
{
|
||||
std::string sArg = m_sUtf8ArgumentJSON;
|
||||
if (sArg.empty())
|
||||
sArg = "{}";
|
||||
std::string sArg = GetCorrectArgument(m_sUtf8ArgumentJSON);
|
||||
|
||||
NSStringUtils::string_replaceA(sArg, "\\", "\\\\");
|
||||
NSStringUtils::string_replaceA(sArg, "\"", "\\\"");
|
||||
std::string sArgument = "var Argument = JSON.parse(\"" + sArg + "\");";
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
call hg clone https://hg.mozilla.org/projects/nspr
|
||||
call hg clone https://hg.mozilla.org/projects/nss
|
||||
|
||||
cd nss
|
||||
export USE_64=1
|
||||
make nss_build_all
|
||||
|
||||
git clone https://github.com/openssl/openssl.git openssl
|
||||
cd openssl
|
||||
perl ./Configure linux-64
|
||||
./config
|
||||
make
|
||||
|
||||
#call git clone -b master https://github.com/lsh123/xmlsec.git
|
||||
#download from http://www.aleksey.com/xmlsec/download/xmlsec1-1.2.23.tar.gz
|
||||
# get from our git repository
|
||||
@ -1,312 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-10-10T14:24:04
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= core gui
|
||||
|
||||
TARGET = libxmlsec
|
||||
TEMPLATE = lib
|
||||
QMAKE_CXXFLAGS += -Wall -g
|
||||
|
||||
#CONFIG += shared
|
||||
#CONFIG += plugin
|
||||
CONFIG += staticlib
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD_ROOT_DIR/xmlsec/include \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/build/qt
|
||||
|
||||
DEFINES += \
|
||||
LIBXML_READER_ENABLED \
|
||||
LIBXML_PUSH_ENABLED \
|
||||
LIBXML_HTML_ENABLED \
|
||||
LIBXML_XPATH_ENABLED \
|
||||
LIBXML_OUTPUT_ENABLED \
|
||||
LIBXML_C14N_ENABLED \
|
||||
LIBXML_SAX1_ENABLED \
|
||||
LIBXML_TREE_ENABLED \
|
||||
LIBXML_XPTR_ENABLED \
|
||||
IN_LIBXML \
|
||||
LIBXML_STATIC
|
||||
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/xml/build/qt/libxml2_src.pri)
|
||||
|
||||
DEFINES += PACKAGE=\\\"xmlsec1\\\"
|
||||
DEFINES += VERSION=\\\"1.2.23\\\"
|
||||
DEFINES += XMLSEC_DEFAULT_CRYPTO=\\\"openssl\\\"
|
||||
|
||||
DEFINES += \
|
||||
IN_XMLSEC \
|
||||
XMLSEC_STATIC
|
||||
|
||||
core_linux {
|
||||
#CONFIG += use_gcrypt
|
||||
#CONFIG += use_gnutls
|
||||
#CONFIG += use_mscrypto
|
||||
#CONFIG += use_nss
|
||||
CONFIG += use_openssl
|
||||
#CONFIG += use_skeleton
|
||||
#CONFIG += use_xslt
|
||||
}
|
||||
|
||||
core_windows {
|
||||
CONFIG += use_mscrypto
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/app.h \
|
||||
xmlsec/include/xmlsec/base64.h \
|
||||
xmlsec/include/xmlsec/bn.h \
|
||||
xmlsec/include/xmlsec/buffer.h \
|
||||
xmlsec/include/xmlsec/crypto.h \
|
||||
xmlsec/include/xmlsec/dl.h \
|
||||
xmlsec/include/xmlsec/errors.h \
|
||||
xmlsec/include/xmlsec/exports.h \
|
||||
xmlsec/include/xmlsec/io.h \
|
||||
xmlsec/include/xmlsec/keyinfo.h \
|
||||
xmlsec/include/xmlsec/keys.h \
|
||||
xmlsec/include/xmlsec/keysdata.h \
|
||||
xmlsec/include/xmlsec/keysmngr.h \
|
||||
xmlsec/include/xmlsec/list.h \
|
||||
xmlsec/include/xmlsec/membuf.h \
|
||||
xmlsec/include/xmlsec/nodeset.h \
|
||||
xmlsec/include/xmlsec/parser.h \
|
||||
xmlsec/include/xmlsec/private.h \
|
||||
xmlsec/include/xmlsec/soap.h \
|
||||
xmlsec/include/xmlsec/strings.h \
|
||||
xmlsec/include/xmlsec/templates.h \
|
||||
xmlsec/include/xmlsec/transforms.h \
|
||||
xmlsec/include/xmlsec/version.h \
|
||||
xmlsec/include/xmlsec/version.h.in \
|
||||
xmlsec/include/xmlsec/x509.h \
|
||||
xmlsec/include/xmlsec/xmldsig.h \
|
||||
xmlsec/include/xmlsec/xmlenc.h \
|
||||
xmlsec/include/xmlsec/xmlsec.h \
|
||||
xmlsec/include/xmlsec/xmltree.h \
|
||||
xmlsec/src/globals.h \
|
||||
xmlsec/src/kw_aes_des.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/app.c \
|
||||
xmlsec/src/base64.c \
|
||||
xmlsec/src/bn.c \
|
||||
xmlsec/src/buffer.c \
|
||||
xmlsec/src/c14n.c \
|
||||
xmlsec/src/dl.c \
|
||||
xmlsec/src/enveloped.c \
|
||||
xmlsec/src/errors.c \
|
||||
xmlsec/src/io.c \
|
||||
xmlsec/src/keyinfo.c \
|
||||
xmlsec/src/keys.c \
|
||||
xmlsec/src/keysdata.c \
|
||||
xmlsec/src/keysmngr.c \
|
||||
xmlsec/src/kw_aes_des.c \
|
||||
xmlsec/src/list.c \
|
||||
xmlsec/src/membuf.c \
|
||||
xmlsec/src/nodeset.c \
|
||||
xmlsec/src/parser.c \
|
||||
xmlsec/src/relationship.c \
|
||||
xmlsec/src/soap.c \
|
||||
xmlsec/src/strings.c \
|
||||
xmlsec/src/templates.c \
|
||||
xmlsec/src/transforms.c \
|
||||
xmlsec/src/x509.c \
|
||||
xmlsec/src/xmldsig.c \
|
||||
xmlsec/src/xmlenc.c \
|
||||
xmlsec/src/xmlsec.c \
|
||||
xmlsec/src/xmltree.c \
|
||||
xmlsec/src/xpath.c
|
||||
|
||||
use_gcrypt {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/gcrypt/app.h \
|
||||
xmlsec/include/xmlsec/gcrypt/crypto.h \
|
||||
xmlsec/include/xmlsec/gcrypt/symbols.h \
|
||||
\
|
||||
xmlsec/src/gcrypt/asn1.h \
|
||||
xmlsec/src/gcrypt/globals.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/gcrypt/app.c \
|
||||
xmlsec/src/gcrypt/asn1.c \
|
||||
xmlsec/src/gcrypt/asymkeys.c \
|
||||
xmlsec/src/gcrypt/ciphers.c \
|
||||
xmlsec/src/gcrypt/crypto.c \
|
||||
xmlsec/src/gcrypt/digests.c \
|
||||
xmlsec/src/gcrypt/hmac.c \
|
||||
xmlsec/src/gcrypt/kw_aes.c \
|
||||
xmlsec/src/gcrypt/kw_des.c \
|
||||
xmlsec/src/gcrypt/signatures.c \
|
||||
xmlsec/src/gcrypt/symkeys.c
|
||||
|
||||
}
|
||||
|
||||
use_gnutls {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/gnutls/app.h \
|
||||
xmlsec/include/xmlsec/gnutls/crypto.h \
|
||||
xmlsec/include/xmlsec/gnutls/symbols.h \
|
||||
xmlsec/include/xmlsec/gnutls/x509.h \
|
||||
\
|
||||
xmlsec/src/gnutls/globals.h \
|
||||
xmlsec/src/gnutls/x509utils.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/gnutls/app.c \
|
||||
xmlsec/src/gnutls/asymkeys.c \
|
||||
xmlsec/src/gnutls/ciphers.c \
|
||||
xmlsec/src/gnutls/crypto.c \
|
||||
xmlsec/src/gnutls/digests.c \
|
||||
xmlsec/src/gnutls/hmac.c \
|
||||
xmlsec/src/gnutls/kw_aes.c \
|
||||
xmlsec/src/gnutls/kw_des.c \
|
||||
xmlsec/src/gnutls/signatures.c \
|
||||
xmlsec/src/gnutls/symkeys.c \
|
||||
xmlsec/src/gnutls/x509.c \
|
||||
xmlsec/src/gnutls/x509utils.c \
|
||||
xmlsec/src/gnutls/x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_mscrypto {
|
||||
|
||||
DEFINES += XMLSEC_CRYPTO_MSCRYPTO
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/mscrypto/app.h \
|
||||
xmlsec/include/xmlsec/mscrypto/certkeys.h \
|
||||
xmlsec/include/xmlsec/mscrypto/crypto.h \
|
||||
xmlsec/include/xmlsec/mscrypto/keysstore.h \
|
||||
xmlsec/include/xmlsec/mscrypto/symbols.h \
|
||||
xmlsec/include/xmlsec/mscrypto/x509.h \
|
||||
\
|
||||
xmlsec/src/mscrypto/csp_calg.h \
|
||||
xmlsec/src/mscrypto/csp_oid.h \
|
||||
xmlsec/src/mscrypto/globals.h \
|
||||
xmlsec/src/mscrypto/private.h \
|
||||
xmlsec/src/mscrypto/xmlsec-mingw.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/mscrypto/app.c \
|
||||
xmlsec/src/mscrypto/certkeys.c \
|
||||
xmlsec/src/mscrypto/ciphers.c \
|
||||
xmlsec/src/mscrypto/crypto.c \
|
||||
xmlsec/src/mscrypto/digests.c \
|
||||
xmlsec/src/mscrypto/hmac.c \
|
||||
xmlsec/src/mscrypto/keysstore.c \
|
||||
xmlsec/src/mscrypto/kt_rsa.c \
|
||||
xmlsec/src/mscrypto/kw_aes.c \
|
||||
xmlsec/src/mscrypto/kw_des.c \
|
||||
xmlsec/src/mscrypto/signatures.c \
|
||||
xmlsec/src/mscrypto/symkeys.c \
|
||||
xmlsec/src/mscrypto/x509.c \
|
||||
xmlsec/src/mscrypto/x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_nss {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/nss/app.h \
|
||||
xmlsec/include/xmlsec/nss/bignum.h \
|
||||
xmlsec/include/xmlsec/nss/crypto.h \
|
||||
xmlsec/include/xmlsec/nss/keysstore.h \
|
||||
xmlsec/include/xmlsec/nss/pkikeys.h \
|
||||
xmlsec/include/xmlsec/nss/symbols.h \
|
||||
xmlsec/include/xmlsec/nss/x509.h \
|
||||
\
|
||||
xmlsec/src/nss/globals.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/nss/app.c \
|
||||
xmlsec/src/nss/bignum.c \
|
||||
xmlsec/src/nss/ciphers.c \
|
||||
xmlsec/src/nss/crypto.c \
|
||||
xmlsec/src/nss/digests.c \
|
||||
xmlsec/src/nss/hmac.c \
|
||||
xmlsec/src/nss/keysstore.c \
|
||||
xmlsec/src/nss/keytrans.c \
|
||||
xmlsec/src/nss/kw_aes.c \
|
||||
xmlsec/src/nss/kw_des.c \
|
||||
xmlsec/src/nss/pkikeys.c \
|
||||
xmlsec/src/nss/signatures.c \
|
||||
xmlsec/src/nss/symkeys.c \
|
||||
xmlsec/src/nss/x509.c \
|
||||
xmlsec/src/nss/x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_openssl {
|
||||
|
||||
DEFINES += XMLSEC_OPENSSL_110
|
||||
|
||||
INCLUDEPATH += $$PWD/openssl/include
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/openssl/app.h \
|
||||
xmlsec/include/xmlsec/openssl/bn.h \
|
||||
xmlsec/include/xmlsec/openssl/crypto.h \
|
||||
xmlsec/include/xmlsec/openssl/evp.h \
|
||||
xmlsec/include/xmlsec/openssl/symbols.h \
|
||||
xmlsec/include/xmlsec/openssl/x509.h \
|
||||
\
|
||||
xmlsec/src/openssl/globals.h \
|
||||
xmlsec/src/openssl/openssl11_wrapper.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/openssl/_app.c \
|
||||
xmlsec/src/openssl/_bn.c \
|
||||
xmlsec/src/openssl/_ciphers.c \
|
||||
xmlsec/src/openssl/_crypto.c \
|
||||
xmlsec/src/openssl/_digests.c \
|
||||
xmlsec/src/openssl/_evp.c \
|
||||
xmlsec/src/openssl/_evp_signatures.c \
|
||||
xmlsec/src/openssl/_hmac.c \
|
||||
xmlsec/src/openssl/_kt_rsa.c \
|
||||
xmlsec/src/openssl/_kw_aes.c \
|
||||
xmlsec/src/openssl/_kw_des.c \
|
||||
xmlsec/src/openssl/_signatures.c \
|
||||
xmlsec/src/openssl/_symkeys.c \
|
||||
xmlsec/src/openssl/_x509.c \
|
||||
xmlsec/src/openssl/_x509vfy.c
|
||||
|
||||
}
|
||||
|
||||
use_skeleton {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/skeleton/app.h \
|
||||
xmlsec/include/xmlsec/skeleton/crypto.h \
|
||||
xmlsec/include/xmlsec/skeleton/symbols.h \
|
||||
\
|
||||
xmlsec/src/skeleton/globals.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/skeleton/app.c \
|
||||
xmlsec/src/skeleton/crypto.c
|
||||
|
||||
}
|
||||
|
||||
use_xslt {
|
||||
|
||||
HEADERS += \
|
||||
xmlsec/include/xmlsec/private/xslt.h
|
||||
|
||||
SOURCES += \
|
||||
xmlsec/src/xslt.c
|
||||
|
||||
} else {
|
||||
|
||||
DEFINES += \
|
||||
XMLSEC_NO_XSLT
|
||||
|
||||
}
|
||||
@ -7,23 +7,23 @@ class COOXMLSigner_private;
|
||||
class OPENSSL_DECL COOXMLSigner
|
||||
{
|
||||
public:
|
||||
COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext);
|
||||
COOXMLSigner(unsigned char* data, unsigned long length, ICertificate* pContext);
|
||||
~COOXMLSigner();
|
||||
COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext);
|
||||
COOXMLSigner(unsigned char* data, unsigned long length, ICertificate* pContext);
|
||||
~COOXMLSigner();
|
||||
|
||||
void SetGuid (const std::wstring& guid);
|
||||
void SetImageValid (const std::wstring& file);
|
||||
void SetImageInvalid(const std::wstring& file);
|
||||
void SetImageValid (unsigned char* data, unsigned long length);
|
||||
void SetImageInvalid(unsigned char* data, unsigned long length);
|
||||
void SetGuid (const std::wstring& guid);
|
||||
void SetImageValid (const std::wstring& file);
|
||||
void SetImageInvalid(const std::wstring& file);
|
||||
void SetImageValid (unsigned char* data, unsigned long length);
|
||||
void SetImageInvalid(unsigned char* data, unsigned long length);
|
||||
|
||||
int Sign(unsigned char*& pFiletoWrite, unsigned long& dwLenFiletoWrite);
|
||||
int Sign(unsigned char*& pFiletoWrite, unsigned long& dwLenFiletoWrite);
|
||||
|
||||
// Simle alias to Sign(data, len) for folder realization
|
||||
int Sign();
|
||||
// Simle alias to Sign(data, len) for folder realization
|
||||
int Sign();
|
||||
|
||||
private:
|
||||
COOXMLSigner_private* m_internal;
|
||||
COOXMLSigner_private* m_internal;
|
||||
};
|
||||
|
||||
#endif //_XML_OOXMLSIGNER_H_
|
||||
|
||||
@ -12,43 +12,43 @@ class COOXMLSignature_private;
|
||||
class OPENSSL_DECL COOXMLSignature
|
||||
{
|
||||
public:
|
||||
COOXMLSignature();
|
||||
~COOXMLSignature();
|
||||
COOXMLSignature();
|
||||
~COOXMLSignature();
|
||||
|
||||
public:
|
||||
int GetValid();
|
||||
std::string GetGuid();
|
||||
std::string GetDate();
|
||||
ICertificate* GetCertificate();
|
||||
std::string GetImageValidBase64();
|
||||
std::string GetImageInvalidBase64();
|
||||
int GetValid();
|
||||
std::string GetGuid();
|
||||
std::string GetDate();
|
||||
ICertificate* GetCertificate();
|
||||
std::string GetImageValidBase64();
|
||||
std::string GetImageInvalidBase64();
|
||||
|
||||
std::wstring GetFile();
|
||||
std::wstring GetFile();
|
||||
|
||||
public:
|
||||
void Check();
|
||||
void Check();
|
||||
|
||||
friend class COOXMLVerifier_private;
|
||||
friend class COOXMLVerifier;
|
||||
friend class COOXMLVerifier_private;
|
||||
friend class COOXMLVerifier;
|
||||
private:
|
||||
COOXMLSignature_private* m_internal;
|
||||
COOXMLSignature_private* m_internal;
|
||||
};
|
||||
|
||||
class COOXMLVerifier_private;
|
||||
class Q_DECL_EXPORT COOXMLVerifier
|
||||
{
|
||||
public:
|
||||
COOXMLVerifier(const std::wstring& sFolder);
|
||||
COOXMLVerifier(unsigned char* data, unsigned long length);
|
||||
~COOXMLVerifier();
|
||||
COOXMLVerifier(const std::wstring& sFolder);
|
||||
COOXMLVerifier(unsigned char* data, unsigned long length);
|
||||
~COOXMLVerifier();
|
||||
|
||||
int GetSignatureCount();
|
||||
COOXMLSignature* GetSignature(const int& index);
|
||||
int GetSignatureCount();
|
||||
COOXMLSignature* GetSignature(const int& index);
|
||||
|
||||
void RemoveSignature(const std::string& sGuid);
|
||||
void RemoveSignature(const std::string& sGuid);
|
||||
|
||||
private:
|
||||
COOXMLVerifier_private* m_internal;
|
||||
COOXMLVerifier_private* m_internal;
|
||||
};
|
||||
|
||||
#endif //_XML_OOXMLVERIFIER_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -6,213 +6,255 @@
|
||||
#include "../../../common/Directory.h"
|
||||
#include "../../../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
class CManifestFileInfo
|
||||
{
|
||||
public:
|
||||
IFolder* m_pFolder;
|
||||
|
||||
protected:
|
||||
std::wstring m_sFile;
|
||||
std::wstring m_sAliasDirectory;
|
||||
int m_nCountUnexistedFile;
|
||||
|
||||
public:
|
||||
CManifestFileInfo()
|
||||
{
|
||||
m_pFolder = NULL;
|
||||
m_sFile = L"";
|
||||
m_nCountUnexistedFile = 0;
|
||||
}
|
||||
|
||||
std::wstring& GetFilePath()
|
||||
{
|
||||
return m_sFile;
|
||||
}
|
||||
|
||||
void SetFilePath(const std::wstring& sFilePath)
|
||||
{
|
||||
m_sFile = sFilePath;
|
||||
m_sAliasDirectory = NSFile::GetDirectoryName(sFilePath);
|
||||
m_sAliasDirectory = NSFile::GetDirectoryName(m_sAliasDirectory); // ../ from _rels/
|
||||
}
|
||||
|
||||
void CheckAliasExist(const std::wstring& sFile)
|
||||
{
|
||||
if (!m_pFolder->exists(m_sAliasDirectory + L"/" + sFile))
|
||||
++m_nCountUnexistedFile;
|
||||
}
|
||||
|
||||
bool IsExitRemovedFile()
|
||||
{
|
||||
return (0 != m_nCountUnexistedFile) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
class COOXMLRelationship
|
||||
{
|
||||
public:
|
||||
std::wstring rid;
|
||||
std::wstring type;
|
||||
std::wstring target;
|
||||
std::wstring target_mode;
|
||||
std::wstring rid;
|
||||
std::wstring type;
|
||||
std::wstring target;
|
||||
std::wstring target_mode;
|
||||
|
||||
public:
|
||||
|
||||
COOXMLRelationship()
|
||||
{
|
||||
}
|
||||
COOXMLRelationship()
|
||||
{
|
||||
}
|
||||
|
||||
COOXMLRelationship(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
rid = node.GetAttribute("Id");
|
||||
type = node.GetAttribute("Type");
|
||||
target = node.GetAttribute("Target");
|
||||
target_mode = node.GetAttribute("TargetMode");
|
||||
COOXMLRelationship(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
rid = node.GetAttribute("Id");
|
||||
type = node.GetAttribute("Type");
|
||||
target = node.GetAttribute("Target");
|
||||
target_mode = node.GetAttribute("TargetMode");
|
||||
|
||||
CheckTargetMode();
|
||||
}
|
||||
CheckTargetMode();
|
||||
}
|
||||
|
||||
std::wstring GetXml()
|
||||
{
|
||||
NSStringUtils::CStringBuilder builder;
|
||||
builder.WriteString(L"<Relationship Id=\"");
|
||||
builder.WriteEncodeXmlString(rid);
|
||||
builder.WriteString(L"\" Type=\"");
|
||||
builder.WriteEncodeXmlString(type);
|
||||
builder.WriteString(L"\" Target=\"");
|
||||
builder.WriteEncodeXmlString(target);
|
||||
builder.WriteString(L"\" TargetMode=\"");
|
||||
builder.WriteEncodeXmlString(target_mode);
|
||||
builder.WriteString(L"\" />");
|
||||
return builder.GetData();
|
||||
}
|
||||
std::wstring GetXml()
|
||||
{
|
||||
NSStringUtils::CStringBuilder builder;
|
||||
builder.WriteString(L"<Relationship Id=\"");
|
||||
builder.WriteEncodeXmlString(rid);
|
||||
builder.WriteString(L"\" Type=\"");
|
||||
builder.WriteEncodeXmlString(type);
|
||||
builder.WriteString(L"\" Target=\"");
|
||||
builder.WriteEncodeXmlString(target);
|
||||
builder.WriteString(L"\" TargetMode=\"");
|
||||
builder.WriteEncodeXmlString(target_mode);
|
||||
builder.WriteString(L"\" />");
|
||||
return builder.GetData();
|
||||
}
|
||||
|
||||
static bool Compare(const COOXMLRelationship& i, const COOXMLRelationship& j)
|
||||
{
|
||||
return i.rid < j.rid;
|
||||
}
|
||||
static bool Compare(const COOXMLRelationship& i, const COOXMLRelationship& j)
|
||||
{
|
||||
return i.rid < j.rid;
|
||||
}
|
||||
|
||||
protected:
|
||||
void CheckTargetMode()
|
||||
{
|
||||
if (!target_mode.empty())
|
||||
return;
|
||||
void CheckTargetMode()
|
||||
{
|
||||
if (!target_mode.empty())
|
||||
return;
|
||||
|
||||
if (0 == target.find(L"http") || 0 == target.find(L"www") || 0 == target.find(L"ftp"))
|
||||
target_mode = L"External";
|
||||
else
|
||||
target_mode = L"Internal";
|
||||
}
|
||||
if (0 == target.find(L"http") || 0 == target.find(L"www") || 0 == target.find(L"ftp"))
|
||||
target_mode = L"External";
|
||||
else
|
||||
target_mode = L"Internal";
|
||||
}
|
||||
};
|
||||
|
||||
class COOXMLRelationships
|
||||
{
|
||||
public:
|
||||
std::vector<COOXMLRelationship> rels;
|
||||
IFolder* m_pFolder;
|
||||
std::vector<COOXMLRelationship> rels;
|
||||
CManifestFileInfo* m_pFileInfo;
|
||||
|
||||
public:
|
||||
|
||||
COOXMLRelationships()
|
||||
{
|
||||
m_pFolder = NULL;
|
||||
}
|
||||
COOXMLRelationships()
|
||||
{
|
||||
}
|
||||
|
||||
COOXMLRelationships(const std::string& xml, std::map<std::wstring, bool>* check_need = NULL)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
if (!oNode.FromXmlStringA(xml))
|
||||
return;
|
||||
COOXMLRelationships(const std::string& xml, CManifestFileInfo* pFileInfo, std::map<std::wstring, bool>* check_need = NULL)
|
||||
{
|
||||
m_pFileInfo = pFileInfo;
|
||||
XmlUtils::CXmlNode oNode;
|
||||
if (!oNode.FromXmlStringA(xml))
|
||||
return;
|
||||
|
||||
FromXmlNode(oNode, check_need);
|
||||
}
|
||||
FromXmlNode(oNode, check_need);
|
||||
}
|
||||
|
||||
COOXMLRelationships(const std::wstring& xml, IFolder* pFolder, std::map<std::wstring, bool>* check_need = NULL)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
COOXMLRelationships(CManifestFileInfo* pFileInfo, std::map<std::wstring, bool>* check_need = NULL)
|
||||
{
|
||||
m_pFileInfo = pFileInfo;
|
||||
|
||||
if (NULL == pFolder)
|
||||
{
|
||||
if (!oNode.FromXmlString(xml))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFolder = pFolder;
|
||||
oNode = pFolder->getNodeFromFile(xml);
|
||||
if (!oNode.IsValid())
|
||||
return;
|
||||
}
|
||||
if (!m_pFileInfo || NULL != m_pFileInfo->m_pFolder)
|
||||
return;
|
||||
|
||||
FromXmlNode(oNode, check_need);
|
||||
}
|
||||
XmlUtils::CXmlNode oNode = m_pFileInfo->m_pFolder->getNodeFromFile(m_pFileInfo->GetFilePath());
|
||||
if (!oNode.IsValid())
|
||||
return;
|
||||
|
||||
void FromXmlNode(XmlUtils::CXmlNode& oNode, std::map<std::wstring, bool>* check_need = NULL)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (!oNode.GetNodes(L"Relationship", oNodes))
|
||||
return;
|
||||
FromXmlNode(oNode, check_need);
|
||||
}
|
||||
|
||||
int nCount = oNodes.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oRel;
|
||||
oNodes.GetAt(i, oRel);
|
||||
void FromXmlNode(XmlUtils::CXmlNode& oNode, std::map<std::wstring, bool>* check_need = NULL)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (!oNode.GetNodes(L"Relationship", oNodes))
|
||||
return;
|
||||
|
||||
if (NULL == check_need)
|
||||
{
|
||||
rels.push_back(COOXMLRelationship(oRel));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sRid = oRel.GetAttribute("Id");
|
||||
if (check_need->find(sRid) != check_need->end())
|
||||
rels.push_back(COOXMLRelationship(oRel));
|
||||
}
|
||||
}
|
||||
}
|
||||
int nCount = oNodes.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oRel;
|
||||
oNodes.GetAt(i, oRel);
|
||||
|
||||
std::wstring GetXml()
|
||||
{
|
||||
NSStringUtils::CStringBuilder builder;
|
||||
COOXMLRelationship oCurrentRel(oRel);
|
||||
if (NULL == check_need)
|
||||
{
|
||||
rels.push_back(oCurrentRel);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sRid = oRel.GetAttribute("Id");
|
||||
if (check_need->find(sRid) != check_need->end())
|
||||
rels.push_back(oCurrentRel);
|
||||
}
|
||||
|
||||
builder.WriteString(L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
|
||||
if (oCurrentRel.target_mode == L"Internal")
|
||||
{
|
||||
m_pFileInfo->CheckAliasExist(oCurrentRel.target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort by rId
|
||||
std::sort(rels.begin(), rels.end(), COOXMLRelationship::Compare);
|
||||
std::wstring GetXml()
|
||||
{
|
||||
NSStringUtils::CStringBuilder builder;
|
||||
|
||||
for (std::vector<COOXMLRelationship>::iterator i = rels.begin(); i != rels.end(); i++)
|
||||
builder.WriteString(i->GetXml());
|
||||
builder.WriteString(L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
|
||||
|
||||
builder.WriteString(L"</Relationships>");
|
||||
// sort by rId
|
||||
std::sort(rels.begin(), rels.end(), COOXMLRelationship::Compare);
|
||||
|
||||
return builder.GetData();
|
||||
}
|
||||
for (std::vector<COOXMLRelationship>::iterator i = rels.begin(); i != rels.end(); i++)
|
||||
builder.WriteString(i->GetXml());
|
||||
|
||||
std::wstring GetTransforms()
|
||||
{
|
||||
NSStringUtils::CStringBuilder builder;
|
||||
builder.WriteString(L"</Relationships>");
|
||||
|
||||
builder.WriteString(L"<Transforms><Transform Algorithm=\"http://schemas.openxmlformats.org/package/2006/RelationshipTransform\">");
|
||||
return builder.GetData();
|
||||
}
|
||||
|
||||
for (std::vector<COOXMLRelationship>::iterator i = rels.begin(); i != rels.end(); i++)
|
||||
{
|
||||
builder.WriteString(L"<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"");
|
||||
builder.WriteEncodeXmlString(i->rid);
|
||||
builder.WriteString(L"\" />");
|
||||
}
|
||||
std::wstring GetTransforms()
|
||||
{
|
||||
NSStringUtils::CStringBuilder builder;
|
||||
|
||||
builder.WriteString(L"</Transform><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>");
|
||||
builder.WriteString(L"<Transforms><Transform Algorithm=\"http://schemas.openxmlformats.org/package/2006/RelationshipTransform\">");
|
||||
|
||||
return builder.GetData();
|
||||
}
|
||||
for (std::vector<COOXMLRelationship>::iterator i = rels.begin(); i != rels.end(); i++)
|
||||
{
|
||||
builder.WriteString(L"<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"");
|
||||
builder.WriteEncodeXmlString(i->rid);
|
||||
builder.WriteString(L"\" />");
|
||||
}
|
||||
|
||||
void CheckOriginSigs(const std::wstring& file)
|
||||
{
|
||||
int rId = 0;
|
||||
std::string sReplace = "";
|
||||
std::vector<COOXMLRelationship>::iterator i = rels.begin();
|
||||
while (i != rels.end())
|
||||
{
|
||||
if (0 == i->target.find(L"_xmlsignatures/"))
|
||||
{
|
||||
sReplace = U_TO_UTF8(i->target);
|
||||
break;
|
||||
}
|
||||
builder.WriteString(L"</Transform><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>");
|
||||
|
||||
std::wstring rid = i->rid;
|
||||
rid = rid.substr(3);
|
||||
return builder.GetData();
|
||||
}
|
||||
|
||||
int nTemp = std::stoi(rid);
|
||||
void CheckOriginSigs(const std::wstring& file)
|
||||
{
|
||||
int rId = 0;
|
||||
std::string sReplace = "";
|
||||
std::vector<COOXMLRelationship>::iterator i = rels.begin();
|
||||
while (i != rels.end())
|
||||
{
|
||||
if (0 == i->target.find(L"_xmlsignatures/"))
|
||||
{
|
||||
sReplace = U_TO_UTF8(i->target);
|
||||
break;
|
||||
}
|
||||
|
||||
if (nTemp > rId)
|
||||
rId = nTemp;
|
||||
std::wstring rid = i->rid;
|
||||
rid = rid.substr(3);
|
||||
|
||||
i++;
|
||||
}
|
||||
int nTemp = std::stoi(rid);
|
||||
|
||||
if (!sReplace.empty())
|
||||
{
|
||||
if (sReplace == "_xmlsignatures/origin.sigs")
|
||||
return;
|
||||
if (nTemp > rId)
|
||||
rId = nTemp;
|
||||
|
||||
std::string sXmlA = m_pFolder->readXml(file);
|
||||
NSStringUtils::string_replaceA(sXmlA, sReplace, "_xmlsignatures/origin.sigs");
|
||||
m_pFolder->writeXmlA(file, sXmlA);
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
std::string sXmlA = m_pFolder->readXml(file);
|
||||
if (!sReplace.empty())
|
||||
{
|
||||
if (sReplace == "_xmlsignatures/origin.sigs")
|
||||
return;
|
||||
|
||||
std::string::size_type pos = sXmlA.rfind("</Relationships>");
|
||||
if (pos == std::string::npos)
|
||||
return;
|
||||
std::string sXmlA = m_pFileInfo->m_pFolder->readXml(file);
|
||||
NSStringUtils::string_replaceA(sXmlA, sReplace, "_xmlsignatures/origin.sigs");
|
||||
m_pFileInfo->m_pFolder->writeXmlA(file, sXmlA);
|
||||
return;
|
||||
}
|
||||
|
||||
rId++;
|
||||
std::string sRet = sXmlA.substr(0, pos);
|
||||
sRet += ("<Relationship Id=\"rId" + std::to_string(rId) + "\" \
|
||||
std::string sXmlA = m_pFileInfo->m_pFolder->readXml(file);
|
||||
|
||||
std::string::size_type pos = sXmlA.rfind("</Relationships>");
|
||||
if (pos == std::string::npos)
|
||||
return;
|
||||
|
||||
rId++;
|
||||
std::string sRet = sXmlA.substr(0, pos);
|
||||
sRet += ("<Relationship Id=\"rId" + std::to_string(rId) + "\" \
|
||||
Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin\" Target=\"_xmlsignatures/origin.sigs\"/>\
|
||||
</Relationships>");
|
||||
m_pFolder->writeXmlA(file, sRet);
|
||||
}
|
||||
m_pFileInfo->m_pFolder->writeXmlA(file, sRet);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //_XML_RELS_H_
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
#include "./XmlTransform.h"
|
||||
|
||||
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg)
|
||||
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg, CManifestFileInfo* pManifestFileInfo)
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformRelationship* transform = new CXmlTransformRelationship();
|
||||
if (transform->m_algorithm == alg)
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformC14N* transform = new CXmlTransformC14N();
|
||||
if (transform->CheckC14NTransform(alg))
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformRelationship* transform = new CXmlTransformRelationship(pManifestFileInfo);
|
||||
if (transform->m_algorithm == alg)
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformC14N* transform = new CXmlTransformC14N();
|
||||
if (transform->CheckC14NTransform(alg))
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -6,186 +6,204 @@
|
||||
class IXmlTransform
|
||||
{
|
||||
protected:
|
||||
std::string m_algorithm;
|
||||
std::string m_algorithm;
|
||||
|
||||
public:
|
||||
IXmlTransform()
|
||||
{
|
||||
m_algorithm = "";
|
||||
}
|
||||
virtual ~IXmlTransform()
|
||||
{
|
||||
}
|
||||
IXmlTransform()
|
||||
{
|
||||
m_algorithm = "";
|
||||
}
|
||||
virtual ~IXmlTransform()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string Transform(const std::string& sXml) = 0;
|
||||
virtual void LoadFromXml(XmlUtils::CXmlNode& node) = 0;
|
||||
virtual std::string Transform(const std::string& sXml) = 0;
|
||||
virtual void LoadFromXml(XmlUtils::CXmlNode& node) = 0;
|
||||
|
||||
static IXmlTransform* GetFromType(const std::string& alg);
|
||||
static IXmlTransform* GetFromType(const std::string& alg, CManifestFileInfo* pManifestFileInfo);
|
||||
};
|
||||
|
||||
class CXmlTransformRelationship : public IXmlTransform
|
||||
{
|
||||
protected:
|
||||
std::map<std::wstring, bool> m_arIds;
|
||||
CManifestFileInfo* m_pManifestFileInfo;
|
||||
std::map<std::wstring, bool> m_arIds;
|
||||
|
||||
public:
|
||||
CXmlTransformRelationship() : IXmlTransform()
|
||||
{
|
||||
m_algorithm = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
|
||||
}
|
||||
CXmlTransformRelationship(CManifestFileInfo* pManifestFileInfo) : IXmlTransform()
|
||||
{
|
||||
m_pManifestFileInfo = pManifestFileInfo;
|
||||
m_algorithm = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
|
||||
}
|
||||
|
||||
virtual std::string Transform(const std::string& xml)
|
||||
{
|
||||
COOXMLRelationships _rels(xml, &m_arIds);
|
||||
return U_TO_UTF8(_rels.GetXml());
|
||||
}
|
||||
virtual std::string Transform(const std::string& xml)
|
||||
{
|
||||
std::map<std::wstring, bool>* checker = &m_arIds;
|
||||
|
||||
virtual void LoadFromXml(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodesIds;
|
||||
node.GetChilds(oNodesIds);
|
||||
// для некоторых путей не считаем валидными добавления в rels после подписи
|
||||
if (m_pManifestFileInfo)
|
||||
{
|
||||
std::wstring& sFile = m_pManifestFileInfo->GetFilePath();
|
||||
if (0 == sFile.find(L"/word/") ||
|
||||
0 == sFile.find(L"/ppt/") ||
|
||||
0 == sFile.find(L"/xl/"))
|
||||
{
|
||||
// https://bugzilla.onlyoffice.com/show_bug.cgi?id=59649
|
||||
checker = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int nCount = oNodesIds.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode _node;
|
||||
oNodesIds.GetAt(i, _node);
|
||||
|
||||
std::wstring sType = _node.GetAttribute("SourceId");
|
||||
if (!sType.empty())
|
||||
m_arIds.insert(std::pair<std::wstring, bool>(sType, true));
|
||||
}
|
||||
}
|
||||
COOXMLRelationships _rels(xml, m_pManifestFileInfo, checker);
|
||||
return U_TO_UTF8(_rels.GetXml());
|
||||
}
|
||||
|
||||
virtual void LoadFromXml(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodesIds;
|
||||
node.GetChilds(oNodesIds);
|
||||
|
||||
int nCount = oNodesIds.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode _node;
|
||||
oNodesIds.GetAt(i, _node);
|
||||
|
||||
std::wstring sType = _node.GetAttribute("SourceId");
|
||||
if (!sType.empty())
|
||||
m_arIds.insert(std::pair<std::wstring, bool>(sType, true));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CXmlTransformC14N : public IXmlTransform
|
||||
{
|
||||
protected:
|
||||
int m_mode;
|
||||
bool m_comments;
|
||||
int m_mode;
|
||||
bool m_comments;
|
||||
|
||||
public:
|
||||
CXmlTransformC14N() : IXmlTransform()
|
||||
{
|
||||
m_mode = -1;
|
||||
m_comments = false;
|
||||
}
|
||||
CXmlTransformC14N() : IXmlTransform()
|
||||
{
|
||||
m_mode = -1;
|
||||
m_comments = false;
|
||||
}
|
||||
|
||||
bool CheckC14NTransform(const std::string& alg)
|
||||
{
|
||||
m_mode = -1;
|
||||
if ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_0;
|
||||
m_comments = false;
|
||||
}
|
||||
else if ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_0;
|
||||
m_comments = true;
|
||||
}
|
||||
else if ("http://www.w3.org/2006/12/xml-c14n11" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_1;
|
||||
m_comments = false;
|
||||
}
|
||||
else if ("http://www.w3.org/2006/12/xml-c14n11#WithComments" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_1;
|
||||
m_comments = true;
|
||||
}
|
||||
else if ("http://www.w3.org/2001/10/xml-exc-c14n#" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_EXCLUSIVE_1_0;
|
||||
m_comments = false;
|
||||
}
|
||||
else if ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_EXCLUSIVE_1_0;
|
||||
m_comments = true;
|
||||
}
|
||||
return (-1 != m_mode) ? true : false;
|
||||
}
|
||||
bool CheckC14NTransform(const std::string& alg)
|
||||
{
|
||||
m_mode = -1;
|
||||
if ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_0;
|
||||
m_comments = false;
|
||||
}
|
||||
else if ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_0;
|
||||
m_comments = true;
|
||||
}
|
||||
else if ("http://www.w3.org/2006/12/xml-c14n11" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_1;
|
||||
m_comments = false;
|
||||
}
|
||||
else if ("http://www.w3.org/2006/12/xml-c14n11#WithComments" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_1_1;
|
||||
m_comments = true;
|
||||
}
|
||||
else if ("http://www.w3.org/2001/10/xml-exc-c14n#" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_EXCLUSIVE_1_0;
|
||||
m_comments = false;
|
||||
}
|
||||
else if ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments" == alg)
|
||||
{
|
||||
m_mode = XmlUtils::XML_C14N_EXCLUSIVE_1_0;
|
||||
m_comments = true;
|
||||
}
|
||||
return (-1 != m_mode) ? true : false;
|
||||
}
|
||||
|
||||
virtual std::string Transform(const std::string& xml)
|
||||
{
|
||||
if (-1 == m_mode)
|
||||
return xml;
|
||||
return XmlUtils::NSXmlCanonicalizator::Execute(xml, m_mode, m_comments);
|
||||
}
|
||||
virtual std::string Transform(const std::string& xml)
|
||||
{
|
||||
if (-1 == m_mode)
|
||||
return xml;
|
||||
return XmlUtils::NSXmlCanonicalizator::Execute(xml, m_mode, m_comments);
|
||||
}
|
||||
|
||||
virtual void LoadFromXml(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
// none
|
||||
XML_UNUSED(node);
|
||||
}
|
||||
virtual void LoadFromXml(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
// none
|
||||
XML_UNUSED(node);
|
||||
}
|
||||
};
|
||||
|
||||
class CXmlTransforms
|
||||
{
|
||||
protected:
|
||||
std::vector<IXmlTransform*> m_transforms;
|
||||
bool m_valid;
|
||||
std::vector<IXmlTransform*> m_transforms;
|
||||
bool m_valid;
|
||||
|
||||
public:
|
||||
CXmlTransforms()
|
||||
{
|
||||
m_valid = true;
|
||||
}
|
||||
CXmlTransforms()
|
||||
{
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
CXmlTransforms(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
m_valid = true;
|
||||
CXmlTransforms(XmlUtils::CXmlNode& node, CManifestFileInfo* pManifestInfo)
|
||||
{
|
||||
m_valid = true;
|
||||
|
||||
XmlUtils::CXmlNodes oNodes = node.GetNodes(L"Transform");
|
||||
int nCount = oNodes.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode nodeTransform;
|
||||
oNodes.GetAt(i, nodeTransform);
|
||||
XmlUtils::CXmlNodes oNodes = node.GetNodes(L"Transform");
|
||||
int nCount = oNodes.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode nodeTransform;
|
||||
oNodes.GetAt(i, nodeTransform);
|
||||
|
||||
IXmlTransform* pTransform = IXmlTransform::GetFromType(nodeTransform.GetAttributeA("Algorithm"));
|
||||
if (NULL == pTransform)
|
||||
{
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
IXmlTransform* pTransform = IXmlTransform::GetFromType(nodeTransform.GetAttributeA("Algorithm"), pManifestInfo);
|
||||
if (NULL == pTransform)
|
||||
{
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
pTransform->LoadFromXml(nodeTransform);
|
||||
m_transforms.push_back(pTransform);
|
||||
}
|
||||
}
|
||||
pTransform->LoadFromXml(nodeTransform);
|
||||
m_transforms.push_back(pTransform);
|
||||
}
|
||||
}
|
||||
|
||||
~CXmlTransforms()
|
||||
{
|
||||
for (std::vector<IXmlTransform*>::iterator i = m_transforms.begin(); i != m_transforms.end(); i++)
|
||||
{
|
||||
IXmlTransform* t = *i;
|
||||
RELEASEOBJECT(t);
|
||||
}
|
||||
m_transforms.clear();
|
||||
}
|
||||
~CXmlTransforms()
|
||||
{
|
||||
for (std::vector<IXmlTransform*>::iterator i = m_transforms.begin(); i != m_transforms.end(); i++)
|
||||
{
|
||||
IXmlTransform* t = *i;
|
||||
RELEASEOBJECT(t);
|
||||
}
|
||||
m_transforms.clear();
|
||||
}
|
||||
|
||||
bool GetValid()
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
bool GetValid()
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
std::string Transform(const std::string& xml)
|
||||
{
|
||||
std::string sResult = xml;
|
||||
for (std::vector<IXmlTransform*>::iterator i = m_transforms.begin(); i != m_transforms.end(); i++)
|
||||
{
|
||||
sResult = (*i)->Transform(sResult);
|
||||
}
|
||||
return sResult;
|
||||
}
|
||||
std::string Transform(const std::string& xml)
|
||||
{
|
||||
std::string sResult = xml;
|
||||
for (std::vector<IXmlTransform*>::iterator i = m_transforms.begin(); i != m_transforms.end(); i++)
|
||||
{
|
||||
sResult = (*i)->Transform(sResult);
|
||||
}
|
||||
return sResult;
|
||||
}
|
||||
|
||||
void AddTransform(IXmlTransform* transform)
|
||||
{
|
||||
m_transforms.push_back(transform);
|
||||
}
|
||||
void AddTransform(IXmlTransform* transform)
|
||||
{
|
||||
m_transforms.push_back(transform);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //_XML_TRANSFORM_H_
|
||||
|
||||
@ -57,23 +57,23 @@ namespace NSDjvu
|
||||
{
|
||||
static GUTF8String MakeUTF8String(const std::wstring& wsText)
|
||||
{
|
||||
std::string sText = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(wsText);
|
||||
GUTF8String utf8String(sText.c_str());
|
||||
return utf8String;
|
||||
std::string sText = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(wsText);
|
||||
GUTF8String utf8String(sText.c_str());
|
||||
return utf8String;
|
||||
}
|
||||
static std::string MakeCString(GUTF8String& strText)
|
||||
static std::string MakeCString(GUTF8String& strText)
|
||||
{
|
||||
std::string sString(strText.getbuf());
|
||||
return sString;
|
||||
return sString;
|
||||
}
|
||||
static int GetInteger(const std::wstring& wsString)
|
||||
static int GetInteger(const std::wstring& wsString)
|
||||
{
|
||||
if (wsString.size() < 1)
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
return std::stoi(wsString);
|
||||
return std::stoi(wsString);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -81,7 +81,7 @@ namespace NSDjvu
|
||||
|
||||
try
|
||||
{
|
||||
return static_cast<int>(std::stol(wsString));
|
||||
return static_cast<int>(std::stol(wsString));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -93,9 +93,9 @@ namespace NSDjvu
|
||||
CDjVuFileImplementation::CDjVuFileImplementation(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
m_pDoc = NULL;
|
||||
m_wsTempDirectory = L"";
|
||||
SetTempDirectory(L"");
|
||||
m_pApplicationFonts = pFonts;
|
||||
m_wsTempDirectory = L"";
|
||||
SetTempDirectory(L"");
|
||||
m_pApplicationFonts = pFonts;
|
||||
}
|
||||
CDjVuFileImplementation::~CDjVuFileImplementation()
|
||||
{
|
||||
@ -105,7 +105,7 @@ CDjVuFileImplementation::~CDjVuFileImplementation()
|
||||
}
|
||||
NSFonts::IApplicationFonts* CDjVuFileImplementation::GetFonts()
|
||||
{
|
||||
return m_pApplicationFonts;
|
||||
return m_pApplicationFonts;
|
||||
}
|
||||
|
||||
bool CDjVuFileImplementation::LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXMLOptions)
|
||||
@ -127,19 +127,19 @@ bool CDjVuFileImplementation::LoadFromFile(const std::wstring& wsSrcFileName, co
|
||||
}
|
||||
bool CDjVuFileImplementation::LoadFromMemory(BYTE* data, DWORD length, const std::wstring& wsXmlOptions)
|
||||
{
|
||||
m_pDoc = NULL;
|
||||
try
|
||||
{
|
||||
GP<ByteStream> stream = ByteStream::create(data, (size_t)length);
|
||||
m_pDoc = DjVuDocument::create(stream);
|
||||
m_pDoc->wait_get_pages_num();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_pDoc = NULL;
|
||||
try
|
||||
{
|
||||
GP<ByteStream> stream = ByteStream::create(data, (size_t)length);
|
||||
m_pDoc = DjVuDocument::create(stream);
|
||||
m_pDoc->wait_get_pages_num();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
void CDjVuFileImplementation::Close()
|
||||
{
|
||||
@ -151,14 +151,14 @@ std::wstring CDjVuFileImplementation::GetTempDirectory() const
|
||||
void CDjVuFileImplementation::SetTempDirectory(const std::wstring& wsDirectory)
|
||||
{
|
||||
#ifndef DISABLE_TEMP_DIRECTORY
|
||||
if (!m_wsTempDirectory.empty())
|
||||
NSDirectory::DeleteDirectory(m_wsTempDirectory);
|
||||
if (!m_wsTempDirectory.empty())
|
||||
NSDirectory::DeleteDirectory(m_wsTempDirectory);
|
||||
|
||||
m_wsTempDirectory = wsDirectory;
|
||||
if (m_wsTempDirectory.empty())
|
||||
m_wsTempDirectory = NSFile::CFileBinary::GetTempPath();
|
||||
m_wsTempDirectory = wsDirectory;
|
||||
if (m_wsTempDirectory.empty())
|
||||
m_wsTempDirectory = NSFile::CFileBinary::GetTempPath();
|
||||
|
||||
m_wsTempDirectory += L"/DJVU/";
|
||||
m_wsTempDirectory += L"/DJVU/";
|
||||
NSDirectory::CreateDirectory(m_wsTempDirectory);
|
||||
#endif
|
||||
}
|
||||
@ -193,14 +193,14 @@ void CDjVuFileImplementation::GetPageInfo(int nPageIndex, double* pdWidth, doubl
|
||||
*pdDpiX = pPage->get_dpi();
|
||||
*pdDpiY = pPage->get_dpi();
|
||||
#endif
|
||||
int nW = 0;
|
||||
int nH = 0;
|
||||
int nDpi = 0;
|
||||
m_pDoc->ReadPageInfo(nPageIndex, nW, nH, nDpi);
|
||||
*pdWidth = nW;
|
||||
*pdHeight = nH;
|
||||
*pdDpiX = nDpi;
|
||||
*pdDpiY = nDpi;
|
||||
int nW = 0;
|
||||
int nH = 0;
|
||||
int nDpi = 0;
|
||||
m_pDoc->ReadPageInfo(nPageIndex, nW, nH, nDpi);
|
||||
*pdWidth = nW;
|
||||
*pdHeight = nH;
|
||||
*pdDpiX = nDpi;
|
||||
*pdDpiY = nDpi;
|
||||
}
|
||||
void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
||||
{
|
||||
@ -217,14 +217,14 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPag
|
||||
pRenderer->get_Type(&lRendererType);
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (c_nPDFWriter == lRendererType)
|
||||
if (c_nPDFWriter == lRendererType)
|
||||
{
|
||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
||||
CreatePdfFrame(pRenderer, pPage, nPageIndex, oText);
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
{
|
||||
{
|
||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
||||
CreateFrame(pRenderer, pPage, nPageIndex, oText);
|
||||
}
|
||||
@ -236,8 +236,8 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPag
|
||||
}
|
||||
void CDjVuFileImplementation::ConvertToPdf(const std::wstring& wsDstPath)
|
||||
{
|
||||
CPdfFile oPdf(m_pApplicationFonts);
|
||||
oPdf.CreatePdf();
|
||||
CPdfFile oPdf(m_pApplicationFonts);
|
||||
oPdf.CreatePdf();
|
||||
|
||||
bool bBreak = false;
|
||||
for (int nPageIndex = 0, nPagesCount = GetPagesCount(); nPageIndex < nPagesCount; nPageIndex++)
|
||||
@ -262,166 +262,166 @@ void CDjVuFileImplementation::ConvertToPdf(const std::wstring& wsDstPath)
|
||||
}
|
||||
std::wstring CDjVuFileImplementation::GetInfo()
|
||||
{
|
||||
std::wstring sRes = L"{";
|
||||
std::wstring sRes = L"{";
|
||||
|
||||
double nW = 0;
|
||||
double nH = 0;
|
||||
double nDpi = 0;
|
||||
GetPageInfo(0, &nW, &nH, &nDpi, &nDpi);
|
||||
sRes += L"\"PageWidth\":";
|
||||
sRes += std::to_wstring((int)(nW * 100));
|
||||
sRes += L",\"PageHeight\":";
|
||||
sRes += std::to_wstring((int)(nH * 100));
|
||||
sRes += L",\"NumberOfPages\":";
|
||||
sRes += std::to_wstring(GetPagesCount());
|
||||
sRes += L"}";
|
||||
double nW = 0;
|
||||
double nH = 0;
|
||||
double nDpi = 0;
|
||||
GetPageInfo(0, &nW, &nH, &nDpi, &nDpi);
|
||||
sRes += L"\"PageWidth\":";
|
||||
sRes += std::to_wstring((int)(nW * 100));
|
||||
sRes += L",\"PageHeight\":";
|
||||
sRes += std::to_wstring((int)(nH * 100));
|
||||
sRes += L",\"NumberOfPages\":";
|
||||
sRes += std::to_wstring(GetPagesCount());
|
||||
sRes += L"}";
|
||||
|
||||
return sRes;
|
||||
return sRes;
|
||||
}
|
||||
|
||||
void getBookmars(const GP<DjVmNav>& nav, int& pos, int count, NSWasm::CData& out, int level)
|
||||
{
|
||||
while (count > 0 && pos < nav->getBookMarkCount())
|
||||
{
|
||||
GP<DjVmNav::DjVuBookMark> gpBookMark;
|
||||
nav->getBookMark(gpBookMark, pos++);
|
||||
while (count > 0 && pos < nav->getBookMarkCount())
|
||||
{
|
||||
GP<DjVmNav::DjVuBookMark> gpBookMark;
|
||||
nav->getBookMark(gpBookMark, pos++);
|
||||
|
||||
GUTF8String str = gpBookMark->url;
|
||||
int endpos;
|
||||
DWORD nPage = str.toULong(1, endpos) - 1;
|
||||
if (endpos == (int)str.length())
|
||||
{
|
||||
out.AddInt(nPage);
|
||||
out.AddInt(level);
|
||||
out.AddDouble(0.0);
|
||||
GUTF8String description = gpBookMark->displayname;
|
||||
out.WriteString((BYTE*)description.getbuf(), description.length());
|
||||
}
|
||||
GUTF8String str = gpBookMark->url;
|
||||
int endpos;
|
||||
DWORD nPage = str.toULong(1, endpos) - 1;
|
||||
if (endpos == (int)str.length())
|
||||
{
|
||||
out.AddInt(nPage);
|
||||
out.AddInt(level);
|
||||
out.AddDouble(0.0);
|
||||
GUTF8String description = gpBookMark->displayname;
|
||||
out.WriteString((BYTE*)description.getbuf(), description.length());
|
||||
}
|
||||
|
||||
getBookmars(nav, pos, gpBookMark->count, out, level + 1);
|
||||
count--;
|
||||
}
|
||||
getBookmars(nav, pos, gpBookMark->count, out, level + 1);
|
||||
count--;
|
||||
}
|
||||
}
|
||||
BYTE* CDjVuFileImplementation::GetStructure()
|
||||
{
|
||||
GP<DjVmNav> nav = m_pDoc->get_djvm_nav();
|
||||
if (!nav)
|
||||
return NULL;
|
||||
GP<DjVmNav> nav = m_pDoc->get_djvm_nav();
|
||||
if (!nav)
|
||||
return NULL;
|
||||
|
||||
int pos = 0;
|
||||
int count = nav->getBookMarkCount();
|
||||
if (count <= 0)
|
||||
return NULL;
|
||||
int pos = 0;
|
||||
int count = nav->getBookMarkCount();
|
||||
if (count <= 0)
|
||||
return NULL;
|
||||
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
getBookmars(nav, pos, count, oRes, 1);
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
getBookmars(nav, pos, count, oRes, 1);
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
}
|
||||
BYTE* CDjVuFileImplementation::GetPageGlyphs(int nPageIndex)
|
||||
{
|
||||
return NULL;
|
||||
try
|
||||
{
|
||||
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||
const GP<DjVuText> text(DjVuText::create());
|
||||
const GP<ByteStream> text_str(pPage->get_text());
|
||||
if (!text_str)
|
||||
return NULL;
|
||||
text->decode(text_str);
|
||||
return NULL;
|
||||
try
|
||||
{
|
||||
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||
const GP<DjVuText> text(DjVuText::create());
|
||||
const GP<ByteStream> text_str(pPage->get_text());
|
||||
if (!text_str)
|
||||
return NULL;
|
||||
text->decode(text_str);
|
||||
|
||||
GUTF8String pageText = text->get_xmlText(pPage->get_height());
|
||||
XmlUtils::CXmlNode hiddenText;
|
||||
XmlUtils::CXmlNode pageColumn;
|
||||
XmlUtils::CXmlNode region;
|
||||
hiddenText.FromXmlStringA(NSDjvu::MakeCString(pageText));
|
||||
hiddenText.GetNode(L"PAGECOLUMN", pageColumn);
|
||||
pageColumn.GetNode(L"REGION", region);
|
||||
GUTF8String pageText = text->get_xmlText(pPage->get_height());
|
||||
XmlUtils::CXmlNode hiddenText;
|
||||
XmlUtils::CXmlNode pageColumn;
|
||||
XmlUtils::CXmlNode region;
|
||||
hiddenText.FromXmlStringA(NSDjvu::MakeCString(pageText));
|
||||
hiddenText.GetNode(L"PAGECOLUMN", pageColumn);
|
||||
pageColumn.GetNode(L"REGION", region);
|
||||
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
XmlUtils::CXmlNodes oParagraphsNodes;
|
||||
region.GetNodes(L"PARAGRAPH", oParagraphsNodes);
|
||||
for (int nParagraphIndex = 0; nParagraphIndex < oParagraphsNodes.GetCount(); nParagraphIndex++)
|
||||
{
|
||||
XmlUtils::CXmlNode oParagraphNode;
|
||||
oParagraphsNodes.GetAt(nParagraphIndex, oParagraphNode);
|
||||
XmlUtils::CXmlNodes oLinesNodes;
|
||||
oParagraphNode.GetNodes(L"LINE", oLinesNodes);
|
||||
for (int nLineIndex = 0; nLineIndex < oLinesNodes.GetCount(); nLineIndex++)
|
||||
{
|
||||
XmlUtils::CXmlNode oLineNode;
|
||||
oLinesNodes.GetAt(nLineIndex, oLineNode);
|
||||
XmlUtils::CXmlNodes oWordsNodes;
|
||||
oLineNode.GetNodes(L"WORD", oWordsNodes);
|
||||
for (int nWordIndex = 0; nWordIndex < oWordsNodes.GetCount(); nWordIndex++)
|
||||
{
|
||||
XmlUtils::CXmlNode oWordNode;
|
||||
oWordsNodes.GetAt(nWordIndex, oWordNode);
|
||||
std::wstring csWord = oWordNode.GetText();
|
||||
std::wstring csCoords = oWordNode.GetAttribute(L"coords");
|
||||
double arrCoords[4];
|
||||
ParseCoords(csCoords, arrCoords, 1);
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
XmlUtils::CXmlNodes oParagraphsNodes;
|
||||
region.GetNodes(L"PARAGRAPH", oParagraphsNodes);
|
||||
for (int nParagraphIndex = 0; nParagraphIndex < oParagraphsNodes.GetCount(); nParagraphIndex++)
|
||||
{
|
||||
XmlUtils::CXmlNode oParagraphNode;
|
||||
oParagraphsNodes.GetAt(nParagraphIndex, oParagraphNode);
|
||||
XmlUtils::CXmlNodes oLinesNodes;
|
||||
oParagraphNode.GetNodes(L"LINE", oLinesNodes);
|
||||
for (int nLineIndex = 0; nLineIndex < oLinesNodes.GetCount(); nLineIndex++)
|
||||
{
|
||||
XmlUtils::CXmlNode oLineNode;
|
||||
oLinesNodes.GetAt(nLineIndex, oLineNode);
|
||||
XmlUtils::CXmlNodes oWordsNodes;
|
||||
oLineNode.GetNodes(L"WORD", oWordsNodes);
|
||||
for (int nWordIndex = 0; nWordIndex < oWordsNodes.GetCount(); nWordIndex++)
|
||||
{
|
||||
XmlUtils::CXmlNode oWordNode;
|
||||
oWordsNodes.GetAt(nWordIndex, oWordNode);
|
||||
std::wstring csWord = oWordNode.GetText();
|
||||
std::wstring csCoords = oWordNode.GetAttribute(L"coords");
|
||||
double arrCoords[4];
|
||||
ParseCoords(csCoords, arrCoords, 1);
|
||||
|
||||
std::string sText = U_TO_UTF8(csWord);
|
||||
oRes.WriteString((BYTE*)sText.c_str(), sText.length());
|
||||
oRes.AddDouble(arrCoords[0]);
|
||||
oRes.AddDouble(arrCoords[3]);
|
||||
oRes.AddDouble(arrCoords[2] - arrCoords[0]);
|
||||
oRes.AddDouble(arrCoords[1] - arrCoords[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
oRes.WriteLen();
|
||||
std::string sText = U_TO_UTF8(csWord);
|
||||
oRes.WriteString((BYTE*)sText.c_str(), sText.length());
|
||||
oRes.AddDouble(arrCoords[0]);
|
||||
oRes.AddDouble(arrCoords[3]);
|
||||
oRes.AddDouble(arrCoords[2] - arrCoords[0]);
|
||||
oRes.AddDouble(arrCoords[1] - arrCoords[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
catch (...) {}
|
||||
return NULL;
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
catch (...) {}
|
||||
return NULL;
|
||||
}
|
||||
BYTE* CDjVuFileImplementation::GetPageLinks(int nPageIndex)
|
||||
{
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
|
||||
try
|
||||
{
|
||||
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||
pPage->wait_for_complete_decode();
|
||||
GP<DjVuAnno> pAnno = pPage->get_decoded_anno();
|
||||
if (!pAnno)
|
||||
return NULL;
|
||||
GPList<GMapArea> map_areas = pAnno->ant->map_areas;
|
||||
try
|
||||
{
|
||||
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||
pPage->wait_for_complete_decode();
|
||||
GP<DjVuAnno> pAnno = pPage->get_decoded_anno();
|
||||
if (!pAnno)
|
||||
return NULL;
|
||||
GPList<GMapArea> map_areas = pAnno->ant->map_areas;
|
||||
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
for (GPosition pos(map_areas); pos; ++pos)
|
||||
{
|
||||
GUTF8String str = map_areas[pos]->url;
|
||||
oRes.WriteString((BYTE*)str.getbuf(), str.length());
|
||||
// Верхний левый угол
|
||||
double x = map_areas[pos]->get_xmin();
|
||||
double y = dHeight - map_areas[pos]->get_ymax();
|
||||
oRes.AddDouble(0.0);
|
||||
oRes.AddDouble(x);
|
||||
oRes.AddDouble(y);
|
||||
oRes.AddDouble(map_areas[pos]->get_xmax() - x);
|
||||
oRes.AddDouble(map_areas[pos]->get_ymax() - map_areas[pos]->get_ymin());
|
||||
}
|
||||
oRes.WriteLen();
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
for (GPosition pos(map_areas); pos; ++pos)
|
||||
{
|
||||
GUTF8String str = map_areas[pos]->url;
|
||||
oRes.WriteString((BYTE*)str.getbuf(), str.length());
|
||||
// Верхний левый угол
|
||||
double x = map_areas[pos]->get_xmin();
|
||||
double y = dHeight - map_areas[pos]->get_ymax();
|
||||
oRes.AddDouble(0.0);
|
||||
oRes.AddDouble(x);
|
||||
oRes.AddDouble(y);
|
||||
oRes.AddDouble(map_areas[pos]->get_xmax() - x);
|
||||
oRes.AddDouble(map_areas[pos]->get_ymax() - map_areas[pos]->get_ymin());
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
catch (...) {}
|
||||
return NULL;
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
catch (...) {}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pPage, int nPage, XmlUtils::CXmlNode& text)
|
||||
@ -467,7 +467,7 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
}
|
||||
else if (c_nHtmlRendrerer == lRendererType)
|
||||
{
|
||||
// TODO: Нужно реализовать функцию
|
||||
// TODO: Нужно реализовать функцию
|
||||
// pRenderer->GetMaxImageSize();
|
||||
//VARIANT var;
|
||||
//renderer->GetAdditionalParam(L"MaxImageSize", &var);
|
||||
@ -492,10 +492,13 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
if (!pBufferDst)
|
||||
return;
|
||||
|
||||
bool bIsInit = false;
|
||||
|
||||
Aggplus::CImage oImage;
|
||||
oImage.Create(pBufferDst, lImageWidth, lImageHeight, 4 * lImageWidth);
|
||||
if (pPage->is_legal_photo() || pPage->is_legal_compound())
|
||||
{
|
||||
bIsInit = true;
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
|
||||
@ -515,11 +518,12 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
}
|
||||
else if (pPage->is_legal_bilevel())
|
||||
{
|
||||
bIsInit = true;
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
@ -531,7 +535,7 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
@ -560,6 +564,7 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
|
||||
if (NULL != pImage)
|
||||
{
|
||||
bIsInit = true;
|
||||
BYTE* pBuffer = pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
@ -580,9 +585,10 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
|
||||
if (NULL != pBitmap)
|
||||
{
|
||||
bIsInit = true;
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
@ -594,7 +600,7 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
@ -624,7 +630,8 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
}
|
||||
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
if (bIsInit)
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
pRenderer->EndCommand(c_nPageType);
|
||||
}
|
||||
void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pPage, int nPageIndex, XmlUtils::CXmlNode& oText)
|
||||
@ -738,42 +745,42 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>
|
||||
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
|
||||
NSImages::CPixJbig2 oPix;
|
||||
if (oPix.Create(lImageWidth, lImageHeight, 1))
|
||||
NSImages::CPixJbig2 oPix;
|
||||
if (oPix.Create(lImageWidth, lImageHeight, 1))
|
||||
{
|
||||
for (int nY = 0; nY < lImageHeight; nY++)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](nY);
|
||||
for (int nX = 0; nX < lImageWidth; nX++, pLine++)
|
||||
{
|
||||
oPix.SetPixel(nX, lImageHeight - 1 - nY, *pLine);
|
||||
oPix.SetPixel(nX, lImageHeight - 1 - nY, *pLine);
|
||||
}
|
||||
}
|
||||
|
||||
pPdf->DrawImageWith1bppMask((IGrObject*)&oImage, &oPix, lImageWidth, lImageHeight, 0, 0, dWidth, dHeight);
|
||||
oPix.Destroy();
|
||||
pPdf->DrawImageWith1bppMask((IGrObject*)&oImage, &oPix, lImageWidth, lImageHeight, 0, 0, dWidth, dHeight);
|
||||
oPix.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pPage->is_legal_bilevel())
|
||||
{
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
|
||||
NSImages::CPixJbig2 oPix;
|
||||
if (oPix.Create(lImageWidth, lImageHeight, 1))
|
||||
NSImages::CPixJbig2 oPix;
|
||||
if (oPix.Create(lImageWidth, lImageHeight, 1))
|
||||
{
|
||||
for (int nY = 0; nY < lImageHeight; nY++)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](nY);
|
||||
for (int nX = 0; nX < lImageWidth; nX++, pLine++)
|
||||
{
|
||||
oPix.SetPixel(nX, lImageHeight - 1 - nY, *pLine);
|
||||
oPix.SetPixel(nX, lImageHeight - 1 - nY, *pLine);
|
||||
}
|
||||
}
|
||||
|
||||
pPdf->DrawImage1bpp(&oPix, lImageWidth, lImageHeight, 0, 0, dWidth, dHeight);
|
||||
oPix.Destroy();
|
||||
pPdf->DrawImage1bpp(&oPix, lImageWidth, lImageHeight, 0, 0, dWidth, dHeight);
|
||||
oPix.Destroy();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -815,20 +822,20 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
if (nPaletteEntries <= 2)
|
||||
{
|
||||
NSImages::CPixJbig2 oPix;
|
||||
if (oPix.Create(lImageWidth, lImageHeight, 1))
|
||||
NSImages::CPixJbig2 oPix;
|
||||
if (oPix.Create(lImageWidth, lImageHeight, 1))
|
||||
{
|
||||
for (int nY = 0; nY < lImageHeight; nY++)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](nY);
|
||||
for (int nX = 0; nX < lImageWidth; nX++, pLine++)
|
||||
{
|
||||
oPix.Create(nX, lImageHeight - 1 - nY, *pLine);
|
||||
oPix.Create(nX, lImageHeight - 1 - nY, *pLine);
|
||||
}
|
||||
}
|
||||
|
||||
pPdf->DrawImage1bpp(&oPix, lImageWidth, lImageHeight, 0, 0, dWidth, dHeight);
|
||||
oPix.Destroy();
|
||||
pPdf->DrawImage1bpp(&oPix, lImageWidth, lImageHeight, 0, 0, dWidth, dHeight);
|
||||
oPix.Destroy();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -840,7 +847,7 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>
|
||||
Aggplus::CImage oImage;
|
||||
oImage.Create(pBufferDst, lImageWidth, lImageHeight, 4 * lImageWidth);
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
@ -852,7 +859,7 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
@ -892,10 +899,10 @@ XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
|
||||
XmlUtils::CXmlNode hiddenText;
|
||||
XmlUtils::CXmlNode pageColumn;
|
||||
XmlUtils::CXmlNode region;
|
||||
hiddenText.FromXmlStringA(NSDjvu::MakeCString(pageText));
|
||||
hiddenText.GetNode(L"PAGECOLUMN", pageColumn);
|
||||
pageColumn.GetNode(L"REGION", region);
|
||||
region.GetNode(L"PARAGRAPH", paragraph);
|
||||
hiddenText.FromXmlStringA(NSDjvu::MakeCString(pageText));
|
||||
hiddenText.GetNode(L"PAGECOLUMN", pageColumn);
|
||||
pageColumn.GetNode(L"REGION", region);
|
||||
region.GetNode(L"PARAGRAPH", paragraph);
|
||||
}
|
||||
return paragraph;
|
||||
}
|
||||
@ -903,7 +910,7 @@ void CDjVuFileImplementation::TextToRenderer(IRenderer* pRenderer, XmlUtils::CXm
|
||||
{
|
||||
// Выставим шрифт пустой (чтобы растягивать по всему ректу)
|
||||
pRenderer->put_FontName(L"DjvuEmptyFont");
|
||||
//std::wstring csText = oTextNode.GetXml();
|
||||
//std::wstring csText = oTextNode.GetXml();
|
||||
XmlUtils::CXmlNodes oLinesNodes;
|
||||
oTextNode.GetNodes(L"LINE", oLinesNodes);
|
||||
for (int nLineIndex = 0; nLineIndex < oLinesNodes.GetCount(); ++nLineIndex)
|
||||
@ -916,11 +923,11 @@ void CDjVuFileImplementation::TextToRenderer(IRenderer* pRenderer, XmlUtils::CXm
|
||||
{
|
||||
XmlUtils::CXmlNode oWordNode;
|
||||
oWordsNodes.GetAt(nWordIndex, oWordNode);
|
||||
std::wstring csWord = oWordNode.GetText();
|
||||
std::wstring csCoords = oWordNode.GetAttribute(L"coords");
|
||||
std::wstring csWord = oWordNode.GetText();
|
||||
std::wstring csCoords = oWordNode.GetAttribute(L"coords");
|
||||
double arrCoords[4];
|
||||
ParseCoords(csCoords, arrCoords, dKoef);
|
||||
DrawPageText(pRenderer, arrCoords, csWord);
|
||||
ParseCoords(csCoords, arrCoords, dKoef);
|
||||
DrawPageText(pRenderer, arrCoords, csWord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -929,13 +936,13 @@ void CDjVuFileImplementation::DrawPageText(IRenderer* pRenderer, double* pdCoord
|
||||
pRenderer->put_FontSize(pdCoords[1] - pdCoords[3]);
|
||||
pRenderer->CommandDrawText(wsText,
|
||||
(float)(pdCoords[0]),
|
||||
(float)(pdCoords[3]),
|
||||
(float)(pdCoords[2] - pdCoords[0]),
|
||||
(float)(pdCoords[1] - pdCoords[3]));
|
||||
(float)(pdCoords[3]),
|
||||
(float)(pdCoords[2] - pdCoords[0]),
|
||||
(float)(pdCoords[1] - pdCoords[3]));
|
||||
}
|
||||
void CDjVuFileImplementation::ParseCoords(const std::wstring& wsCoordsStr, double* pdCoords, double dKoef)
|
||||
{
|
||||
std::vector<std::wstring> vCoords = NSStringExt::Split(wsCoordsStr, L',');
|
||||
std::vector<std::wstring> vCoords = NSStringExt::Split(wsCoordsStr, L',');
|
||||
if (vCoords.size() >= 4)
|
||||
{
|
||||
for (int nIndex = 0; nIndex < 4; nIndex++)
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "../DesktopEditor/graphics/pro/officedrawingfile.h"
|
||||
#include "../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
#include "src/logic/elements/Paragraph.h"
|
||||
#include "./convert_params.h"
|
||||
|
||||
#ifndef DOCXRENDERER_USE_DYNAMIC_LIBRARY
|
||||
#define DOCXRENDERER_DECL_EXPORT
|
||||
|
||||
44
DocxRenderer/convert_params.h
Normal file
44
DocxRenderer/convert_params.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* 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-6 Ernesta Birznieka-Upish
|
||||
* 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
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
enum TextAssociationType
|
||||
{
|
||||
tatBlockChar = 0, // Каждый символ во фрейме
|
||||
tatBlockLine = 1, // Каждая линия - параграф во фрейме. Линии могут объединяться в рамках одного блока.
|
||||
tatPlainLine = 2, // Каждая линия - параграф обычный
|
||||
tatShapeLine = 3, // Каждая линия - параграф в шейпе. Линии могут объединяться в рамках одного блока.
|
||||
tatPlainParagraph = 4 // Линии объединяются в параграфы
|
||||
};
|
||||
}
|
||||
@ -1,18 +1,10 @@
|
||||
#pragma once
|
||||
#include "BaseItem.h"
|
||||
#include "TextLine.h"
|
||||
#include "../../../convert_params.h"
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
enum TextAssociationType
|
||||
{
|
||||
tatBlockChar = 0, // Каждый символ во фрейме
|
||||
tatBlockLine = 1, // Каждая линия - параграф во фрейме. Линии могут объединяться в рамках одного блока.
|
||||
tatPlainLine = 2, // Каждая линия - параграф обычный
|
||||
tatShapeLine = 3, // Каждая линия - параграф в шейпе. Линии могут объединяться в рамках одного блока.
|
||||
tatPlainParagraph = 4 // Линии объединяются в параграфы
|
||||
};
|
||||
|
||||
class CParagraph : public CBaseItem
|
||||
{
|
||||
public:
|
||||
|
||||
@ -10,7 +10,7 @@ CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, graphics, PdfFile, DjVuFile, XpsFile, DocxRenderer)
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, kernel_network, graphics, PdfFile, DjVuFile, XpsFile, DocxRenderer)
|
||||
|
||||
core_linux:include($$PWD/../../Common/3dParty/icu/icu.pri)
|
||||
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
|
||||
|
||||
@ -167,7 +167,7 @@ HRESULT CEpubFile::Convert(const std::wstring& sInputFile, const std::wstring& s
|
||||
NSDirectory::CreateDirectory(sOutputDir);
|
||||
HRESULT hRes = oFile.OpenBatchHtml(arFiles, sOutputDir, &oFileParams);
|
||||
if (bIsOutCompress && S_OK == hRes)
|
||||
oOfficeUtils.CompressFileOrDirectory(sOutputDir, sOutputFile);
|
||||
hRes = oOfficeUtils.CompressFileOrDirectory(sOutputDir, sOutputFile);
|
||||
|
||||
#ifdef _DEBUG
|
||||
std::wcout << L"---" << (S_OK == hRes ? L"Successful" : L"Failed") << L" conversion of Epub to Docx---" << std::endl;
|
||||
|
||||
@ -1104,31 +1104,19 @@ private:
|
||||
std::vector<CTc>::iterator it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; });
|
||||
while(it1 != mTable.end() || it2 != mTable.end())
|
||||
{
|
||||
oXml->WriteString(L"<w:tc><w:tcPr><w:textDirection w:val=\"lrTb\"/><w:noWrap w:val=\"false\"/><w:tcBorders>");
|
||||
oXml->WriteString(L"<w:tc><w:tcPr><w:tcBorders>");
|
||||
oXml->WriteString(!sBorders.empty() ? sBorders : L"<w:left w:val=\"none\" w:color=\"000000\"/><w:top w:val=\"none\" w:color=\"000000\"/><w:right w:val=\"none\" w:color=\"000000\"/><w:bottom w:val=\"none\" w:color=\"000000\"/>");
|
||||
oXml->WriteString(L"</w:tcBorders><w:vMerge w:val=\"continue\"/><w:gridSpan w:val=\"");
|
||||
std::wstring sCol = (it1 != mTable.end() ? it1->sGridSpan : it2->sGridSpan);
|
||||
oXml->WriteString(sCol);
|
||||
oXml->WriteString(L"\"/></w:tcPr><w:p></w:p></w:tc>");
|
||||
oXml->WriteString(L"\"/><w:noWrap w:val=\"false\"/><w:textDirection w:val=\"lrTb\"/></w:tcPr><w:p></w:p></w:tc>");
|
||||
j += stoi(sCol);
|
||||
it1 = std::find_if(mTable.begin(), mTable.end(), [i, j](const CTc& item){ return item.i == i && item.j == j; });
|
||||
it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; });
|
||||
}
|
||||
|
||||
GetSubClass(oXml, sSelectors);
|
||||
oXml->WriteString(L"<w:tc><w:tcPr><w:textDirection w:val=\"lrTb\"/><w:noWrap w:val=\"false\"/><w:tcBorders>");
|
||||
oXml->WriteString(!sBorders.empty() ? sBorders : L"<w:left w:val=\"none\" w:color=\"000000\"/><w:top w:val=\"none\" w:color=\"000000\"/><w:right w:val=\"none\" w:color=\"000000\"/><w:bottom w:val=\"none\" w:color=\"000000\"/>");
|
||||
oXml->WriteString(L"</w:tcBorders>");
|
||||
if(nRowspan != 1)
|
||||
{
|
||||
oXml->WriteString(L"<w:vMerge w:val=\"restart\"/>");
|
||||
std::wstring sColspan = std::to_wstring(nColspan);
|
||||
if(nRowspan == 0)
|
||||
mTable.push_back({0, j, sColspan});
|
||||
else
|
||||
for(int k = i + 1; k < i + nRowspan; k++)
|
||||
mTable.push_back({k, j, sColspan});
|
||||
}
|
||||
oXml->WriteString(L"<w:tc><w:tcPr>");
|
||||
|
||||
NSCSS::CCompiledStyle oStyleSetting = m_oStylesCalculator.GetCompiledStyle({sSelectors.back()}, true);
|
||||
NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle({sSelectors.back()}, false);
|
||||
@ -1138,7 +1126,7 @@ private:
|
||||
int nWidth = oStyle.m_pDisplay.GetWidth();
|
||||
std::wstring wsType = L"dxa";
|
||||
|
||||
//Если ширина указана в %, то используем тип dxa, если же в других ндтнтцах измерения, то в pct
|
||||
//Если ширина указана в %, то используем тип dxa, если же в других единицах измерения, то в pct
|
||||
#if 1
|
||||
// проблема с regex в старом gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52719)
|
||||
boost::wregex oWidthRegex(L"((width)+)[\\s]*:[\\s]*(.+%)");
|
||||
@ -1173,12 +1161,26 @@ private:
|
||||
j += nColspan - 1;
|
||||
}
|
||||
|
||||
oXml->WriteString(L"<w:tcBorders>");
|
||||
oXml->WriteString(!sBorders.empty() ? sBorders : L"<w:left w:val=\"none\" w:color=\"000000\"/><w:top w:val=\"none\" w:color=\"000000\"/><w:right w:val=\"none\" w:color=\"000000\"/><w:bottom w:val=\"none\" w:color=\"000000\"/>");
|
||||
oXml->WriteString(L"</w:tcBorders>");
|
||||
if(nRowspan != 1)
|
||||
{
|
||||
oXml->WriteString(L"<w:vMerge w:val=\"restart\"/>");
|
||||
std::wstring sColspan = std::to_wstring(nColspan);
|
||||
if(nRowspan == 0)
|
||||
mTable.push_back({0, j, sColspan});
|
||||
else
|
||||
for(int k = i + 1; k < i + nRowspan; k++)
|
||||
mTable.push_back({k, j, sColspan});
|
||||
}
|
||||
|
||||
std::wstring wsVerticalAlign = oStyle.m_pDisplay.GetVerticalAlign();
|
||||
|
||||
if (!wsVerticalAlign.empty())
|
||||
oXml->WriteString(L"<w:vAlign w:val=\"" + wsVerticalAlign + L"\"/>");
|
||||
|
||||
oXml->WriteString(L"<w:hideMark/></w:tcPr>");
|
||||
oXml->WriteString(L"<w:noWrap w:val=\"false\"/><w:textDirection w:val=\"lrTb\"/><w:hideMark/></w:tcPr>");
|
||||
size_t nEmpty = oXml->GetCurSize();
|
||||
m_bWasPStyle = false;
|
||||
|
||||
@ -1213,12 +1215,12 @@ private:
|
||||
it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; });
|
||||
while(it1 != mTable.end() || it2 != mTable.end())
|
||||
{
|
||||
oXml->WriteString(L"<w:tc><w:tcPr><w:textDirection w:val=\"lrTb\"/><w:noWrap w:val=\"false\"/><w:tcBorders>");
|
||||
oXml->WriteString(L"<w:tc><w:tcPr><w:tcBorders>");
|
||||
oXml->WriteString(!sBorders.empty() ? sBorders : L"<w:left w:val=\"none\" w:color=\"000000\"/><w:top w:val=\"none\" w:color=\"000000\"/><w:right w:val=\"none\" w:color=\"000000\"/><w:bottom w:val=\"none\" w:color=\"000000\"/>");
|
||||
oXml->WriteString(L"</w:tcBorders><w:vMerge w:val=\"continue\"/><w:gridSpan w:val=\"");
|
||||
std::wstring sCol = (it1 != mTable.end() ? it1->sGridSpan : it2->sGridSpan);
|
||||
oXml->WriteString(sCol);
|
||||
oXml->WriteString(L"\"/></w:tcPr><w:p></w:p></w:tc>");
|
||||
oXml->WriteString(L"\"/><w:noWrap w:val=\"false\"/><w:textDirection w:val=\"lrTb\"/></w:tcPr><w:p></w:p></w:tc>");
|
||||
j += stoi(sCol);
|
||||
it1 = std::find_if(mTable.begin(), mTable.end(), [i, j](const CTc& item){ return item.i == i && item.j == j; });
|
||||
it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; });
|
||||
@ -1240,8 +1242,9 @@ private:
|
||||
|
||||
NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors, false);
|
||||
|
||||
//if (oXml->GetSubData(oXml->GetCurSize() - 6) != L"</w:p>")
|
||||
// oXml->WriteString(L"<w:p><w:pPr><w:spacing w:beforeLines=\"0\" w:before=\"0\" w:afterLines=\"0\" w:after=\"0\"/><w:rPr><w:vanish/><w:sz w:val=\"2\"/><w:szCs w:val=\"2\"/></w:rPr></w:pPr></w:p>");
|
||||
if (oXml->GetSubData(oXml->GetCurSize() - 6) != L"</w:p>")
|
||||
oXml->WriteString(L"<w:p><w:pPr><w:spacing w:beforeLines=\"0\" w:before=\"0\" w:afterLines=\"0\" w:after=\"0\"/><w:rPr><w:vanish/><w:sz w:val=\"2\"/><w:szCs w:val=\"2\"/></w:rPr></w:pPr></w:p>");
|
||||
m_bWasSpace = false;
|
||||
|
||||
// Начало таблицы
|
||||
std::wstring wsTable = L"<w:tbl><w:tblPr>";
|
||||
|
||||
@ -101,7 +101,7 @@ std::wstring PPT::CFontProperty::getXmlArgsStr() const
|
||||
{
|
||||
std::wstring str = L" typeface=\"" + Name + L"\"";
|
||||
if (IsValidPitchFamily(PitchFamily))
|
||||
str += L" pitchFamily=\"" + std::to_wstring(PitchFamily) + L"\"";
|
||||
str += L" pitchFamily=\"" + std::to_wstring((char)PitchFamily) + L"\"";
|
||||
if (IsValidCharset(Charset))
|
||||
str += L" charset=\"" + std::to_wstring((char)Charset) + L"\"";
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ void BulletsConverter::ConvertAllBullets(PPTX::Logic::TextParagraphPr &oPPr, CTe
|
||||
pBuFont->typeface = pPF->bulletFontProperties->Name;
|
||||
|
||||
if ( CFontProperty::IsValidPitchFamily(pPF->bulletFontProperties->PitchFamily))
|
||||
pBuFont->pitchFamily = std::to_wstring(pPF->bulletFontProperties->PitchFamily);
|
||||
pBuFont->pitchFamily = std::to_wstring((char)pPF->bulletFontProperties->PitchFamily);
|
||||
if ( CFontProperty::IsValidCharset(pPF->bulletFontProperties->Charset))
|
||||
pBuFont->charset = std::to_wstring(pPF->bulletFontProperties->Charset);
|
||||
|
||||
|
||||
@ -1430,7 +1430,7 @@ std::wstring CShapeWriter::WriteBullets(CTextPFRun *pPF, CRelsGenerator* pRels)
|
||||
|
||||
if ( pPF->bulletFontProperties->PitchFamily > 0)
|
||||
{
|
||||
buWrt.WriteString(std::wstring(L" pitchFamily=\"") + std::to_wstring(pPF->bulletFontProperties->PitchFamily) + L"\"");
|
||||
buWrt.WriteString(std::wstring(L" pitchFamily=\"") + std::to_wstring((char)pPF->bulletFontProperties->PitchFamily) + L"\"");
|
||||
}
|
||||
if ( pPF->bulletFontProperties->Charset > 0)
|
||||
{
|
||||
|
||||
@ -154,8 +154,8 @@ namespace NSBinPptxRW
|
||||
m_oReader.Init(pDstBuffer, 0, dstLen);
|
||||
m_oReader.Seek(start_pos);
|
||||
}
|
||||
|
||||
m_oReader.m_strFolder = srcFolder;
|
||||
OOX::CPath path(srcFolder);
|
||||
m_oReader.m_strFolder = path.GetPath();
|
||||
m_oReader.m_strFolderExternalThemes = strThemesFolder;
|
||||
|
||||
for (LONG i = 0; i < 30/*main tables max*/; ++i)
|
||||
|
||||
@ -7694,7 +7694,10 @@ int BinaryFileReader::ReadFile(const std::wstring& sSrcFileName, std::wstring sD
|
||||
CSVWriter oCSVWriter;
|
||||
|
||||
oCSVWriter.Init(oXlsx, nCodePage, sDelimiter, false);
|
||||
oCSVWriter.Start(sDstPathCSV);
|
||||
|
||||
bResultOk = oCSVWriter.Start(sDstPathCSV);
|
||||
if (!bResultOk) return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
|
||||
SaveParams oSaveParams(drawingsPath, embeddingsPath, themePath, pOfficeDrawingConverter->GetContentTypes(), &oCSVWriter);
|
||||
|
||||
try
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
Impl(OOX::Spreadsheet::CXlsx &oXlsx, unsigned int m_nCodePage, const std::wstring& sDelimiter, bool m_bJSON);
|
||||
~Impl();
|
||||
|
||||
void Start(const std::wstring &sFileDst);
|
||||
bool Start(const std::wstring &sFileDst);
|
||||
void WriteSheetStart(OOX::Spreadsheet::CWorksheet* pWorksheet);
|
||||
void WriteRowStart(OOX::Spreadsheet::CRow *pRow);
|
||||
void WriteCell(OOX::Spreadsheet::CCell *pCell);
|
||||
@ -166,10 +166,11 @@ void CSVWriter::Xlsx2Csv(const std::wstring &sFileDst, OOX::Spreadsheet::CXlsx &
|
||||
}
|
||||
impl_->End();
|
||||
}
|
||||
void CSVWriter::Start(const std::wstring &sFileDst)
|
||||
bool CSVWriter::Start(const std::wstring &sFileDst)
|
||||
{
|
||||
if (impl_)
|
||||
impl_->Start(sFileDst);
|
||||
return impl_->Start(sFileDst);
|
||||
return false;
|
||||
}
|
||||
void CSVWriter::WriteSheetStart(OOX::Spreadsheet::CWorksheet* pWorksheet)
|
||||
{
|
||||
@ -578,9 +579,10 @@ CSVWriter::Impl::~Impl()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
void CSVWriter::Impl::Start(const std::wstring &sFileDst)
|
||||
bool CSVWriter::Impl::Start(const std::wstring &sFileDst)
|
||||
{
|
||||
m_oFile.CreateFileW(sFileDst);
|
||||
bool res = m_oFile.CreateFileW(sFileDst);
|
||||
if (!res) return false;
|
||||
|
||||
// Нужно записать шапку
|
||||
if (46 == m_nCodePage)//todo 46 временно CP_UTF8
|
||||
@ -598,6 +600,7 @@ void CSVWriter::Impl::Start(const std::wstring &sFileDst)
|
||||
BYTE arBigEndian[2] = { 0xFE, 0xFF };
|
||||
m_oFile.WriteFile(arBigEndian, 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void CSVWriter::Impl::WriteSheetStart(OOX::Spreadsheet::CWorksheet* pWorksheet)
|
||||
{
|
||||
@ -946,12 +949,16 @@ std::wstring CSVWriter::Impl::ConvertValueCellToString(const std::wstring &value
|
||||
format_string += L".";
|
||||
format_string += std::to_wstring(numberFormat.count_float);
|
||||
}
|
||||
if (numberFormat.bPercent) format_string += L"%";
|
||||
|
||||
std::wstring strEnd = format_code.substr(pos_end + 1);
|
||||
XmlUtils::replace_all(strEnd, L"\\", L"");
|
||||
|
||||
|
||||
format_string += numberFormat.bFloat ? L"f" : L"ld";
|
||||
if (numberFormat.bPercent)
|
||||
{
|
||||
format_string += L"%%";
|
||||
XmlUtils::replace_all(strEnd, L"%", L"");
|
||||
}
|
||||
|
||||
format_string += strEnd;
|
||||
|
||||
numberFormat.format_string = format_string;
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
|
||||
void Init(OOX::Spreadsheet::CXlsx &oXlsx, unsigned int nCodePage, const std::wstring& wcDelimiter, bool bJSON);
|
||||
|
||||
void Start(const std::wstring &sFileDst);
|
||||
bool Start(const std::wstring &sFileDst);
|
||||
void WriteSheetStart(OOX::Spreadsheet::CWorksheet* pWorksheet);
|
||||
void WriteRowStart(OOX::Spreadsheet::CRow *pRow);
|
||||
void WriteCell(OOX::Spreadsheet::CCell *pCell);
|
||||
|
||||
@ -1262,8 +1262,10 @@ void CDrawingConverter::SetMainDocument(BinDocxRW::CDocxSerializer* pDocument)
|
||||
|
||||
void CDrawingConverter::SetSrcPath(const std::wstring& sPath, int nDocType)
|
||||
{
|
||||
m_pReader->m_pRels->m_pManager = m_pImageManager;
|
||||
m_pReader->m_strFolder = sPath;
|
||||
OOX::CPath path(sPath);
|
||||
|
||||
m_pReader->m_pRels->m_pManager = m_pImageManager;
|
||||
m_pReader->m_strFolder = path.GetPath();
|
||||
|
||||
m_pImageManager->m_nDocumentType = nDocType;
|
||||
}
|
||||
|
||||
@ -419,8 +419,12 @@ namespace PPTX
|
||||
{
|
||||
OOX::CPath pathUrl = strImagePath;
|
||||
strImagePath = pathUrl.GetPath();
|
||||
|
||||
if (std::wstring::npos == strImagePath.find(pReader->m_strFolder))
|
||||
{
|
||||
strImagePath.clear();
|
||||
}
|
||||
}
|
||||
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, additionalFile, oleData, strOrigBase64);
|
||||
|
||||
// -------------------
|
||||
|
||||
@ -942,9 +942,10 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool result = true;
|
||||
if (bLargeFile)
|
||||
{
|
||||
pStorageNew->Save(file_name_out);
|
||||
result = pStorageNew->Save(file_name_out);
|
||||
pStorageNew->Close();
|
||||
delete pStorageNew;
|
||||
}
|
||||
@ -974,7 +975,7 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s
|
||||
// }
|
||||
////test back---------------------------------------------------------------------------------test back
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity)
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@ Server core components which are a part of [ONLYOFFICE Document Server][2] and [
|
||||
|
||||
Official website: [http://www.onlyoffice.com](http://onlyoffice.com "http://www.onlyoffice.com")
|
||||
|
||||
Code repository: [https://github.com/ONLYOFFICE/core](https://github.com/ONLYOFFICE/сore "https://github.com/ONLYOFFICE/core")
|
||||
Code repository: [https://github.com/ONLYOFFICE/core](https://github.com/ONLYOFFICE/core "https://github.com/ONLYOFFICE/core")
|
||||
|
||||
SaaS version: [https://www.onlyoffice.com/cloud-office.aspx](https://www.onlyoffice.com/cloud-office.aspx "https://www.onlyoffice.com/cloud-office.aspx")
|
||||
|
||||
|
||||
@ -94,20 +94,8 @@ _UINT32 RtfConvertationManager::ConvertRtfToOOX( std::wstring sSrcFileName, std:
|
||||
m_poRtfReader = &oReader;
|
||||
m_poOOXWriter = &oWriter;
|
||||
|
||||
//m_poRtfReader->m_convertationManager = this;
|
||||
|
||||
if (false == oReader.Load( )) return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
|
||||
//сохранение будет поэлементое в обработчике OnCompleteItemRtf
|
||||
//надо только завершить
|
||||
//if( true == m_bParseFirstItem )
|
||||
//{
|
||||
// m_bParseFirstItem = false;
|
||||
// oWriter.SaveByItemStart( );
|
||||
//}
|
||||
//m_poOOXWriter->SaveByItem();
|
||||
//oWriter.SaveByItemEnd( );
|
||||
|
||||
oWriter.Save();
|
||||
|
||||
NSDirectory::DeleteDirectory(oReader.m_sTempFolder);
|
||||
@ -146,17 +134,19 @@ _UINT32 RtfConvertationManager::ConvertOOXToRtf( std::wstring sDstFileName, std:
|
||||
|
||||
m_poOOXReader->m_convertationManager = this;
|
||||
|
||||
bool succes = oReader.Parse( );
|
||||
if( true == succes)
|
||||
bool result = oReader.Parse( );
|
||||
if( result )
|
||||
{
|
||||
succes = oWriter.Save( );
|
||||
result = oWriter.Save( );
|
||||
}
|
||||
|
||||
NSDirectory::DeleteDirectory(oReader.m_sTempFolder);
|
||||
NSDirectory::DeleteDirectory(oWriter.m_sTempFolder);
|
||||
|
||||
if( true == succes) return 0;
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
if ( result )
|
||||
return 0;
|
||||
else
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
void RtfConvertationManager::OnCompleteItemRtf()
|
||||
{
|
||||
|
||||
@ -183,6 +183,7 @@ bool RtfWriter::SaveByItem()
|
||||
}
|
||||
bool RtfWriter::SaveByItemEnd()
|
||||
{
|
||||
bool result = true;
|
||||
//окончательно дописываем темповый файл
|
||||
RELEASEOBJECT( m_oCurTempFileWriter );
|
||||
|
||||
@ -272,7 +273,9 @@ bool RtfWriter::SaveByItemEnd()
|
||||
oTargetFileWriter.Write( &nEndFile, 1);
|
||||
}
|
||||
catch(...)
|
||||
{}
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_aTempFiles.size(); i++ )
|
||||
Utils::RemoveDirOrFile( m_aTempFiles[i] );
|
||||
@ -283,7 +286,8 @@ bool RtfWriter::SaveByItemEnd()
|
||||
Utils::RemoveDirOrFile( m_aTempFilesSectPr[i] );
|
||||
|
||||
m_aTempFilesSectPr.clear();
|
||||
return true;
|
||||
|
||||
return result;
|
||||
}
|
||||
int RtfWriter::GetCount()
|
||||
{
|
||||
|
||||
@ -1428,7 +1428,7 @@ bool OOXpPrReader::Parse( ReaderParameter oParam, RtfParagraphProperty& oOutputP
|
||||
}
|
||||
|
||||
if( m_ooxParaProps->m_oRPr.IsInit() )
|
||||
{
|
||||
{// ??? todooo сохранять текстовые ствойсва и использовать там где в run нет этих свойств
|
||||
OOXrPrReader orPrReader(m_ooxParaProps->m_oRPr.GetPointer());
|
||||
orPrReader.Parse( oParam, oOutputProperty.m_oCharProperty );
|
||||
}
|
||||
|
||||
@ -62,10 +62,10 @@ namespace Docx2Txt
|
||||
|
||||
void convert();
|
||||
|
||||
void writeUtf8 (const std::wstring& path) const;
|
||||
void writeUnicode (const std::wstring& path) const;
|
||||
void writeBigEndian (const std::wstring& path) const;
|
||||
void writeAnsi (const std::wstring& path) const;
|
||||
bool writeUtf8 (const std::wstring& path) const;
|
||||
bool writeUnicode (const std::wstring& path) const;
|
||||
bool writeBigEndian (const std::wstring& path) const;
|
||||
bool writeAnsi (const std::wstring& path) const;
|
||||
|
||||
Txt::File m_outputFile;
|
||||
OOX::CDocx m_inputFile;
|
||||
@ -115,33 +115,32 @@ namespace Docx2Txt
|
||||
return converter_->convert();
|
||||
}
|
||||
|
||||
void Converter::read(const std::wstring & path)
|
||||
bool Converter::read(const std::wstring & path)
|
||||
{
|
||||
bool res = converter_->m_inputFile.Read(path);
|
||||
return;
|
||||
return converter_->m_inputFile.Read(path);
|
||||
}
|
||||
|
||||
void Converter::write(const std::wstring & path)
|
||||
bool Converter::write(const std::wstring & path)
|
||||
{
|
||||
return converter_->m_outputFile.write(path);
|
||||
}
|
||||
|
||||
void Converter::writeUtf8(const std::wstring & path) const
|
||||
bool Converter::writeUtf8(const std::wstring & path) const
|
||||
{
|
||||
return converter_->writeUtf8(path);
|
||||
}
|
||||
|
||||
void Converter::writeUnicode(const std::wstring & path) const
|
||||
bool Converter::writeUnicode(const std::wstring & path) const
|
||||
{
|
||||
return converter_->writeUnicode(path);
|
||||
}
|
||||
|
||||
void Converter::writeBigEndian(const std::wstring & path) const
|
||||
bool Converter::writeBigEndian(const std::wstring & path) const
|
||||
{
|
||||
return converter_->writeBigEndian(path);
|
||||
}
|
||||
|
||||
void Converter::writeAnsi(const std::wstring & path) const
|
||||
bool Converter::writeAnsi(const std::wstring & path) const
|
||||
{
|
||||
return converter_->writeAnsi(path);
|
||||
}
|
||||
@ -204,27 +203,21 @@ namespace Docx2Txt
|
||||
}
|
||||
|
||||
|
||||
void Converter_Impl::writeUtf8(const std::wstring& path) const
|
||||
bool Converter_Impl::writeUtf8(const std::wstring& path) const
|
||||
{
|
||||
m_outputFile.writeUtf8(path);
|
||||
return m_outputFile.writeUtf8(path);
|
||||
}
|
||||
|
||||
|
||||
void Converter_Impl::writeUnicode(const std::wstring& path) const
|
||||
bool Converter_Impl::writeUnicode(const std::wstring& path) const
|
||||
{
|
||||
m_outputFile.writeUnicode(path);
|
||||
return m_outputFile.writeUnicode(path);
|
||||
}
|
||||
|
||||
|
||||
void Converter_Impl::writeBigEndian(const std::wstring& path) const
|
||||
bool Converter_Impl::writeBigEndian(const std::wstring& path) const
|
||||
{
|
||||
m_outputFile.writeBigEndian(path);
|
||||
return m_outputFile.writeBigEndian(path);
|
||||
}
|
||||
|
||||
|
||||
void Converter_Impl::writeAnsi(const std::wstring& path) const
|
||||
bool Converter_Impl::writeAnsi(const std::wstring& path) const
|
||||
{
|
||||
m_outputFile.writeAnsi(path);
|
||||
return m_outputFile.writeAnsi(path);
|
||||
}
|
||||
void Converter_Impl::convert(OOX::WritingElement* item, std::vector<std::wstring>& textOut, bool bEnter,
|
||||
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles)
|
||||
|
||||
@ -44,13 +44,13 @@ namespace Docx2Txt
|
||||
|
||||
void convert();
|
||||
|
||||
void read (const std::wstring& path);
|
||||
void write (const std::wstring& path);
|
||||
bool read (const std::wstring& path);
|
||||
bool write (const std::wstring& path);
|
||||
|
||||
void writeUtf8 (const std::wstring& path) const;
|
||||
void writeUnicode (const std::wstring& path) const;
|
||||
void writeBigEndian (const std::wstring& path) const;
|
||||
void writeAnsi (const std::wstring& path) const;
|
||||
bool writeUtf8 (const std::wstring& path) const;
|
||||
bool writeUnicode (const std::wstring& path) const;
|
||||
bool writeBigEndian (const std::wstring& path) const;
|
||||
bool writeAnsi (const std::wstring& path) const;
|
||||
|
||||
private:
|
||||
Converter_Impl * converter_;
|
||||
|
||||
@ -189,40 +189,40 @@ namespace Txt
|
||||
m_listContentSize = file.getLinesCount();
|
||||
}
|
||||
|
||||
void File::write(const std::wstring& filename) const
|
||||
bool File::write(const std::wstring& filename) const
|
||||
{
|
||||
TxtFile file(filename);
|
||||
file.writeUtf8(NSEncoding::transformFromUnicode(m_listContent, 46));
|
||||
return file.writeUtf8(NSEncoding::transformFromUnicode(m_listContent, 46));
|
||||
}
|
||||
|
||||
void File::writeCodePage(const std::wstring& filename, int code_page) const
|
||||
bool File::writeCodePage(const std::wstring& filename, int code_page) const
|
||||
{
|
||||
TxtFile file(filename);
|
||||
file.writeAnsiOrCodePage(NSEncoding::transformFromUnicode(m_listContent, code_page));
|
||||
return file.writeAnsiOrCodePage(NSEncoding::transformFromUnicode(m_listContent, code_page));
|
||||
}
|
||||
|
||||
void File::writeUtf8(const std::wstring& filename) const
|
||||
bool File::writeUtf8(const std::wstring& filename) const
|
||||
{
|
||||
TxtFile file(filename);
|
||||
file.writeUtf8(NSEncoding::transformFromUnicode(m_listContent, 46));
|
||||
return file.writeUtf8(NSEncoding::transformFromUnicode(m_listContent, 46));
|
||||
}
|
||||
|
||||
void File::writeUnicode(const std::wstring& filename) const
|
||||
bool File::writeUnicode(const std::wstring& filename) const
|
||||
{
|
||||
TxtFile file(filename);
|
||||
file.writeUnicode(m_listContent);
|
||||
return file.writeUnicode(m_listContent);
|
||||
}
|
||||
|
||||
void File::writeBigEndian(const std::wstring& filename) const
|
||||
bool File::writeBigEndian(const std::wstring& filename) const
|
||||
{
|
||||
TxtFile file(filename);
|
||||
file.writeBigEndian(m_listContent);
|
||||
return file.writeBigEndian(m_listContent);
|
||||
}
|
||||
|
||||
void File::writeAnsi(const std::wstring& filename) const
|
||||
bool File::writeAnsi(const std::wstring& filename) const
|
||||
{
|
||||
TxtFile file(filename);
|
||||
file.writeAnsiOrCodePage(NSEncoding::transformFromUnicode(m_listContent, -1));
|
||||
return file.writeAnsiOrCodePage(NSEncoding::transformFromUnicode(m_listContent, -1));
|
||||
}
|
||||
|
||||
const bool File::isValid(const std::wstring& filename) const
|
||||
|
||||
@ -45,13 +45,13 @@ namespace Txt
|
||||
void read (const std::wstring& filename);
|
||||
void read (const std::wstring& filename, int code_page);
|
||||
|
||||
void write (const std::wstring& filename) const;
|
||||
bool write (const std::wstring& filename) const;
|
||||
|
||||
void writeCodePage (const std::wstring& filename, int code_page) const;
|
||||
void writeUtf8 (const std::wstring& filename) const;
|
||||
void writeUnicode (const std::wstring& filename) const;
|
||||
void writeBigEndian (const std::wstring& filename) const;
|
||||
void writeAnsi (const std::wstring& filename) const;
|
||||
bool writeCodePage (const std::wstring& filename, int code_page) const;
|
||||
bool writeUtf8 (const std::wstring& filename) const;
|
||||
bool writeUnicode (const std::wstring& filename) const;
|
||||
bool writeBigEndian (const std::wstring& filename) const;
|
||||
bool writeAnsi (const std::wstring& filename) const;
|
||||
|
||||
const bool isValid (const std::wstring& filename) const;
|
||||
|
||||
|
||||
@ -192,109 +192,109 @@ const std::vector<std::string> TxtFile::readUtf8()
|
||||
return result;
|
||||
}
|
||||
|
||||
void TxtFile::writeAnsiOrCodePage(const std::vector<std::string>& content) // === writeUtf8withoutPref также
|
||||
bool TxtFile::writeAnsiOrCodePage(const std::vector<std::string>& content) // === writeUtf8withoutPref также
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(m_path))
|
||||
{
|
||||
BYTE endLine[2] = {0x0d, 0x0a};
|
||||
for (std::vector<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file.WriteFile((BYTE*)(*iter).c_str(), (*iter).length());
|
||||
file.WriteFile(endLine, 2);
|
||||
if (!file.CreateFileW(m_path)) return false;
|
||||
|
||||
m_linesCount++;
|
||||
}
|
||||
BYTE endLine[2] = {0x0d, 0x0a};
|
||||
for (std::vector<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file.WriteFile((BYTE*)(*iter).c_str(), (*iter).length());
|
||||
file.WriteFile(endLine, 2);
|
||||
|
||||
m_linesCount++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TxtFile::writeUnicode(const std::vector<std::wstring>& content)
|
||||
bool TxtFile::writeUnicode(const std::vector<std::wstring>& content)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(m_path))
|
||||
if (!file.CreateFileW(m_path)) return false;
|
||||
|
||||
BYTE Header[2] = {0xff, 0xfe};
|
||||
BYTE EndLine[4] = { 0x0d, 0x00, 0x0a, 0x00 };
|
||||
|
||||
file.WriteFile(Header, 2);
|
||||
|
||||
for (std::vector<std::wstring>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
BYTE Header[2] = {0xff, 0xfe};
|
||||
BYTE EndLine[4] = {0x0d, 0x00, 0x0a, 0x00};
|
||||
|
||||
file.WriteFile(Header,2);
|
||||
const wchar_t * data = (*iter).c_str();
|
||||
int size = (*iter).length();
|
||||
|
||||
for (std::vector<std::wstring>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
const wchar_t * data = (*iter).c_str();
|
||||
int size = (*iter).length();
|
||||
|
||||
if(sizeof(wchar_t) == 2)
|
||||
{
|
||||
file.WriteFile((BYTE*)data, size << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//convert Utf 32 to Utf 16
|
||||
}
|
||||
|
||||
file.WriteFile(EndLine, 4);
|
||||
m_linesCount++;
|
||||
file.WriteFile((BYTE*)data, size << 1);
|
||||
}
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
void TxtFile::writeBigEndian(const std::vector<std::wstring>& content)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(m_path))
|
||||
{
|
||||
BYTE Header[2] = {0xfe, 0xff};
|
||||
BYTE EndLine[4] = {0x00, 0x0d, 0x00, 0x0a};
|
||||
|
||||
file.WriteFile(Header,2);
|
||||
|
||||
for (std::vector<std::wstring>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
else
|
||||
{
|
||||
if(sizeof(wchar_t) == 2)
|
||||
{
|
||||
BYTE* data = (BYTE*)(*iter).c_str();
|
||||
int size = (*iter).length();
|
||||
//swap bytes
|
||||
for (long i = 0; i < size << 1; i+=2)
|
||||
{
|
||||
char v = data[i];
|
||||
data[i] = data[i+1];
|
||||
data[i+1] = v;
|
||||
}
|
||||
file.WriteFile((BYTE*)(*iter).c_str(), size << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//convert Utf 32 to Utf 16
|
||||
}
|
||||
|
||||
file.WriteFile(EndLine, 4);
|
||||
m_linesCount++;
|
||||
//convert Utf 32 to Utf 16
|
||||
}
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
void TxtFile::writeUtf8(const std::vector<std::string>& content)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(m_path))
|
||||
{
|
||||
BYTE Header[3] = {0xef ,0xbb , 0xbf};
|
||||
BYTE EndLine[2] = {0x0d ,0x0a};
|
||||
|
||||
file.WriteFile(Header,3);
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file.WriteFile((BYTE*)(*iter).c_str(), (*iter).length());
|
||||
file.WriteFile((BYTE*)EndLine, 2);
|
||||
|
||||
m_linesCount++;
|
||||
}
|
||||
file.CloseFile();
|
||||
file.WriteFile(EndLine, 4);
|
||||
m_linesCount++;
|
||||
}
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TxtFile::writeBigEndian(const std::vector<std::wstring>& content)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.CreateFileW(m_path)) return false;
|
||||
|
||||
BYTE Header[2] = {0xfe, 0xff};
|
||||
BYTE EndLine[4] = { 0x00, 0x0d, 0x00, 0x0a };
|
||||
|
||||
file.WriteFile(Header, 2);
|
||||
|
||||
for (std::vector<std::wstring>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
BYTE* data = (BYTE*)(*iter).c_str();
|
||||
int size = (*iter).length();
|
||||
//swap bytes
|
||||
for (long i = 0; i < size << 1; i += 2)
|
||||
{
|
||||
char v = data[i];
|
||||
data[i] = data[i + 1];
|
||||
data[i + 1] = v;
|
||||
}
|
||||
file.WriteFile((BYTE*)(*iter).c_str(), size << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//convert Utf 32 to Utf 16
|
||||
}
|
||||
|
||||
file.WriteFile(EndLine, 4);
|
||||
m_linesCount++;
|
||||
}
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TxtFile::writeUtf8(const std::vector<std::string>& content)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.CreateFileW(m_path)) return false;
|
||||
|
||||
BYTE Header[3] = { 0xef ,0xbb , 0xbf };
|
||||
BYTE EndLine[2] = { 0x0d ,0x0a };
|
||||
|
||||
file.WriteFile(Header, 3);
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file.WriteFile((BYTE*)(*iter).c_str(), (*iter).length());
|
||||
file.WriteFile((BYTE*)EndLine, 2);
|
||||
|
||||
m_linesCount++;
|
||||
}
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool TxtFile::isUnicode()
|
||||
|
||||
@ -48,10 +48,10 @@ public:
|
||||
const std::vector<std::wstring> readBigEndian();
|
||||
const std::vector<std::string> readUtf8();
|
||||
|
||||
void writeAnsiOrCodePage (const std::vector<std::string>& content);
|
||||
void writeUnicode (const std::vector<std::wstring>& content);
|
||||
void writeBigEndian (const std::vector<std::wstring>& content);
|
||||
void writeUtf8 (const std::vector<std::string>& content);
|
||||
bool writeAnsiOrCodePage (const std::vector<std::string>& content);
|
||||
bool writeUnicode (const std::vector<std::wstring>& content);
|
||||
bool writeBigEndian (const std::vector<std::wstring>& content);
|
||||
bool writeUtf8 (const std::vector<std::string>& content);
|
||||
|
||||
const bool isUnicode();
|
||||
const bool isBigEndian();
|
||||
|
||||
@ -121,35 +121,40 @@ _UINT32 CTxtXmlFile::txt_LoadFromFile(const std::wstring & sSrcFileName, const s
|
||||
|
||||
_UINT32 CTxtXmlFile::txt_SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcPath, const std::wstring & sXMLOptions)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
try
|
||||
{
|
||||
Docx2Txt::Converter converter;
|
||||
converter.read(sSrcPath);
|
||||
converter.convert();
|
||||
|
||||
int encoding = ParseTxtOptions(sXMLOptions);
|
||||
|
||||
if (encoding == EncodingType::Utf8)
|
||||
converter.writeUtf8(sDstFileName);
|
||||
else if (encoding == EncodingType::Unicode)
|
||||
converter.writeUnicode(sDstFileName);
|
||||
else if (encoding == EncodingType::Ansi)
|
||||
converter.writeAnsi(sDstFileName);
|
||||
else if (encoding == EncodingType::BigEndian)
|
||||
converter.writeBigEndian(sDstFileName);
|
||||
else if (encoding > 0) //code page
|
||||
result = converter.read(sSrcPath);
|
||||
if (result)
|
||||
{
|
||||
converter.write(sDstFileName);
|
||||
converter.convert();
|
||||
|
||||
int encoding = ParseTxtOptions(sXMLOptions);
|
||||
|
||||
if (encoding == EncodingType::Utf8)
|
||||
result = converter.writeUtf8(sDstFileName);
|
||||
else if (encoding == EncodingType::Unicode)
|
||||
result = converter.writeUnicode(sDstFileName);
|
||||
else if (encoding == EncodingType::Ansi)
|
||||
result = converter.writeAnsi(sDstFileName);
|
||||
else if (encoding == EncodingType::BigEndian)
|
||||
result = converter.writeBigEndian(sDstFileName);
|
||||
else if (encoding > 0) //code page
|
||||
{
|
||||
result = converter.write(sDstFileName);
|
||||
}
|
||||
else //auto define
|
||||
result = converter.write(sDstFileName);
|
||||
}
|
||||
else //auto define
|
||||
converter.write(sDstFileName);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
result = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3049,11 +3049,12 @@ namespace NExtractTools
|
||||
NSDirectory::CreateDirectory(sTempUnpackedOox);
|
||||
|
||||
_UINT32 nRes = odf_flat2oox_dir(sFrom, sTempUnpackedOox, sTemp, params);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedOox, sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = dir2zipMscrypt(sTempUnpackedOox, sTo, sTemp, params);
|
||||
}
|
||||
|
||||
return nRes;
|
||||
}
|
||||
_UINT32 odf_flat2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
@ -4897,7 +4898,8 @@ namespace NExtractTools
|
||||
|
||||
IOfficeDrawingFile* pReader = NULL;
|
||||
nRes = PdfDjvuXpsToRenderer(&pReader, &pdfWriter, sFrom, nFormatFrom, sTo, sTemp, params, pApplicationFonts, sPages);
|
||||
pdfWriter.SaveToFile(sTo);
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
nRes = S_OK == pdfWriter.SaveToFile(sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
RELEASEOBJECT(pReader);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user