Commit a51d2e11 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

x2t move to ServerComponents

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68991 954022d7-b5bf-4e40-9824-e11837661b57
parent db69c450
......@@ -7918,8 +7918,13 @@ SDK/bin/docbuilder/docbuilder_mac64 svn_mime_002dtype=application%2Foctet-stream
SDK/bin/docbuilder/docbuilder_win32.exe svn_mime_002dtype=application%2Foctet-stream
SDK/bin/docbuilder/docbuilder_win64.exe svn_mime_002dtype=application%2Foctet-stream
SDK/bin/linux svnc_tsvn_003alogminsize=5
SDK/bin/linux/CentOS6/x2t svn_mime_002dtype=application%2Foctet-stream
SDK/bin/linux/x2t svn_mime_002dtype=application%2Foctet-stream
SDK/bin/mac/x2t svn_mime_002dtype=application%2Foctet-stream
SDK/bin/windows svnc_tsvn_003alogminsize=5
SDK/bin/windows/icudt.dll svn_mime_002dtype=application%2Foctet-stream
SDK/bin/windows/x2t.exe svn_mime_002dtype=application%2Foctet-stream
SDK/bin/windows/x2t32.exe svn_mime_002dtype=application%2Foctet-stream
SDK/include svnc_tsvn_003alogminsize=5
SDK/lib svnc_tsvn_003alogminsize=5
SDK/lib/ios svnc_tsvn_003alogminsize=5
......@@ -9288,6 +9293,37 @@ UnicodeConverter/test/testfiles/32_utf8.txt svn_mime_002dtype=application%2Focte
UnicodeConverter/test/testfiles/41_utf8.txt svn_mime_002dtype=application%2Foctet-stream
UnicodeConverter/test/testfiles/42_utf8.txt svn_mime_002dtype=application%2Foctet-stream
UnicodeConverter/test/testfiles/43_utf8.txt svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestIOSX2tConverter svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/project.xcworkspace svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/project.xcworkspace/xcuserdata svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/project.xcworkspace/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/project.xcworkspace/xcuserdata/alexey.musinov.xcuserdatad/UserInterfaceState.xcuserstate svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/xcuserdata svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad/xcschemes svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/Base.lproj svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/Demo-Hayden-Management-v2.docx svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/Images.xcassets svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/Images.xcassets/AppIcon.appiconset svnc_tsvn_003alogminsize=5
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/price.xlsx svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/shapes.xlsx svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestIOSX2tConverter/TestIOSX2tConverter/smeta.xlsx svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestMacX2tConverter svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/project.xcworkspace svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/project.xcworkspace/xcuserdata svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/project.xcworkspace/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/project.xcworkspace/xcuserdata/alexey.musinov.xcuserdatad/UserInterfaceState.xcuserstate svn_mime_002dtype=application%2Foctet-stream
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/xcuserdata svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad/xcdebugger svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad/xcschemes svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter/Base.lproj svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter/Images.xcassets svnc_tsvn_003alogminsize=5
X2tConverter/test/TestMacX2tConverter/TestMacX2tConverter/Images.xcassets/AppIcon.appiconset svnc_tsvn_003alogminsize=5
/XpsFile svnc_tsvn_003alogminsize=5
XpsFile/XpsFileTest svnc_tsvn_003alogminsize=5
XpsFile/XpsLib svnc_tsvn_003alogminsize=5
#-------------------------------------------------
#
# Project created by QtCreator 2014-10-03T18:30:31
#
#-------------------------------------------------
QT -= core
QT -= gui
VERSION = 2.0.2.355
DEFINES += INTVER=$$VERSION
mac {
message(64 bit)
TARGET = x2t
} else {
contains(QMAKE_HOST.arch, x86_64):{
#64bit
message(64 bit)
TARGET = x2t
}
!contains(QMAKE_HOST.arch, x86_64):{
#32bit
message(32 bit)
TARGET = x2t32
}
}
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
win32 {
QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
QMAKE_LFLAGS += /INCREMENTAL:NO
contains(QMAKE_TARGET.arch, x86_64):{
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.02
} else {
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.01
}
} else {
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wno-ignored-qualifiers
}
CONFIG += c++11
#CONFIG += static_link_libstd
static_link_libstd {
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
}
#CONFIG += build_for_centos6
build_for_centos6 {
QMAKE_LFLAGS += -Wl,--dynamic-linker=./ld-linux-x86-64.so.2
}
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
PPTX_DEF\
PPT_DEF\
ENABLE_PPT_TO_PPTX_CONVERT\
NODOCX \
#DISABLE_FILE_DOWNLOADER \
FILTER_FLATE_DECODE_ENABLED \
CXIMAGE_DONT_DECLARE_TCHAR \
BUILD_CONFIG_FULL_VERSION \
DONT_WRITE_EMBEDDED_FONTS \
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML
DEFINES += PDFREADER_USE_DYNAMIC_LIBRARY
DEFINES += PDFWRITER_USE_DYNAMIC_LIBRARY
DEFINES += XPS_USE_DYNAMIC_LIBRARY
DEFINES += DJVU_USE_DYNAMIC_LIBRARY
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY
DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY
#################### WINDOWS #####################
win32 {
DEFINES += \
LIBXML_READER_ENABLED
INCLUDEPATH += ../../../Common/DocxFormat/Source/XML/libxml2/XML/include\
INCLUDEPATH += ../../../ASCOfficeUtils/ZLIB/zlib-1.2.3
}
#################### WINDOWS #####################
#################### LINUX ########################
linux-g++ | linux-g++-64 | linux-g++-32 {
DEFINES += \
LINUX \
_LINUX \
_LINUX_QT
INCLUDEPATH += /usr/include/libxml2
}
mac {
DEFINES += \
LINUX \
_LINUX \
_LINUX_QT \
_MAC \
MAC \
LIBXML_READER_ENABLED
INCLUDEPATH += ../../../Common/DocxFormat/Source/XML/libxml2/XML/include\
INCLUDEPATH += ../../../ASCOfficeUtils/ZLIB/zlib-1.2.3
}
#################### LINUX ########################
INCLUDEPATH += \
../../../DesktopEditor/freetype-2.5.2/include
INCLUDEPATH += $$PWD/../../../Common/DocxFormat
DEPENDPATH += $$PWD/../../../Common/DocxFormat
INCLUDEPATH += $$PWD/../../../ASCOfficePPTXFile/
DEPENDPATH += $$PWD/../../../ASCOfficePPTXFile/
INCLUDEPATH += $$PWD/../../../ASCOfficePPTXFile/Editor/
DEPENDPATH += $$PWD/../../../ASCOfficePPTXFile/Editor/
INCLUDEPATH += $$PWD/../../../ASCOfficeUtils/ASCOfficeUtils
DEPENDPATH += $$PWD/../../../ASCOfficeUtils/ASCOfficeUtils
INCLUDEPATH += $$PWD/../../../ASCOfficeDocxFile2
DEPENDPATH += $$PWD/../../../ASCOfficeDocxFile2
##############################################################################################################
SOURCES += ../../src/main.cpp \
../../src/cextracttools.cpp \
../../../Common/OfficeFileFormatChecker2.cpp \
../../src/ASCConverters.cpp
HEADERS += ../../src/cextracttools.h \
../../../Common/OfficeFileFormatChecker.h \
../../src/ASCConverters.h
###############################################################################################################
############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../../../SDK/lib
DESTINATION_BIN_PATH = $$PWD/../../../SDK/bin
win32:contains(QMAKE_TARGET.arch, x86_64):{
message(win64)
DESTINATION_BIN_PATH = $$DESTINATION_BIN_PATH/windows
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64/DEBUG
} else {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64
}
}
win32:!contains(QMAKE_TARGET.arch, x86_64):{
message(win32)
DESTINATION_BIN_PATH = $$DESTINATION_BIN_PATH/windows
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32/DEBUG
} else {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32
}
}
linux-g++ | linux-g++-64 | linux-g++-32:contains(QMAKE_HOST.arch, x86_64):{
message(linuX)
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_64
DESTINATION_BIN_PATH = $$DESTINATION_BIN_PATH/linux
LIBS += $$PWD/../../../UnicodeConverter/icubuilds/linux64/usr/local/lib/libicuuc.so.55
LIBS += $$PWD/../../../UnicodeConverter/icubuilds/linux64/usr/local/lib/libicudata.so.55
}
linux-g++ | linux-g++-64 | linux-g++-32:!contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_32
DESTINATION_BIN_PATH = $$DESTINATION_BIN_PATH/linux
}
mac {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/mac_64
DESTINATION_BIN_PATH = $$DESTINATION_BIN_PATH/mac
}
DESTDIR = $$DESTINATION_BIN_PATH
############### destination path ###############
message(destination sdk path = $$DESTINATION_SDK_PATH)
CONFIG(debug, debug|release) {
message(Debug)
BOOST_LIBNAME_POSTFIX = -gd
} else {
message(Release)
}
#Xls file
LIBS += -L$$DESTINATION_SDK_PATH -lXlsFormatLib
# odf format writer
LIBS += -L$$DESTINATION_SDK_PATH -lOdfFileWriterLib
# odf format reader
LIBS += -L$$DESTINATION_SDK_PATH -lOdfFileReaderLib
#doc file
LIBS += -L$$DESTINATION_SDK_PATH -lDocFormatLib
# ppt file
LIBS += -L$$DESTINATION_SDK_PATH -lPptFormatLib
#rtf file
LIBS += -L$$DESTINATION_SDK_PATH -lRtfFormatLib
#txt(xml) file
LIBS += -L$$DESTINATION_SDK_PATH -lTxtXmlFormatLib
# pdf writer
LIBS += -L$$DESTINATION_SDK_PATH -lPdfWriter
#docxfile2
LIBS += -L$$DESTINATION_SDK_PATH -lASCOfficeDocxFile2Lib
#pptxformat
LIBS += -L$$DESTINATION_SDK_PATH -lPPTXFormatLib
#docxformat
LIBS += -L$$DESTINATION_SDK_PATH -lDocxFormatLib
#office utils
LIBS += -L$$DESTINATION_SDK_PATH -lOfficeUtils
#graphics
LIBS += -L$$DESTINATION_SDK_PATH -lgraphics
#doctrenderer
LIBS += -L$$DESTINATION_SDK_PATH -ldoctrenderer
#HtmlRenderer
LIBS += -L$$DESTINATION_SDK_PATH -lHtmlRenderer
LIBS += -L$$DESTINATION_SDK_PATH -lPdfReader
LIBS += -L$$DESTINATION_SDK_PATH -lDjVuFile
LIBS += -L$$DESTINATION_SDK_PATH -lXpsFile
#HtmlFile
LIBS += -L$$DESTINATION_SDK_PATH -lHtmlFile
#UnicodeConverter
LIBS += -L$$DESTINATION_SDK_PATH -lUnicodeConverter
#####################################################
# внешнее подключение сторонних библиотек
win32 {
LIBS += -lurlmon
LIBS += -LC:\boost_1_58_0\stage\lib -llibboost_regex-vc120-mt$$BOOST_LIBNAME_POSTFIX-1_58
}
linux-g++ | linux-g++-64 | linux-g++-32 {
LIBS += -lboost_regex
LIBS += -lz
LIBS += -lxml2
LIBS += -lcurl
}
mac {
LIBS += -L$$PWD/../../../Common/boost_1_58_0/stage/lib -lboost_regex
LIBS += -L$$DESTINATION_SDK_PATH -llibxml
LIBS += -framework AppKit
}
########################################################
TEMPLATE = subdirs
CONFIG -= debug_and_release debug_and_release_target
# важно!!! build directory должна быть на уровне выше, чтобы Makefile и $$PWD были на одном уровне к ServerComponents
SUBDIRS = \
OfficeUtils \
graphics \
DocxFormatLib \
PPTXFormatLib \
ASCOfficeDocxFile2Lib \
TxtXmlFormatLib \
RtfFormatLib \
PptFormatLib \
DocFormatLib \
OdfFileReaderLib \
OdfFileWriterLib \
XlsFormatLib \
X2tConverter
OfficeUtils.file = ../../../OfficeUtils/OfficeUtils.pro
graphics.file = ../../../DesktopEditor/Qt_build/graphics/project/graphics.pro
DocxFormatLib.file = ../../../Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro
PPTXFormatLib.file = ../../../ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro
ASCOfficeDocxFile2Lib.file = ../../../ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro
TxtXmlFormatLib.file = ../../../ASCOfficeTxtFile/TxtXmlFormatLib/Linux/TxtXmlFormatLib.pro
RtfFormatLib.file = ../../../ASCOfficeRtfFile/RtfFormatLib/Linux/RtfFormatLib.pro
PptFormatLib.file = ../../../ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro
DocFormatLib.file = ../../../ASCOfficeDocFile/DocFormatLib/Linux/DocFormatLib.pro
OdfFileReaderLib.file = ../../../ASCOfficeOdfFile/linux/OdfFileReaderLib.pro
OdfFileWriterLib.file = ../../../ASCOfficeOdfFileW/linux/OdfFileWriterLib.pro
XlsFormatLib.file = ../../../ASCOfficeXlsFile2/source/linux/XlsFormatLib.pro
X2tConverter.file = ./X2tConverter.pro
X2tConverter.depends = \
OfficeUtils \
graphics \
DocxFormatLib \
PPTXFormatLib \
ASCOfficeDocxFile2Lib \
TxtXmlFormatLib \
RtfFormatLib \
PptFormatLib \
DocFormatLib \
OdfFileReaderLib \
OdfFileWriterLib \
XlsFormatLib
############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../../../SDK/lib
DESTINATION_ICU = $$PWD/../../../UnicodeConverter/icubuilds
win32:contains(QMAKE_TARGET.arch, x86_64):{
DESTINATION_ICU = $$DESTINATION_ICU/win64/bin
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64/DEBUG
} else {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64
}
}
win32:!contains(QMAKE_TARGET.arch, x86_64):{
DESTINATION_ICU = $$DESTINATION_ICU/win32/bin
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32/DEBUG
} else {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32
}
}
linux-g++ | linux-g++-64 | linux-g++-32:contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_ICU = $$DESTINATION_ICU/linux64/usr/local/lib
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_64
}
linux-g++ | linux-g++-64 | linux-g++-32:!contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_32
}
mac {
DESTINATION_ICU = $$DESTINATION_ICU/icubuilds/mac/build_release-55-1/lib
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/mac_64
}
LIBS += -L$$DESTINATION_SDK_PATH
LIBS += -L$$DESTINATION_ICU
################################################

#include "ASCConverters.h"
//todo убрать ошибки компиляции если переместить include ниже
#include "../../../ServerComponents/PdfWriter/OnlineOfficeBinToPdf.h"
#include "cextracttools.h"
#include "../../../ServerComponents/DesktopEditor/common/Path.h"
#include "../../../ServerComponents/DesktopEditor/common/Directory.h"
#include "../../../ServerComponents/ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
#include "../../../ServerComponents/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h"
#include "../../../ServerComponents/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h"
#include "../../../ServerComponents/ASCOfficePPTXFile/ASCOfficePPTXFile.h"
#include "../../../ServerComponents/ASCOfficeRtfFile/RtfFormatLib/source/ConvertationManager.h"
#include "../../../ServerComponents/ASCOfficeRtfFile/RtfFormatLib/source/ConvertationManager.h"
#include "../../../ServerComponents/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h"
#include "../../../ServerComponents/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.h"
#include "../../../ServerComponents/ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h"
#include "../../../ServerComponents/ASCOfficeOdfFile/src/ConvertOO2OOX.h"
#include "../../../ServerComponents/ASCOfficeOdfFileW/source/Oox2OdfConverter/Oox2OdfConverter.h"
#include "../../../ServerComponents/DesktopEditor/doctrenderer/doctrenderer.h"
#include "../../../ServerComponents/DesktopEditor/fontengine/ApplicationFonts.h"
#include "../../../ServerComponents/PdfReader/PdfReader.h"
#include "../../../ServerComponents/DjVuFile/DjVu.h"
#include "../../../ServerComponents/XpsFile/XpsFile.h"
#include "../../../ServerComponents/HtmlRenderer/include/HTMLRenderer3.h"
#include "../../../ServerComponents/HtmlFile/HtmlFile.h"
#include "../../../ServerComponents/ASCOfficeXlsFile2/source/XlsXlsxConverter/ConvertXls2Xlsx.h"
#include <iostream>
#include <fstream>
namespace NExtractTools
{
void initApplicationFonts(CApplicationFonts& oApplicationFonts, const std::wstring &sFontPath)
{
if(sFontPath.empty())
oApplicationFonts.Initialize();
else
oApplicationFonts.InitializeFromFolder(sFontPath);
}
// docx -> bin
int docx2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
// Extract docx to temp directory
std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedDOCX);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedDOCX, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return docx_dir2doct_bin(sTempUnpackedDOCX, sTo, sFontPath);
}
int docx_dir2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sFontPath)
{
// Save to file (from temp dir)
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
//bool bRes = m_oCDocxSerializer.saveToFile (sResDoct, sSrcDocx, sTemp);
CString sXmlOptions;
int nRes = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sFrom), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
// sleep(3*60);
return nRes;
}
// docx -> doct
int docx2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
// Extract docx to temp directory
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultDoctDir);
int nRes = docx2doct_bin(sFrom, sResultDoctFileEditor, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// bin -> docx
int doct_bin2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
nRes = doct_bin2docx_dir(sFrom, sTo, sResultDocxDir, sFontPath, bFromChanges, sThemeDir, params);
if (SUCCEEDED_X2T(nRes))
{
// compress
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultDocxDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// bin -> docx dir
int doct_bin2docx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sToDir, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
std::wstring sTargetBin;
if(bFromChanges)
nRes = apply_changes(sFrom, sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT, sFontPath, sThemeDir, sTargetBin, params);
else
sTargetBin = sFrom;
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions = _T("");
CString sThemePath; // will be filled by 'CreateDocxFolders' method
CString sMediaPath; // will be filled by 'CreateDocxFolders' method
CString sEmbedPath; // will be filled by 'CreateDocxFolders' method
CString sToDir2 = std_string2string(sToDir);
m_oCDocxSerializer.CreateDocxFolders (sToDir2, sThemePath, sMediaPath, sEmbedPath);
if (SUCCEEDED_X2T(nRes))
{
nRes = m_oCDocxSerializer.loadFromFile (std_string2string(sTargetBin), sToDir2, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
//удаляем EditorWithChanges, потому что он не в Temp
if (sFrom != sTargetBin)
NSFile::CFileBinary::Remove(sTargetBin);
return nRes;
}
// doct -> docx
int doct2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
// Extract docx to temp directory
std::wstring sTempUnpackedDOCT = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sTempDoctFileEditor = sTempUnpackedDOCT + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedDOCT);
// unzip doct to folder
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedDOCT, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return doct_bin2docx(sTempDoctFileEditor, sTo, sTemp, sFontPath, bFromChanges, sThemeDir, params);
}
// xslx -> bin
int xlsx2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions)
{
// Extract xlsx to temp directory
std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedXLSX, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return xlsx_dir2xlst_bin(sTempUnpackedXLSX, sTo, sFontPath, sXmlOptions);
}
int xlsx_dir2xlst_bin (const std::wstring &sXlsxDir, const std::wstring &sTo, const std::wstring &sFontPath, const std::wstring &sXmlOptions)
{
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sTo1 = std_string2string(sTo);
return m_oCXlsxSerializer.saveToFile (sTo1, std_string2string(sXlsxDir), std_string2string(sXmlOptions)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// xslx -> xslt
int xlsx2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions)
{
// Extract xlsx to temp directory
std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultXlstDir);
int nRes = xlsx2xlst_bin(sFrom, sResultXlstFileEditor, sTemp, sFontPath, sXmlOptions);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultXlstDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// bin -> xslx
int xlst_bin2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
// Extract xlsx to temp directory
std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
FileSystem::Directory::CreateDirectory(sResultXlsxDir);
nRes = xlst_bin2xlsx_dir(sFrom, sTo, sResultXlsxDir, sFontPath, bFromChanges, sThemeDir, params);
if (SUCCEEDED_X2T(nRes))
{
// compress
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultXlsxDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
int xlst_bin2xlsx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
std::wstring sTargetBin;
if(bFromChanges)
nRes = apply_changes(sFrom, sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile::XLST, sFontPath, sThemeDir, sTargetBin, params);
else
sTargetBin = sFrom;
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sXmlOptions = _T("");
CString sMediaPath; // will be filled by 'CreateXlsxFolders' method
CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method
m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions, std_string2string(sTo), sMediaPath, sEmbedPath);
if(SUCCEEDED_X2T(nRes))
{
nRes = m_oCXlsxSerializer.loadFromFile (std_string2string(sTargetBin), std_string2string(sTo), sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
//удаляем EditorWithChanges, потому что он не в Temp
if (sFrom != sTargetBin)
NSFile::CFileBinary::Remove(sTargetBin);
return nRes;
}
// xslt -> xslx
int xlst2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
// Extract xlsx to temp directory
std::wstring sTempUnpackedXLST = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sTempXlstFileEditor = sTempUnpackedXLST + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedXLST);
// unzip xlst to folder
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedXLST, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return xlst_bin2xlsx(sTempXlstFileEditor, sTo, sTemp, sFontPath, bFromChanges, sThemeDir, params);
}
// pptx -> bin
int pptx2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
// unzip pptx to temp folder
std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked")+ FILE_SEPARATOR_STR; // leading slash is very important!
FileSystem::Directory::CreateDirectory(sTempUnpackedPPTX);
// unzip pptx to folder
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedPPTX, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return pptx_dir2pptt_bin(sTempUnpackedPPTX, sTo, sFontPath);
}
int pptx_dir2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sFontPath)
{
// convert unzipped pptx to unzipped pptt
CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
int nRes = 0;
if (pptx_file)
{
#if defined(_WIN32) || defined (_WIN64)
BSTR bstrFontPath = SysAllocString(sFontPath.c_str());
BSTR bstrTempUnpackedPPTX = SysAllocString(sFrom.c_str());
BSTR bstrTo = SysAllocString(sTo.c_str());
pptx_file->SetFontDir (bstrFontPath);
nRes = (S_OK == pptx_file->OpenFileToPPTY (bstrTempUnpackedPPTX, bstrTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
SysFreeString(bstrFontPath);
SysFreeString(bstrTempUnpackedPPTX);
SysFreeString(bstrTo);
#else
pptx_file->SetFontDir (sFontPath);
nRes = (S_OK == pptx_file->OpenFileToPPTY (sFrom, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
#endif
delete pptx_file;
}
return nRes;
}
// pptx -> pptt
int pptx2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked");
std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultPpttDir);
int nRes = pptx2pptt_bin(sFrom, sTempPpttFileEditor, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
// zip pptt folder to output file
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultPpttDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// bin -> pptx
int pptt_bin2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
std::wstring sResultPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked");
FileSystem::Directory::CreateDirectory(sResultPptxDir);
nRes = pptt_bin2pptx_dir(sFrom, sTo, sResultPptxDir, sFontPath, bFromChanges, sThemeDir, params);
if (!SUCCEEDED_X2T(nRes))
return nRes;
// zip pptx folder to output file
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultPptxDir,sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
return nRes;
}
int pptt_bin2pptx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
std::wstring sTargetBin;
if(bFromChanges)
nRes = apply_changes(sFrom, sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile::PPTT, sFontPath, sThemeDir, sTargetBin, params);
else
sTargetBin = sFrom;
CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
HRESULT hr = S_OK;
if (pptx_file)
{
#if defined(_WIN32) || defined (_WIN64)
BSTR bstrFontPath = SysAllocString(sFontPath.c_str());
BSTR bstrTargetBin = SysAllocString(sTargetBin.c_str());
BSTR bstrResultPptxDir = SysAllocString(sTo.c_str());
BSTR bstrThemeDir = SysAllocString(sThemeDir.c_str());
pptx_file->SetFontDir (bstrFontPath);
nRes = (S_OK == pptx_file->ConvertPPTYToPPTX(bstrTargetBin, bstrResultPptxDir, bstrThemeDir)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
SysFreeString(bstrFontPath);
SysFreeString(bstrTargetBin);
SysFreeString(bstrResultPptxDir);
SysFreeString(bstrThemeDir);
#else
pptx_file->SetFontDir(sFontPath);
nRes = (S_OK == pptx_file->ConvertPPTYToPPTX(sTargetBin, sTo, sThemeDir)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
#endif
delete pptx_file;
}
//удаляем EditorWithChanges, потому что он не в Temp
if (sFrom != sTargetBin)
NSFile::CFileBinary::Remove(sTargetBin);
return nRes;
}
// pptt -> pptx
int pptt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
// unzip pptt to temp folder
std::wstring sTempUnpackedPPTT = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked");
std::wstring sTempPpttFileEditor = sTempUnpackedPPTT + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedPPTT);
// unzip pptt to folder
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedPPTT, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return pptt_bin2pptx(sTempPpttFileEditor, sTo, sTemp, sFontPath, bFromChanges, sThemeDir, params);
}
// zip dir
int dir2zip (const std::wstring &sFrom, const std::wstring &sTo)
{
COfficeUtils oCOfficeUtils(NULL);
return (S_OK == oCOfficeUtils.CompressFileOrDirectory(sFrom, sTo, -1)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// unzip dir
int zip2dir (const std::wstring &sFrom, const std::wstring &sTo)
{
COfficeUtils oCOfficeUtils(NULL);
return (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTo, NULL, 0)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// csv -> xslt
int csv2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & XmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath)
{
CString sCSV = std_string2string(sFrom);
std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultXlstDir);
COfficeUtils oCOfficeUtils(NULL);
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sXmlOptions = std_string2string(XmlOptions);
int nRes = m_oCXlsxSerializer.saveToFile (std_string2string(sResultXlstFileEditor), sCSV, sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if (SUCCEEDED_X2T(nRes))
{
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultXlstDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// csv -> xslx
int csv2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & XmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath)
{
CString sCSV = std_string2string(sFrom);
std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX);
FileSystem::Directory::CreateDirectory(sResultXlstDir);
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
COfficeUtils oCOfficeUtils(NULL);
CString sXMLOptions = std_string2string(XmlOptions);
CString sMediaPath;
CString sEmbedPath;
int nRes = m_oCXlsxSerializer.saveToFile (std_string2string(sResultXlstFileEditor), sCSV, sXMLOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if (SUCCEEDED_X2T(nRes))
{
sXMLOptions = _T("");
nRes = m_oCXlsxSerializer.loadFromFile(std_string2string(sResultXlstFileEditor), std_string2string(sTempUnpackedXLSX), sXMLOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
if (SUCCEEDED_X2T(nRes))
{
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedXLSX, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
}
return nRes;
}
int csv2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & XmlOptions, const std::wstring &sFontPath)
{
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sXmlOptions = std_string2string(XmlOptions);
return m_oCXlsxSerializer.saveToFile(std_string2string(sTo), std_string2string(sFrom), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// xlst -> csv
int xlst2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath)
{
CString sCSV = std_string2string(sTo);
std::wstring sTempUnpackedXLST = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sTempXlstFileEditor = sTempUnpackedXLST + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedXLST);
// unzip xlst to folder
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedXLST, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sMediaPath;
CString sEmbedPath;
return m_oCXlsxSerializer.loadFromFile (std_string2string(sTempXlstFileEditor), sCSV, std_string2string(sXmlOptions), sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// xslx -> csv
int xlsx2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath)
{
CString sCSV = std_string2string(sTo);
std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX);
FileSystem::Directory::CreateDirectory(sResultXlstDir);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedXLSX, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sXMLOptions = _T("");
int nRes = m_oCXlsxSerializer.saveToFile (std_string2string(sResultXlstFileEditor), std_string2string(sTempUnpackedXLSX), sXMLOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if (SUCCEEDED_X2T(nRes))
{
CString sMediaPath;
CString sEmbedPath;
nRes = m_oCXlsxSerializer.loadFromFile (std_string2string(sResultXlstDir), sCSV, sXMLOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
int xlst_bin2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sThemeDir, bool bFromChanges, const InputParams& params)
{
int nRes = 0;
std::wstring sTargetBin;
if(bFromChanges)
nRes = apply_changes(sFrom, sTo, NSDoctRenderer::DoctRendererFormat::FormatFile::XLST, sFontPath, sThemeDir, sTargetBin, params);
else
sTargetBin = sFrom;
if(SUCCEEDED_X2T(nRes))
{
//todo сделать отдельный метод для сохранения в csv
// Save to file (from temp dir)
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sXmlOptions1 = std_string2string(sXmlOptions);
std::wstring sToTemp = sTemp + FILE_SEPARATOR_STR + _T("output.csv");
CString sMediaPath; // will be filled by 'CreateXlsxFolders' method
CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method
m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions1, std_string2string(sTemp), sMediaPath, sEmbedPath);
nRes = m_oCXlsxSerializer.loadFromFile(std_string2string(sTargetBin), std_string2string(sToTemp), std_string2string(sXmlOptions), sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
//пишем в Temp и копируем, чтобы не возникало лишних файлов рядом с sTo, а лучше перейти на отдельный метод
if(SUCCEEDED_X2T(nRes))
{
NSFile::CFileBinary::Copy(sToTemp, sTo);
}
}
return nRes;
}
// bin -> pdf
int bin2pdf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bPaid, const std::wstring &sThemeDir)
{
CApplicationFonts oApplicationFonts;
initApplicationFonts(oApplicationFonts, sFontPath);
CPdfRenderer pdfWriter(&oApplicationFonts);
pdfWriter.SetTempFolder(sTemp);
pdfWriter.SetThemesPlace(sThemeDir);
int nReg = (bPaid == false) ? 0 : 1;
return S_OK == pdfWriter.OnlineWordToPdf(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
//doct_bin -> pdf
int doct_bin2pdf(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bPaid, const std::wstring &sThemeDir, const std::wstring &sXmlOptions, const InputParams& params)
{
int nRes = 0;
NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF;
std::wstring sTFileDir = FileSystem::Directory::GetFolderPath(sFrom);
std::wstring sImagesDirectory = sTFileDir + FILE_SEPARATOR_STR + _T("media");
std::wstring sPdfBinFile = sTFileDir + FILE_SEPARATOR_STR + _T("pdf.bin");
NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T(""));
std::wstring sXml = getDoctXml(eFromType, eToType, sTFileDir, sPdfBinFile, sFontPath, sImagesDirectory, sThemeDir, -1, _T(""), params);
std::wstring sResult;
bool bRes = oDoctRenderer.Execute(sXml, sResult);
if (-1 != sResult.find(_T("error")))
{
std::wcerr << _T("DoctRenderer:") << sResult << std::endl;
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else
{
CApplicationFonts oApplicationFonts;
initApplicationFonts(oApplicationFonts, sFontPath);
CPdfRenderer pdfWriter(&oApplicationFonts);
pdfWriter.SetTempFolder(sTemp);
pdfWriter.SetThemesPlace(sThemeDir);
int nReg = (bPaid == false) ? 0 : 1;
nRes = (S_OK == pdfWriter.OnlineWordToPdfFromBinary(sPdfBinFile, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
//удаляем sPdfBinFile, потому что он не в Temp
if (NSFile::CFileBinary::Exists(sPdfBinFile))
NSFile::CFileBinary::Remove(sPdfBinFile);
return nRes;
}
// ppsx -> pptx
int ppsx2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
std::wstring sTempUnpackedPPSX = sTemp + FILE_SEPARATOR_STR + _T("ppsx_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedPPSX);
int nRes = ppsx2pptx_dir(sFrom, sTempUnpackedPPSX);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedPPSX, sTo, -1))
return 0;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int ppsx2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo)
{
COfficeUtils oCOfficeUtils(NULL);
if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTo, NULL, 0))
{
std::wstring sContentTypesPath = sTo + FILE_SEPARATOR_STR + _T("[Content_Types].xml");
if(NSFile::CFileBinary::Exists(sContentTypesPath))
{
std::wstring sData;
if(NSFile::CFileBinary::ReadAllTextUtf8(sContentTypesPath, sData))
{
std::wstring sCTFrom = _T("application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml");
std::wstring sCTTo = _T("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml");
sData = string_replaceAll(sData, sCTFrom, sCTTo);
if(NSFile::CFileBinary::SaveToFile(sContentTypesPath, sData, true))
{
return 0;
}
}
}
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
// ppt -> pptx
int ppt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
std::wstring sResultPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked");
FileSystem::Directory::CreateDirectory(sResultPptxDir);
int nRes = ppt2pptx_dir(sFrom, sResultPptxDir, sTemp);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultPptxDir, sTo, -1))
return 0;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
COfficePPTFile pptFile;
pptFile.put_TempDirectory(sTemp);
return S_OK == pptFile.LoadFromFile(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// ppt -> pptt
int ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked");
std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultPpttDir);
int nRes = ppt2pptt_bin(sFrom, sTempPpttFileEditor, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
// zip pptt folder to output file
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory (sResultPpttDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// ppt -> pptt_bin
int ppt2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
// unzip pptx to temp folder
std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked")+ FILE_SEPARATOR_STR; // leading slash is very important!
FileSystem::Directory::CreateDirectory(sTempUnpackedPPTX);
COfficePPTFile pptFile;
pptFile.put_TempDirectory(sTemp);
if ( pptFile.LoadFromFile(sFrom, sTempUnpackedPPTX) != S_OK) return AVS_FILEUTILS_ERROR_CONVERT;
// convert unzipped pptx to unzipped pptt
CPPTXFile *pptx_file = new CPPTXFile(NULL, NULL, NULL, NULL);
int nRes = 0;
if (pptx_file)
{
#if defined(_WIN32) || defined (_WIN64)
BSTR bstrFontPath = SysAllocString(sFontPath.c_str());
BSTR bstrTempUnpackedPPTX = SysAllocString(sTempUnpackedPPTX.c_str());
BSTR bstrTo = SysAllocString(sTo.c_str());
pptx_file->SetFontDir (bstrFontPath);
nRes = (S_OK == pptx_file->OpenFileToPPTY (bstrTempUnpackedPPTX, bstrTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
SysFreeString(bstrFontPath);
SysFreeString(bstrTempUnpackedPPTX);
SysFreeString(bstrTo);
#else
pptx_file->SetFontDir (sFontPath);
nRes = (S_OK == pptx_file->OpenFileToPPTY (sTempUnpackedPPTX, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
#endif
delete pptx_file;
}
return nRes;
}
// rtf -> docx
int rtf2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
int nRes = rtf2docx_dir(sFrom, sResultDocxDir, sTemp);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDocxDir, sTo, -1))
return 0;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int rtf2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
RtfConvertationManager rtfConvert;
rtfConvert.m_sTempFolder = sTemp;
return S_OK == rtfConvert.ConvertRtfToOOX(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// rtf -> doct
int rtf2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
// Extract docx to temp directory
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultDoctDir);
int nRes = rtf2doct_bin(sFrom, sResultDoctFileEditor, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// rtf -> doct_bin
int rtf2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
RtfConvertationManager rtfConvert;
rtfConvert.m_sTempFolder = sTemp;
if ( rtfConvert.ConvertRtfToOOX(sFrom, sResultDocxDir) == S_OK)
{
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions;
int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sResultDocxDir), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return res;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
// docx -> rtf
int docx2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedDOCX);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedDOCX, NULL, 0))
{
return docx_dir2rtf(sTempUnpackedDOCX, sTo, sTemp);
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int docx_dir2rtf(const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp)
{
//docx folder to rtf
RtfConvertationManager rtfConvert;
rtfConvert.m_sTempFolder = sTemp;
if (rtfConvert.ConvertOOXToRtf(sTo, sDocxDir) == S_OK)
return 0;
return AVS_FILEUTILS_ERROR_CONVERT;
}
// doc -> docx
int doc2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
int nRes = doc2docx_dir(sFrom, sResultDocxDir, sTemp);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDocxDir, sTo, -1))
return 0;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int doc2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
COfficeDocFile docFile;
docFile.put_TempDirectory(sTemp);
return S_OK == docFile.LoadFromFile( sFrom, sTo, NULL) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// doc -> doct
int doc2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
// Extract docx to temp directory
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultDoctDir);
int nRes = doc2doct_bin(sFrom, sResultDoctFileEditor, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// doc -> doct_bin
int doc2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
COfficeDocFile docFile;
docFile.put_TempDirectory(sTemp);
if (docFile.LoadFromFile( sFrom, sResultDocxDir, NULL)== S_OK)
{
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions;
int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sResultDocxDir), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return res;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int docx_dir2doc (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
return AVS_FILEUTILS_ERROR_CONVERT;
COfficeDocFile docFile;
docFile.put_TempDirectory(sTemp);
return S_OK == docFile.SaveToFile(sTo, sDocxDir, NULL) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// doct -> rtf
int doct2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
// Extract docx to temp directory
std::wstring sTempUnpackedDOCT = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sTempDoctFileEditor = sTempUnpackedDOCT + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sTempUnpackedDOCT);
// unzip doct to folder
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedDOCT, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;
return doct_bin2rtf(sTempDoctFileEditor, sTo, sTemp, sFontPath, bFromChanges, sThemeDir, params);
}
// bin -> rtf
int doct_bin2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params)
{
int nRes = 0;
CString sResultDocxDir = std_string2string(sTemp) + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
std::wstring sTargetBin;
if(bFromChanges)
nRes = apply_changes(sFrom, _T(""), NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT, sFontPath, sThemeDir, sTargetBin, params);
else
sTargetBin = sFrom;
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions = _T("");
CString sThemePath; // will be filled by 'CreateDocxFolders' method
CString sMediaPath; // will be filled by 'CreateDocxFolders' method
CString sEmbedPath; // will be filled by 'CreateDocxFolders' method
m_oCDocxSerializer.CreateDocxFolders (sResultDocxDir, sThemePath, sMediaPath, sEmbedPath);
if (SUCCEEDED_X2T(nRes))
{
nRes = m_oCDocxSerializer.loadFromFile (std_string2string(sTargetBin), sResultDocxDir, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
if (SUCCEEDED_X2T(nRes))
{
//docx folder to rtf
RtfConvertationManager rtfConvert;
rtfConvert.m_sTempFolder = sTemp;
if (rtfConvert.ConvertOOXToRtf(sTo, string2std_string(sResultDocxDir)) == S_OK)
return 0;
}
}
//удаляем EditorWithChanges, потому что он не в Temp
if (sFrom != sTargetBin)
NSFile::CFileBinary::Remove(sTargetBin);
return nRes;
}
// txt -> docx
int txt2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
int nRes = txt2docx_dir(sFrom, sResultDocxDir, sXmlOptions, sTemp);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDocxDir, sTo, -1))
return 0;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int txt2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp)
{
CTxtXmlFile txtFile;
// txtFile.m_sTempFolder = std_string2string(sTemp);
return S_OK == txtFile.txt_LoadFromFile(sFrom, sTo, sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// txt -> doct
int txt2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath)
{
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultDoctDir);
int nRes = txt2doct_bin(sFrom, sResultDoctFileEditor, sXmlOptions, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// txt -> doct_bin
int txt2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
CTxtXmlFile txtFile;
// txtFile.m_sTempFolder = std_string2string(sTemp);
if ( txtFile.txt_LoadFromFile(sFrom, sResultDocxDir, sXmlOptions) == S_OK)
{
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions;
int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sResultDocxDir), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return res;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int docx_dir2txt (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp)
{
CTxtXmlFile txtFile;
// txtFile.m_sTempFolder = std_string2string(sTemp);
return S_OK == txtFile.txt_SaveToFile(sTo, sDocxDir, sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
int odf2oot(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath)
{
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultDoctDir);
int nRes = odf2oot_bin(sFrom, sResultDoctFileEditor, sTemp, sFontPath);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
int odf2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath)
{
std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + _T("odf_unpacked");
std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + _T("oox_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedOdf);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0))
return -3;
FileSystem::Directory::CreateDirectory(sTempUnpackedOox);
if (S_OK == ConvertOO2OOX(sTempUnpackedOdf, sTempUnpackedOox, sFontPath, false, NULL))
{
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions;
int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sTempUnpackedOox), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return res;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int odf2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath)
{
std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + _T("oox_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedOox);
int nRes = odf2oox_dir(sFrom, sTempUnpackedOox, sTemp, sFontPath);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedOox, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
int odf2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath)
{
std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + _T("odf_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedOdf);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0))
return AVS_FILEUTILS_ERROR_CONVERT;;
return S_OK == ConvertOO2OOX(sTempUnpackedOdf, sTo, sFontPath, false, NULL) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// docx -> odt
int docx2odt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath )
{
std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedDOCX);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedDOCX, NULL, 0))
{
return docx_dir2odt(sTempUnpackedDOCX, sTo, sTemp, sFontPath);
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
// docx dir -> odt
int docx_dir2odt (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath )
{
std::wstring sTempUnpackedODT = sTemp + FILE_SEPARATOR_STR + _T("odt_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedODT);
Oox2Odf::Converter converter(sDocxDir, _T("text"), sFontPath, NULL);
int nRes = 0;
try
{
converter.convert();
converter.write(sTempUnpackedODT);
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedODT, sTo, -1)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}catch(...)
{
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// xlsx -> ods
int xlsx2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath )
{
std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX);
COfficeUtils oCOfficeUtils(NULL);
if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedXLSX, NULL, 0))
{
return xlsx_dir2ods(sTempUnpackedXLSX, sTo, sTemp, sFontPath);
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int xlsx_dir2ods (const std::wstring &sXlsxDir, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath )
{
std::wstring sTempUnpackedODS = sTemp + FILE_SEPARATOR_STR + _T("ods_unpacked");
FileSystem::Directory::CreateDirectory(sTempUnpackedODS);
try
{
Oox2Odf::Converter converter(sXlsxDir, _T("spreadsheet"), sFontPath, NULL);
converter.convert();
converter.write(sTempUnpackedODS);
COfficeUtils oCOfficeUtils(NULL);
int nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedODS, sTo, -1)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return nRes;
}catch(...)
{
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
//html
int html2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const InputParams& params)
{
std::vector<std::wstring> arFiles;
arFiles.push_back(sFrom);
CHtmlFile oHtmlFile;
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
return 0 == oHtmlFile.Convert(arFiles, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
//mht
int mht2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const InputParams& params)
{
CHtmlFile oHtmlFile;
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
return 0 == oHtmlFile.ConvertMht(sFrom, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
int epub2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const InputParams& params)
{
std::wstring sEpubDir = sTemp + FILE_SEPARATOR_STR + _T("epub_unpacked");
FileSystem::Directory::CreateDirectory(sEpubDir);
int nRes = zip2dir(sFrom, sEpubDir);
if(SUCCEEDED_X2T(nRes))
{
CHtmlFile oHtmlFile;
std::wstring sMetaInfo;
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
nRes = 0 == oHtmlFile.ConvertEpub(sEpubDir, sMetaInfo, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// mailmerge
int convertmailmerge (const InputParamsMailMerge& oMailMergeSend,const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bPaid, const std::wstring &sThemeDir, const InputParams& params)
{
if(NULL == oMailMergeSend.mailFormat || NULL == oMailMergeSend.recordFrom || NULL == oMailMergeSend.recordTo)
return AVS_FILEUTILS_ERROR_CONVERT;
int nRes = 0;
std::wstring sFileFromDir = NSSystemPath::GetDirectoryName(sFrom);
std::wstring sFileToDir = NSSystemPath::GetDirectoryName(sTo);
std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR +_T("media");
NSDoctRenderer::DoctRendererFormat::FormatFile eTypeTo;
switch(*oMailMergeSend.mailFormat)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT;break;
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF;break;
case AVS_OFFICESTUDIO_FILE_OTHER_HTMLZIP:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML;break;
default:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML;break;
}
std::wstring sJsonPath = sFileFromDir + FILE_SEPARATOR_STR +_T("Editor.json");
int recordTo = *oMailMergeSend.recordFrom + 4;
if(recordTo > *oMailMergeSend.recordTo)
recordTo = *oMailMergeSend.recordTo;
NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T(""));
std::wstring sMailMergeXml = getMailMergeXml(sJsonPath, *oMailMergeSend.recordFrom, recordTo, *oMailMergeSend.to);
//посылаем выходную папку sFileFromDir, чтобы файлы лежали на одном уровне с папкой media, важно для дальнейшей конвертации в docx, pdf
std::wstring sXml = getDoctXml(NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT, eTypeTo, sFileFromDir, sFileFromDir, sFontPath, sImagesDirectory, sThemeDir, -1, sMailMergeXml, params);
std::wstring sResult;
oDoctRenderer.Execute(sXml, sResult);
if (-1 != sResult.find(_T("error")))
{
std::wcerr << _T("DoctRenderer:") << sResult << std::endl;
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else
{
nRes = AVS_FILEUTILS_ERROR_CONVERT;
XmlUtils::CXmlNode oRoot;
if(TRUE == oRoot.FromXmlString(std_string2string(sResult)))
{
XmlUtils::CXmlNode oMailMergeFields = oRoot.ReadNode(_T("MailMergeFields"));
XmlUtils::CXmlNodes oXmlNodes;
if(TRUE == oMailMergeFields.GetChilds(oXmlNodes))
{
for(int i = 0; i < oXmlNodes.GetCount(); ++i)
{
XmlUtils::CXmlNode oXmlNode;
if(oXmlNodes.GetAt(i, oXmlNode))
{
std::wstring sFilePathIn = string2std_string(oXmlNode.GetAttribute(_T("path")));
std::wstring wsFilePathInFilename = NSSystemPath::GetFileName(sFilePathIn);
std::wstring sFilePathOut = sFileToDir + FILE_SEPARATOR_STR + wsFilePathInFilename;
if (NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT == eTypeTo)
{
sFilePathOut += _T(".docx");
std::wstring sTempDocx = sTemp + FILE_SEPARATOR_STR + wsFilePathInFilename + _T("_DOCX");
FileSystem::Directory::CreateDirectory(sTempDocx);
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCDocxSerializer.setFontDir(sFontPath1);
CString sXmlOptions = _T("");
CString sThemePath; // will be filled by 'CreateDocxFolders' method
CString sMediaPath; // will be filled by 'CreateDocxFolders' method
CString sEmbedPath; // will be filled by 'CreateDocxFolders' method
m_oCDocxSerializer.CreateDocxFolders (std_string2string(sTempDocx), sThemePath, sMediaPath, sEmbedPath);
nRes = m_oCDocxSerializer.loadFromFile (std_string2string(sFilePathIn), std_string2string(sTempDocx), sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempDocx, sFilePathOut, -1)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
}
else if (NSDoctRenderer::DoctRendererFormat::FormatFile::PDF == eTypeTo)
{
sFilePathOut += _T(".pdf");
CApplicationFonts oApplicationFonts;
initApplicationFonts(oApplicationFonts, sFontPath);
CPdfRenderer pdfWriter(&oApplicationFonts);
pdfWriter.SetTempFolder(sTemp);
pdfWriter.SetThemesPlace(sThemeDir);
int nReg = (bPaid == false) ? 0 : 1;
nRes = (S_OK == pdfWriter.OnlineWordToPdfFromBinary(sFilePathIn, sFilePathOut)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
else if (NSDoctRenderer::DoctRendererFormat::FormatFile::HTML == eTypeTo)
{
sFilePathOut += _T(".html");
bool bCopy = NSFile::CFileBinary::Copy(sFilePathIn,sFilePathOut);
nRes = bCopy ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
if(0 != nRes)
break;
sResult = string_replaceAll(sResult, L"\"" + sFilePathIn + L"\"", L"\"" + NSSystemPath::GetFileName(sFilePathOut) + L"\"");
}
}
}
}
if(SUCCEEDED_X2T(nRes))
NSFile::CFileBinary::SaveToFile(sTo, sResult);
}
return nRes;
}
template<typename T>
int PdfDjvuXpsToRenderer(T& oReader, IRenderer* pRenderer, const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath)
{
int nRes = 0;
bool bResult = oReader.LoadFromFile(sFrom.c_str());
if(!bResult)
{
return AVS_FILEUTILS_ERROR_CONVERT;
}
int nPagesCount = oReader.GetPagesCount();
for (int i = 0; i < nPagesCount; ++i)
{
pRenderer->NewPage();
pRenderer->BeginCommand(c_nPageType);
double dPageDpiX, dPageDpiY;
double dWidth, dHeight;
oReader.GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
dWidth *= 25.4 / dPageDpiX;
dHeight *= 25.4 / dPageDpiY;
pRenderer->put_Width(dWidth);
pRenderer->put_Height(dHeight);
oReader.DrawPageOnRenderer(pRenderer, i, NULL);
pRenderer->EndCommand(c_nPageType);
}
return nRes;
}
int fromDocxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo))
{
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo)
{
nRes = dir2zip(sFrom, sTo);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC == nFormatTo)
{
nRes = docx_dir2doc(sFrom, sTo, sTemp, sFontPath);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT == nFormatTo)
{
nRes = docx_dir2odt(sFrom, sTo, sTemp, sFontPath);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF == nFormatTo)
{
nRes = docx_dir2rtf(sFrom, sTo, sTemp);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatTo)
{
nRes = docx_dir2txt(sFrom, sTo, sXmlOptions, sTemp);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else if(AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo)
{
nRes = docx_dir2doct_bin(sFrom, sTo, sFontPath);
}
else
{
std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
FileSystem::Directory::CreateDirectory(sDoctDir);
std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = docx_dir2doct_bin(sFrom, sTFile, sFontPath);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
return nRes;
}
int fromDoctBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY == nFormatTo)
{
std::wstring sFromDir = FileSystem::Directory::GetFolderPath(sFrom);
nRes = dir2zip(sFromDir, sTo);
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT;
nRes = doct_bin2pdf(eFromType, sFrom, sTo, sTemp, sFontPath, bPaid, sThemeDir, sXmlOptions, params);
}
else if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo))
{
std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
NSDirectory::CreateDirectory(sDocxDir);
nRes = doct_bin2docx_dir(sFrom, sTo, sDocxDir, sFontPath, bFromChanges, sThemeDir, params);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromDocxDir(sDocxDir, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
return nRes;
}
int fromDocument(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatFrom || AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom || AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatFrom)
{
if(AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo)
{
std::wstring sDoctDir = FileSystem::Directory::GetFolderPath(sTo);
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatFrom)
nRes = html2doct_dir(sFrom, sDoctDir, sTemp, params);
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom)
nRes = mht2doct_dir(sFrom, sDoctDir, sTemp, params);
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatFrom)
nRes = epub2doct_dir(sFrom, sDoctDir, sTemp, params);
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else
{
std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
FileSystem::Directory::CreateDirectory(sDoctDir);
std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatFrom)
nRes = html2doct_dir(sFrom, sDoctDir, sTemp, params);
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom)
nRes = mht2doct_dir(sFrom, sDoctDir, sTemp, params);
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatFrom)
nRes = epub2doct_dir(sFrom, sDoctDir, sTemp, params);
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
if(SUCCEEDED_X2T(nRes))
{
nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
}
else
{
std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
FileSystem::Directory::CreateDirectory(sDocxDir);
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatFrom)
{
nRes = zip2dir(sFrom, sDocxDir);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC == nFormatFrom)
{
nRes = doc2docx_dir(sFrom, sDocxDir, sTemp);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT == nFormatFrom)
{
nRes = odf2oox_dir(sFrom, sDocxDir, sTemp, sFontPath);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF == nFormatFrom)
{
nRes = rtf2docx_dir(sFrom, sDocxDir, sTemp);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom)
{
nRes = txt2docx_dir(sFrom, sDocxDir, sXmlOptions, sTemp);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
if(SUCCEEDED_X2T(nRes))
{
nRes = fromDocxDir(sDocxDir, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
return nRes;
}
int fromXlsxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(0 != (AVS_OFFICESTUDIO_FILE_SPREADSHEET & nFormatTo) && AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV != nFormatTo)
{
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatTo)
{
nRes = dir2zip(sFrom, sTo);
}
//else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatTo)
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatTo)
{
nRes = xlsx_dir2ods(sFrom, sTo, sTemp, sFontPath);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else if(AVS_OFFICESTUDIO_FILE_OTHER_JSON == nFormatTo)
{
nRes = xlsx_dir2xlst_bin(sFrom, sTo, sFontPath, sXmlOptions);
}
else if(AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatTo)
{
nRes = xlsx_dir2xlst_bin(sFrom, sTo, sFontPath, sXmlOptions);
}
else
{
std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
FileSystem::Directory::CreateDirectory(sXlstDir);
std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
nRes = xlsx_dir2xlst_bin(sFrom, sTFile, sFontPath, _T(""));
else
nRes = xlsx_dir2xlst_bin(sFrom, sTFile, sFontPath, sXmlOptions);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromXlstBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
return nRes;
}
int fromXlstBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY == nFormatTo)
{
std::wstring sFromDir = FileSystem::Directory::GetFolderPath(sFrom);
nRes = dir2zip(sFromDir, sTo);
}
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
{
nRes = xlst_bin2csv(sFrom, sTo, sXmlOptions, sTemp, sFontPath, sThemeDir, bFromChanges, params);
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::XLST;
nRes = doct_bin2pdf(eFromType, sFrom, sTo, sTemp, sFontPath, bPaid, sThemeDir, sXmlOptions, params);
}
else if(0 != (AVS_OFFICESTUDIO_FILE_SPREADSHEET & nFormatTo))
{
std::wstring sXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
NSDirectory::CreateDirectory(sXlsxDir);
nRes = xlst_bin2xlsx_dir(sFrom, sTo, sXlsxDir, sFontPath, bFromChanges, sThemeDir, params);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromXlsxDir(sXlsxDir, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
return nRes;
}
int fromSpreadsheet(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
{
if(AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatTo)
{
nRes = csv2xlst_bin(sFrom, sTo, sXmlOptions, sFontPath);
}
else
{
std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
FileSystem::Directory::CreateDirectory(sXlstDir);
std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = csv2xlst_bin(sFrom, sTFile, sXmlOptions, sFontPath);
if(SUCCEEDED_X2T(nRes))
{
//зануляем sXmlOptions чтобы, при конвертации xlst bin -> xlsx не перепутать с csv
nRes = fromXlstBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, _T(""), sThemeDir, bFromChanges, bPaid, params);
}
}
}
else
{
std::wstring sXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
FileSystem::Directory::CreateDirectory(sXlsxDir);
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatFrom)
{
nRes = zip2dir(sFrom, sXlsxDir);
}
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatFrom)
{
nRes = xls2xlsx_dir(sFrom, sXlsxDir, sTemp);
}
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatFrom)
{
nRes = odf2oox_dir(sFrom, sXlsxDir, sTemp, sFontPath);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
if(SUCCEEDED_X2T(nRes))
{
nRes = fromXlsxDir(sXlsxDir, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
return nRes;
}
int fromPptxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(0 != (AVS_OFFICESTUDIO_FILE_PRESENTATION & nFormatTo))
{
if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX == nFormatTo)
{
nRes = dir2zip(sFrom, sTo);
}
//else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT == nFormatTo)
//else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP == nFormatTo)
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else if(AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION == nFormatTo)
{
nRes = pptx_dir2pptt_bin(sFrom, sTo, sFontPath);
}
else
{
std::wstring sPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked");
FileSystem::Directory::CreateDirectory(sPpttDir);
std::wstring sTFile = sPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = pptx_dir2pptt_bin(sFrom, sTFile, sFontPath);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromPpttBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
return nRes;
}
int fromPpttBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY == nFormatTo)
{
std::wstring sFromDir = FileSystem::Directory::GetFolderPath(sFrom);
nRes = dir2zip(sFromDir, sTo);
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::PPTT;
nRes = doct_bin2pdf(eFromType, sFrom, sTo, sTemp, sFontPath, bPaid, sThemeDir, sXmlOptions, params);
}
else if(0 != (AVS_OFFICESTUDIO_FILE_PRESENTATION & nFormatTo))
{
std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked");
NSDirectory::CreateDirectory(sPptxDir);
nRes = pptt_bin2pptx_dir(sFrom, sTo, sPptxDir, sFontPath, bFromChanges, sThemeDir, params);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromPptxDir(sPptxDir, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
return nRes;
}
int fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked");
FileSystem::Directory::CreateDirectory(sPptxDir);
if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX == nFormatFrom)
{
nRes = zip2dir(sFrom, sPptxDir);
}
else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT == nFormatFrom)
{
nRes = ppt2pptx_dir(sFrom, sPptxDir, sTemp);
}
else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP == nFormatFrom)
{
nRes = odf2oox_dir(sFrom, sPptxDir, sTemp, sFontPath);
}
else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX == nFormatFrom)
{
nRes = ppsx2pptx_dir(sFrom, sPptxDir);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
if(SUCCEEDED_X2T(nRes))
{
nRes = fromPptxDir(sPptxDir, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
}
return nRes;
}
int fromT(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
if(0 != (AVS_OFFICESTUDIO_FILE_CANVAS & nFormatTo))
{
std::wstring sTDir = FileSystem::Directory::GetFolderPath(sTo);
nRes = zip2dir(sFrom, sTDir);
}
else
{
std::wstring sTDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
NSDirectory::CreateDirectory(sTDir);
std::wstring sTFile = sTDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = zip2dir(sFrom, sTDir);
if(SUCCEEDED_X2T(nRes))
{
if(AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY == nFormatFrom)
nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
else if(AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY == nFormatFrom)
nRes = fromXlstBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
else if(AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY == nFormatFrom)
nRes = fromPpttBin(sTFile, sTo, nFormatTo, sTemp, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, params);
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
}
return nRes;
}
int fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params)
{
int nRes = 0;
CApplicationFonts oApplicationFonts;
initApplicationFonts(oApplicationFonts, sFontPath);
if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
if(nFormatFrom == nFormatTo)
{
NSFile::CFileBinary::Copy(sFrom, sTo);
}
else
{
CPdfRenderer pdfWriter(&oApplicationFonts);
pdfWriter.SetTempFolder(sTemp);
if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatFrom)
{
PdfReader::CPdfReader oReader(&oApplicationFonts);
oReader.SetTempFolder(sTemp.c_str());
nRes = PdfDjvuXpsToRenderer<PdfReader::CPdfReader>(oReader, &pdfWriter, sFrom, nFormatFrom, sTo, sTemp, sFontPath);
pdfWriter.SaveToFile(sTo);
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU == nFormatFrom)
{
CDjVuFile oReader;
nRes = PdfDjvuXpsToRenderer<CDjVuFile>(oReader, &pdfWriter, sFrom, nFormatFrom, sTo, sTemp, sFontPath);
pdfWriter.SaveToFile(sTo);
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS == nFormatFrom)
{
CXpsFile oReader(&oApplicationFonts);
oReader.SetTempFolder(sTemp.c_str());
nRes = PdfDjvuXpsToRenderer<CXpsFile>(oReader, &pdfWriter, sFrom, nFormatFrom, sTo, sTemp, sFontPath);
pdfWriter.SaveToFile(sTo);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
}
else if(AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo)
{
std::wstring sToDir = NSSystemPath::GetDirectoryName(sTo);
if(!params.getDontSaveAdditional())
{
//save origin to print
std::wstring sOrigin = sToDir + FILE_SEPARATOR_STR + _T("origin");
NSFile::CFileBinary::Copy(sFrom, sOrigin);
}
NSHtmlRenderer::CASCHTMLRenderer3 oHtmlRenderer;
oHtmlRenderer.CreateOfficeFile(sToDir);
if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatFrom)
{
PdfReader::CPdfReader oReader(&oApplicationFonts);
oReader.SetTempFolder(sTemp.c_str());
nRes = PdfDjvuXpsToRenderer<PdfReader::CPdfReader>(oReader, &oHtmlRenderer, sFrom, nFormatFrom, sTo, sTemp, sFontPath);
oHtmlRenderer.CloseFile();
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU == nFormatFrom)
{
CDjVuFile oReader;
nRes = PdfDjvuXpsToRenderer<CDjVuFile>(oReader, &oHtmlRenderer, sFrom, nFormatFrom, sTo, sTemp, sFontPath);
oHtmlRenderer.CloseFile();
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS == nFormatFrom)
{
CXpsFile oReader(&oApplicationFonts);
oReader.SetTempFolder(sTemp.c_str());
nRes = PdfDjvuXpsToRenderer<CXpsFile>(oReader, &oHtmlRenderer, sFrom, nFormatFrom, sTo, sTemp, sFontPath);
oHtmlRenderer.CloseFile();
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
else
{
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
int fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid)
{
int nRes = 0;
if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
nRes = bin2pdf(sFrom, sTo, sTemp, sFontPath, bPaid, sThemeDir);
}
else
{
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// xls -> xlsx
int xls2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
FileSystem::Directory::CreateDirectory(sResultDocxDir);
int nRes = xls2xlsx_dir(sFrom, sResultDocxDir, sTemp);
if(SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDocxDir, sTo, -1))
return 0;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
int xls2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp)
{
return S_OK == ConvertXls2Xlsx( sFrom, sTo, NULL) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
}
// xls -> xlst
int xls2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions)
{
// Extract xlsx to temp directory
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
FileSystem::Directory::CreateDirectory(sResultDoctDir);
int nRes = xls2xlst_bin(sFrom, sResultDoctFileEditor, sTemp, sFontPath, sXmlOptions);
if (SUCCEEDED_X2T(nRes))
{
COfficeUtils oCOfficeUtils(NULL);
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
}
return nRes;
}
// xls -> xlst_bin
int xls2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions)
{
std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked");
FileSystem::Directory::CreateDirectory(sResultXlsxDir);
if (ConvertXls2Xlsx( sFrom, sResultXlsxDir, NULL)== S_OK)
{
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
CString sFontPath1 = std_string2string(sFontPath);
m_oCXlsxSerializer.setFontDir(sFontPath1);
CString sTo1 = std_string2string(sTo);
int res = m_oCXlsxSerializer.saveToFile (sTo1, std_string2string(sResultXlsxDir), std_string2string(sXmlOptions)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return res;
}
return AVS_FILEUTILS_ERROR_CONVERT;
}
}
#ifndef ASCCONVERTERS_H
#define ASCCONVERTERS_H
#include <string>
namespace NExtractTools
{
class InputParams;
class InputParamsMailMerge;
}
namespace NExtractTools
{
int docx2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int docx_dir2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sFontPath);
int docx2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int doct_bin2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int doct_bin2docx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sToDir, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int doct2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int xlsx2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions);
int xlsx_dir2xlst_bin (const std::wstring &sXlsxDir, const std::wstring &sTo, const std::wstring &sFontPath, const std::wstring &sXmlOptions);
int xlsx2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions);
int xlst_bin2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int xlst_bin2xlsx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int xlst2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int pptx2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int pptx_dir2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sFontPath);
int pptx2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int pptt_bin2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int pptt_bin2pptx_dir (const std::wstring &sFrom, const std::wstring &sToResult, const std::wstring &sTo, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int pptt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int csv2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int csv2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int csv2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & XmlOptions, const std::wstring &sFontPath);
int xlst2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int xlsx2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int xlst_bin2csv (const std::wstring &sXlsxDir, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int bin2pdf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bPaid, const std::wstring &sThemeDir);
int ppsx2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int ppsx2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo);
int ppt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int ppt2pptx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int ppt2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int rtf2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int rtf2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int rtf2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int rtf2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int docx2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int docx_dir2rtf (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp);
int doct2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int doct_bin2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bFromChanges, const std::wstring &sThemeDir, const InputParams& params);
int doc2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int doc2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int doc2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int doc2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int docx_dir2doc (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int xls2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int xls2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp);
int xls2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions);
int xls2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions);
int txt2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp);
int txt2docx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp);
int txt2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int txt2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp, const std::wstring &sFontPath);
int docx_dir2txt (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring & sXmlOptions, const std::wstring &sTemp);
int odf2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int odf2oox_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int odf2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int odf2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int docx2odt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int docx_dir2odt (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath);
int xlsx2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, const std::wstring &sFontPath);
int xlsx_dir2ods (const std::wstring &sXlsxDir, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath );
int dir2zip (const std::wstring &sFrom, const std::wstring &sTo);
int zip2dir (const std::wstring &sFrom, const std::wstring &sTo);
int convertmailmerge (const InputParamsMailMerge& oMailMergeSend,const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sFontPath, bool bPaid, const std::wstring &sThemeDir, const InputParams& params);
int fromDocxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromDoctBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromDocument (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromXlsxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromXlstBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromSpreadsheet (const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromPptxDir (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromPpttBin (const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromPresentation(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromT(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, const InputParams& params);
int fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sFontPath, const std::wstring &sXmlOptions, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid);
}
#endif // ASCCONVERTERS_H
#include "cextracttools.h"
#include "../../../ServerComponents/DesktopEditor/common/StringBuilder.h"
#include "../../../ServerComponents/DesktopEditor/common/Directory.h"
#include "../../../ServerComponents/DesktopEditor/common/Path.h"
#include "../../../ServerComponents/ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
namespace NExtractTools
{
const TConversionDirection getConversionDirectionFromExt (const std::wstring &sFile1, const std::wstring &sFile2)
{
TConversionDirection res = TCD_ERROR;
int nExt1Pos = sFile1.rfind(_T('.'));
int nExt2Pos = sFile2.rfind(_T('.'));
// check for directory (zip task)
int nSeparator1Pos = sFile1.rfind(_T('/'));
if (-1 == nSeparator1Pos)
{
nSeparator1Pos = sFile1.rfind(_T('\\'));
}
// check for directory (unzip task)
int nSeparator2Pos = sFile2.rfind(_T('/'));
if (-1 == nSeparator2Pos)
{
nSeparator2Pos = sFile2.rfind(_T('\\'));
}
// check for directory in name
bool bIsFile1Directory = ((-1 != nSeparator1Pos) && (nExt1Pos < nSeparator1Pos)); // i.e: /root1/child1.lalala/folder
bool bIsFile2Directory = ((-1 != nSeparator2Pos) && (nExt2Pos < nSeparator2Pos));
// automatic zip/unzip task detection
if (bIsFile1Directory)
{
if (bIsFile2Directory)
{
// Couldn't process 2 directories
return TCD_ERROR;
}
else
{
// dir -> zip
return TCD_ZIPDIR;
}
}
else if (bIsFile2Directory)
{
if (bIsFile1Directory)
{
// Couldn't process 2 directories
return TCD_ERROR;
}
else
{
// zip -> dir
return TCD_UNZIPDIR;
}
}
// there are no directories in paths, both paths are paths to files
if (-1 != nExt1Pos && -1 != nExt2Pos)
{
std::wstring sExt1 = sFile1.substr(nExt1Pos);
std::wstring sExt2 = sFile2.substr(nExt2Pos);
std::transform(sExt1.begin(), sExt1.end(), sExt1.begin(), tolower);
std::transform(sExt2.begin(), sExt2.end(), sExt2.begin(), tolower);
COfficeFileFormatChecker OfficeFileFormatChecker;
if (OfficeFileFormatChecker.isOfficeFile(sFile1))
{
switch (OfficeFileFormatChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
{
if (0 == sExt2.compare(_T(".doct"))) res = TCD_DOCX2DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_DOCX2DOCT_BIN;
else if (0 == sExt2.compare(_T(".rtf"))) res = TCD_DOCX2RTF;
else if (0 == sExt2.compare(_T(".odt"))) res = TCD_DOCX2ODT;
}break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
{
if (0 == sExt2.compare(_T(".xlst"))) res = TCD_XLSX2XLST;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_XLSX2XLST_BIN;
else if (0 == sExt2.compare(_T(".csv"))) res = TCD_XLSX2CSV;
else if (0 == sExt2.compare(_T(".ods"))) res = TCD_XLSX2ODS;
}break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX:
{
if (0 == sExt2.compare(_T(".bin"))) res = TCD_PPTX2PPTT_BIN;
else if (0 == sExt2.compare(_T(".pptt"))) res = TCD_PPTX2PPTT;
else if (0 == sExt2.compare(_T(".pptx"))) res = TCD_PPSX2PPTX;
}break;
case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_DOCT2DOCX;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_T2BIN;
else if (0 == sExt2.compare(_T(".rtf"))) res = TCD_DOCT2RTF;
}break;
case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY:
{
if (0 == sExt2.compare(_T(".xlsx"))) res = TCD_XLST2XLSX;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_T2BIN;
else if (0 == sExt2.compare(_T(".csv"))) res = TCD_XLST2CSV;
}break;
case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY:
{
if (0 == sExt2.compare(_T(".pptx"))) res = TCD_PPTT2PPTX;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_T2BIN;
}break;
case AVS_OFFICESTUDIO_FILE_CANVAS_WORD:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_DOCT_BIN2DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_BIN2T;
else if (0 == sExt2.compare(_T(".rtf"))) res = TCD_DOCT_BIN2RTF;
}break;
case AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET:
{
if (0 == sExt2.compare(_T(".xlsx"))) res = TCD_XLST_BIN2XLSX;
else if (0 == sExt2.compare(_T(".xlst"))) res = TCD_BIN2T;
else if (0 == sExt2.compare(_T(".csv"))) res = TCD_XLST_BIN2CSV;
}break;
case AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION:
{
if (0 == sExt2.compare(_T(".pptx"))) res = TCD_PPTT_BIN2PPTX;
else if (0 == sExt2.compare(_T(".pptt"))) res = TCD_BIN2T;
}break;
case AVS_OFFICESTUDIO_FILE_CANVAS_PDF:
{
if (0 == sExt2.compare(_T(".pdf"))) res = TCD_BIN2PDF;
}break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV:
{
if (0 == sExt2.compare(_T(".xlsx"))) res = TCD_CSV2XLSX;
else if (0 == sExt2.compare(_T(".xlst"))) res = TCD_CSV2XLST;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_CSV2XLST_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_RTF2DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_RTF2DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_RTF2DOCT_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_DOC2DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_DOC2DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_DOC2DOCT_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS:
{
if (0 == sExt2.compare(_T(".xlsx"))) res = TCD_XLS2XLSX;
else if (0 == sExt2.compare(_T(".xlst"))) res = TCD_XLS2XLST;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_XLS2XLST_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT:
{
if (0 == sExt2.compare(_T(".docx"))) res = TCD_TXT2DOCX;
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_TXT2DOCT;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_TXT2DOCT_BIN;
}break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT:
{
if (0 == sExt2.compare(_T(".pptx"))) res = TCD_PPT2PPTX;
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_PPT2PPTT_BIN;
else if (0 == sExt2.compare(_T(".pptt"))) res = TCD_PPT2PPTT;
}break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP:
{
if (0 == sExt2.compare(_T(".bin"))) res = TCD_ODF2OOT_BIN;
else if (0 == sExt2.compare(_T(".doct")) ||
0 == sExt2.compare(_T(".xlst")) ||
0 == sExt2.compare(_T(".pptt"))) res = TCD_ODF2OOT;
else if (0 == sExt2.compare(_T(".docx")) ||
0 == sExt2.compare(_T(".xlsx")) ||
0 == sExt2.compare(_T(".pptx"))) res = TCD_ODF2OOX;
}break;
}
}
}
return res;
}
std::wstring getMailMergeXml(const std::wstring& sJsonPath, int nRecordFrom, int nRecordTo, const std::wstring& sField)
{
NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(_T("<MailMergeData DatabasePath=\""));
oBuilder.WriteEncodeXmlString(sJsonPath.c_str());
oBuilder.WriteString(_T("\" Start=\""));
oBuilder.AddInt(nRecordFrom);
oBuilder.WriteString(_T("\" End=\""));
oBuilder.AddInt(nRecordTo);
oBuilder.WriteString(_T("\" Field=\""));
oBuilder.WriteEncodeXmlString(sField.c_str());
oBuilder.WriteString(_T("\" />"));
return oBuilder.GetData();
}
std::wstring getDoctXml(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, NSDoctRenderer::DoctRendererFormat::FormatFile eToType,
const std::wstring& sTFileDir, const std::wstring& sPdfBinFile, const std::wstring& sFontPath, const std::wstring& sImagesDirectory,
const std::wstring& sThemeDir, int nTopIndex, const std::wstring& sMailMerge, const InputParams& params)
{
NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(_T("<Settings><SrcFileType>"));
oBuilder.AddInt((int)eFromType);
oBuilder.WriteString(_T("</SrcFileType><DstFileType>"));
oBuilder.AddInt((int)eToType);
oBuilder.WriteString(_T("</DstFileType><SrcFilePath>"));
oBuilder.WriteEncodeXmlString(sTFileDir.c_str());
oBuilder.WriteString(_T("</SrcFilePath><DstFilePath>"));
oBuilder.WriteEncodeXmlString(sPdfBinFile.c_str());
oBuilder.WriteString(_T("</DstFilePath><FontsDirectory>"));
oBuilder.WriteEncodeXmlString(sFontPath.c_str());
oBuilder.WriteString(_T("</FontsDirectory><ImagesDirectory>"));
oBuilder.WriteEncodeXmlString(sImagesDirectory.c_str());
oBuilder.WriteString(_T("</ImagesDirectory><ThemesDirectory>"));
oBuilder.WriteEncodeXmlString(sThemeDir.c_str());
oBuilder.WriteString(_T("</ThemesDirectory>"));
if(NULL != params.m_nDoctParams)
{
oBuilder.WriteString(_T("<DoctParams>"));
oBuilder.AddInt(*params.m_nDoctParams);
oBuilder.WriteString(_T("</DoctParams>"));
}
oBuilder.WriteString(_T("<Changes TopItem=\""));
oBuilder.AddInt(nTopIndex);
oBuilder.WriteString(_T("\">"));
std::wstring sChangesDir = sTFileDir + FILE_SEPARATOR_STR + _T("changes");
if (NSDirectory::Exists(sChangesDir))
{
std::vector<std::wstring> aChangesFiles;
CArray<std::wstring> oArray;
NSDirectory::GetFiles2(sChangesDir, oArray, false);
std::vector<std::wstring> aFiles;
for(int i = 0; i < oArray.GetCount(); ++i)
{
aChangesFiles.push_back(oArray[i]);
}
std::sort (aChangesFiles.begin(), aChangesFiles.end(), compare_string_by_length);
for(int i = 0; i < aChangesFiles.size(); ++i)
{
oBuilder.WriteString(_T("<Change>"));
oBuilder.WriteEncodeXmlString(aChangesFiles[i]);
oBuilder.WriteString(_T("</Change>"));
}
}
oBuilder.WriteString(_T("</Changes>"));
oBuilder.WriteString(sMailMerge);
oBuilder.WriteString(_T("</Settings>"));
return oBuilder.GetData();
}
int apply_changes(const std::wstring &sBinFrom, const std::wstring &sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile eType, const std::wstring &sFontDir, const std::wstring &sThemeDir, std::wstring &sBinTo, const InputParams& params)
{
int nRes = 0;
std::wstring sBinDir = FileSystem::Directory::GetFolderPath(sBinFrom);
std::wstring sChangesDir = sBinDir + FILE_SEPARATOR_STR + _T("changes");
if (NSDirectory::Exists(sChangesDir))
{
sBinTo = sBinDir + FILE_SEPARATOR_STR + _T("EditorWithChanges.bin");
std::wstring sImagesDirectory = sBinDir + FILE_SEPARATOR_STR + _T("media");
NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T(""));
int nChangeIndex = -1;
while (true)
{
std::wstring sXml = getDoctXml(eType, eType, sBinDir, sBinTo, sFontDir, sImagesDirectory, sThemeDir, nChangeIndex, _T(""), params);
std::wstring sResult;
oDoctRenderer.Execute(sXml, sResult);
bool bContinue = false;
if (!sResult.empty() && -1 != sResult.find(_T("error")))
{
std::wcerr << _T("DoctRenderer:") << sResult << std::endl;
nRes = AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED;
int nErrorIndex = -1;
int nErrorIndexStart = sResult.find(_T("index"));
if (-1 != nErrorIndexStart)
{
nErrorIndexStart = sResult.find(_T("\""), nErrorIndexStart + 1);
int nErrorIndexEnd = sResult.find(_T("\""), nErrorIndexStart + 1);
nErrorIndex = _wtoi(sResult.substr(nErrorIndexStart + 1, nErrorIndexEnd - nErrorIndexStart - 1).c_str());
}
if (nErrorIndex > 0 && nChangeIndex != nErrorIndex)
{
nChangeIndex = nErrorIndex;
bContinue = true;
}
else
{
sBinTo = sBinFrom;
}
}
if (!bContinue)
{
if(!sToResult.empty() && !params.getDontSaveAdditional())
{
std::vector<std::wstring> aImages = oDoctRenderer.GetImagesInChanges();
//todo сделать interface у COfficeUtils, чтобы можно было делать архив из файлов в разных папках.
for(int i = 0; i < aImages.size(); ++i)
{
std::wstring sImageName = aImages[i];
std::wstring sImage = sImagesDirectory + FILE_SEPARATOR_STR + sImageName;
std::wstring sImageCopy = sChangesDir + FILE_SEPARATOR_STR + sImageName;
NSFile::CFileBinary::Copy(sImage, sImageCopy);
}
std::wstring sToResultDir = FileSystem::Directory::GetFolderPath(sToResult);
std::wstring sTo = sToResultDir + FILE_SEPARATOR_STR + _T("changes.zip");
COfficeUtils oCOfficeUtils(NULL);
oCOfficeUtils.CompressFileOrDirectory(sChangesDir, sTo, -1);
}
break;
}
}
}
else
sBinTo = sBinFrom;
return nRes;
}
}
#ifndef CEXTRACTTOOLS_H
#define CEXTRACTTOOLS_H
#include "../../../ServerComponents/Common/OfficeFileErrorDescription.h"
#include "../../../ServerComponents/Common/OfficeFileFormatChecker.h"
#include "../../../ServerComponents/Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "../../../ServerComponents/Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../../ServerComponents/Common/DocxFormat/Source/XML/stringcommon.h"
#include "../../../ServerComponents/Common/DocxFormat/Source/XML/xmlutils.h"
#include "../../../ServerComponents/DesktopEditor/doctrenderer/doctrenderer.h"
#include "../../../ServerComponents/DesktopEditor/common/StringBuilder.h"
#include "../../../ServerComponents/DesktopEditor/common/Path.h"
#include <iostream>
#include <fstream>
#define SUCCEEDED_X2T(nRes) (0 == (nRes) || AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED == (nRes))
namespace NExtractTools
{
static const TCHAR* gc_sDoctRendererXml = _T("<Settings><SrcFileType>%d</SrcFileType><DstFileType>%d</DstFileType><SrcFilePath>%ls</SrcFilePath><DstFilePath>%ls</DstFilePath><FontsDirectory>%ls</FontsDirectory><ImagesDirectory>%ls</ImagesDirectory><ThemesDirectory>%ls</ThemesDirectory><Changes TopItem=\"%d\">%ls</Changes>%ls</Settings>");
static const TCHAR* gc_sDoctRendererMailMergeXml = _T("<MailMergeData DatabasePath=\"%ls\" Start=\"%d\" End=\"%d\" Field=\"%ls\" />");
typedef enum tagTConversionDirection
{
TCD_ERROR,
TCD_AUTO,
TCD_DOCX2DOCT,
TCD_DOCT2DOCX,
TCD_DOCX2DOCT_BIN,
TCD_DOCT_BIN2DOCX,
TCD_XLSX2XLST,
TCD_XLST2XLSX,
TCD_XLSX2XLST_BIN,
TCD_XLST_BIN2XLSX,
TCD_PPTX2PPTT,
TCD_PPTT2PPTX,
TCD_PPTX2PPTT_BIN,
TCD_PPTT_BIN2PPTX,
TCD_ZIPDIR,
TCD_UNZIPDIR,
TCD_CSV2XLSX,
TCD_XLSX2CSV,
TCD_CSV2XLST,
TCD_XLST2CSV,
TCD_CSV2XLST_BIN,
TCD_XLST_BIN2CSV,
TCD_BIN2PDF,
TCD_T2BIN,
TCD_BIN2T,
TCD_PPSX2PPTX,
//ppt 2
TCD_PPT2PPTX,
TCD_PPT2PPTT,
TCD_PPT2PPTT_BIN,
//doc 2
TCD_DOC2DOCT,
TCD_DOC2DOCT_BIN,
TCD_DOC2DOCX,
//doc 2
TCD_XLS2XLST,
TCD_XLS2XLST_BIN,
TCD_XLS2XLSX,
//rtf 2
TCD_RTF2DOCX,
TCD_RTF2DOCT,
TCD_RTF2DOCT_BIN,
//2 rtf
TCD_DOCT2RTF,
TCD_DOCX2RTF,
TCD_DOCT_BIN2RTF,
//txt 2
TCD_TXT2DOCX,
TCD_TXT2DOCT,
TCD_TXT2DOCT_BIN,
//2 txt
TCD_DOCX2TXT,
TCD_DOCT2TXT,
TCD_DOCT_BIN2TXT,
//odf 2
TCD_ODF2OOX,
TCD_ODF2OOT,
TCD_ODF2OOT_BIN,
//2 odt
TCD_DOCX2ODT,
TCD_DOCT2ODT,
TCD_DOCT_BIN2ODT,
//2 ods
TCD_XLSX2ODS,
TCD_XLST2ODS,
TCD_XLST_BIN2ODS,
TCD_XML2DOCX,
TCD_DOCX2XML,
TCD_MAILMERGE,
TCD_T2,
TCD_DOCT_BIN2,
TCD_XLST_BIN2,
TCD_PPTT_BIN2,
TCD_DOCUMENT2,
TCD_SPREADSHEET2,
TCD_PRESENTATION2,
TCD_CROSSPLATFORM2,
TCD_CANVAS_PDF2
} TConversionDirection;
typedef enum tagTCsvDelimiter
{
TCSVD_NONE = 0,
TCSVD_TAB = 1,
TCSVD_SEMICOLON = 2,
TCSVD_COLON = 3,
TCSVD_COMMA = 4,
TCSVD_SPACE = 5
} TCsvDelimiter;
class InputParamsMailMerge
{
public:
std::wstring* fileName;
std::wstring* from;
std::wstring* jsonKey ;
int* mailFormat;
std::wstring* message;
int* recordCount;
int* recordFrom;
int* recordTo;
std::wstring* subject;
std::wstring* to;
std::wstring* url;
std::wstring* userid;
InputParamsMailMerge()
{
fileName = NULL;
from = NULL;
jsonKey = NULL;
mailFormat = NULL;
message = NULL;
recordCount = NULL;
recordFrom = NULL;
recordTo = NULL;
subject = NULL;
to = NULL;
url = NULL;
userid = NULL;
}
~InputParamsMailMerge()
{
RELEASEOBJECT(fileName);
RELEASEOBJECT(from);
RELEASEOBJECT(jsonKey);
RELEASEOBJECT(mailFormat);
RELEASEOBJECT(message);
RELEASEOBJECT(recordCount);
RELEASEOBJECT(recordFrom);
RELEASEOBJECT(recordTo);
RELEASEOBJECT(subject);
RELEASEOBJECT(to);
RELEASEOBJECT(url);
RELEASEOBJECT(userid);
}
bool FromXmlNode(XmlUtils::CXmlNode& oNode)
{
XmlUtils::CXmlNodes oXmlNodes;
if(TRUE == oNode.GetChilds(oXmlNodes))
{
for(int i = 0; i < oXmlNodes.GetCount(); ++i)
{
XmlUtils::CXmlNode oXmlNode;
if(oXmlNodes.GetAt(i, oXmlNode))
{
CString sValue;
if(oXmlNode.GetTextIfExist(sValue))
{
std::wstring sName = oXmlNode.GetName();
if(_T("fileName") == sName)
fileName = new std::wstring(sValue);
else if(_T("from") == sName)
from = new std::wstring(sValue);
else if(_T("jsonKey") == sName)
jsonKey = new std::wstring(sValue);
else if(_T("mailFormat") == sName)
mailFormat = new int(XmlUtils::GetInteger(sValue));
else if(_T("message") == sName)
message = new std::wstring(sValue);
else if(_T("recordCount") == sName)
recordCount = new int(XmlUtils::GetInteger(sValue));
else if(_T("recordFrom") == sName)
recordFrom = new int(XmlUtils::GetInteger(sValue));
else if(_T("recordTo") == sName)
recordTo = new int(XmlUtils::GetInteger(sValue));
else if(_T("subject") == sName)
subject = new std::wstring(sValue);
else if(_T("to") == sName)
to = new std::wstring(sValue);
else if(_T("url") == sName)
url = new std::wstring(sValue);
else if(_T("userid") == sName)
userid = new std::wstring(sValue);
}
}
}
}
return true;
}
};
class InputParams
{
public:
std::wstring* m_sKey;
std::wstring* m_sFileFrom;
std::wstring* m_sFileTo;
int* m_nFormatFrom;
int* m_nFormatTo;
int* m_nCsvTxtEncoding;
int* m_nCsvDelimiter;
bool* m_bPaid;
bool* m_bFromChanges;
bool* m_bDontSaveAdditional;
std::wstring* m_sAllFontsPath;
std::wstring* m_sFontDir;
std::wstring* m_sThemeDir;
InputParamsMailMerge* m_oMailMergeSend;
int* m_nDoctParams;
std::wstring* m_sHtmlFileInternalPath;
public:
InputParams()
{
m_sKey = NULL;
m_sFileFrom = NULL;
m_sFileTo = NULL;
m_nFormatFrom = new int(AVS_OFFICESTUDIO_FILE_UNKNOWN);
m_nFormatTo = NULL;
m_nCsvTxtEncoding = NULL;
m_nCsvDelimiter = NULL;
m_bPaid = NULL;
m_bFromChanges = NULL;
m_bDontSaveAdditional = NULL;
m_sAllFontsPath = NULL;
m_sFontDir = NULL;
m_sThemeDir = NULL;
m_oMailMergeSend = NULL;
m_nDoctParams = NULL;
m_sHtmlFileInternalPath = NULL;
}
~InputParams()
{
RELEASEOBJECT(m_sKey);
RELEASEOBJECT(m_sFileFrom);
RELEASEOBJECT(m_sFileTo);
RELEASEOBJECT(m_nFormatFrom);
RELEASEOBJECT(m_nFormatTo);
RELEASEOBJECT(m_nCsvTxtEncoding);
RELEASEOBJECT(m_nCsvDelimiter);
RELEASEOBJECT(m_bPaid);
RELEASEOBJECT(m_bFromChanges);
RELEASEOBJECT(m_bDontSaveAdditional);
RELEASEOBJECT(m_sAllFontsPath);
RELEASEOBJECT(m_sFontDir);
RELEASEOBJECT(m_sThemeDir);
RELEASEOBJECT(m_oMailMergeSend);
RELEASEOBJECT(m_nDoctParams);
RELEASEOBJECT(m_sHtmlFileInternalPath);
}
bool FromXmlFile(std::wstring sFilename)
{
XmlUtils::CXmlNode oRoot;
if(TRUE == oRoot.FromXmlFile2(std_string2string(sFilename)))
{
XmlUtils::CXmlNodes oXmlNodes;
if(TRUE == oRoot.GetChilds(oXmlNodes))
{
for(int i = 0; i < oXmlNodes.GetCount(); ++i)
{
XmlUtils::CXmlNode oXmlNode;
if(oXmlNodes.GetAt(i, oXmlNode))
{
std::wstring sName = oXmlNode.GetName();
if(_T("m_oMailMergeSend") == sName)
{
m_oMailMergeSend = new InputParamsMailMerge();
m_oMailMergeSend->FromXmlNode(oXmlNode);
}
else
{
CString sValue;
if(oXmlNode.GetTextIfExist(sValue))
{
if(_T("m_sKey") == sName)
m_sKey = new std::wstring(sValue);
else if(_T("m_sFileFrom") == sName)
m_sFileFrom = new std::wstring(sValue);
else if(_T("m_sFileTo") == sName)
m_sFileTo = new std::wstring(sValue);
else if(_T("m_nFormatFrom") == sName)
m_nFormatFrom = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_nFormatTo") == sName)
m_nFormatTo = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_nCsvTxtEncoding") == sName)
m_nCsvTxtEncoding = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_nCsvDelimiter") == sName)
m_nCsvDelimiter = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_bPaid") == sName)
m_bPaid = new bool(XmlUtils::GetBoolean2(sValue));
else if(_T("m_bFromChanges") == sName)
m_bFromChanges = new bool(XmlUtils::GetBoolean2(sValue));
else if(_T("m_sAllFontsPath") == sName)
m_sAllFontsPath = new std::wstring(sValue);
else if(_T("m_sFontDir") == sName)
m_sFontDir = new std::wstring(sValue);
else if(_T("m_sThemeDir") == sName)
m_sThemeDir = new std::wstring(sValue);
else if(_T("m_bDontSaveAdditional") == sName)
m_bDontSaveAdditional = new bool(XmlUtils::GetBoolean2(sValue));
else if(_T("m_nDoctParams") == sName)
m_nDoctParams = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_sHtmlFileInternalPath") == sName)
m_sHtmlFileInternalPath = new std::wstring(sValue);
}
}
}
}
}
}
return true;
}
std::wstring getXmlOptions()
{
CString sRes;
int nCsvEncoding = 65001; //utf8
char cDelimiter = ',';
if(NULL != m_nCsvTxtEncoding)
nCsvEncoding = *m_nCsvTxtEncoding;
if(NULL != m_nCsvDelimiter)
{
switch (*m_nCsvDelimiter)
{
case TCSVD_TAB: cDelimiter = '\t'; break;
case TCSVD_SEMICOLON: cDelimiter = ';'; break;
case TCSVD_COLON: cDelimiter = ':'; break;
case TCSVD_COMMA: cDelimiter = ','; break;
case TCSVD_SPACE: cDelimiter = ' '; break;
}
}
int nFileType = 1;
if(NULL != m_nFormatFrom && AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == *m_nFormatFrom)
nFileType = 2;
CString sSaveType;
if(NULL != m_nFormatTo)
{
if(AVS_OFFICESTUDIO_FILE_OTHER_JSON == *m_nFormatTo)
sSaveType = _T(" saveFileType='3'");
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == *m_nFormatTo)
nFileType = 2;
}
sRes.Format(_T("<xmlOptions><fileOptions fileType='%d' codePage='%d' delimiter='%c' %ls /><TXTOptions><Encoding>%d</Encoding></TXTOptions></xmlOptions>"), nFileType, nCsvEncoding, cDelimiter, sSaveType, nCsvEncoding);
return sRes.GetBuffer();
}
TConversionDirection getConversionDirection()
{
TConversionDirection eRes = TCD_AUTO;
if(NULL != m_nFormatFrom && NULL != m_nFormatTo)
{
int nFormatFrom = *m_nFormatFrom;
int nFormatTo = *m_nFormatTo;
COfficeFileFormatChecker FileFormatChecker;
if ((m_sFileFrom) && (FileFormatChecker.isOfficeFile(*m_sFileFrom)))
{
if (nFormatFrom != FileFormatChecker.nFileType &&
FileFormatChecker.nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
{
nFormatFrom = FileFormatChecker.nFileType;
*m_nFormatFrom = nFormatFrom;
}
}
eRes = processDownloadFile();
if(TCD_AUTO != eRes)
return eRes;
processInnerFormats();
if(NULL != m_oMailMergeSend)
eRes = TCD_MAILMERGE;
else if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatFrom))
eRes = TCD_DOCUMENT2;
else if(0 != (AVS_OFFICESTUDIO_FILE_SPREADSHEET & nFormatFrom))
eRes = TCD_SPREADSHEET2;
else if(0 != (AVS_OFFICESTUDIO_FILE_PRESENTATION & nFormatFrom))
eRes = TCD_PRESENTATION2;
else if(0 != (AVS_OFFICESTUDIO_FILE_TEAMLAB & nFormatFrom))
eRes = TCD_T2;
else if(AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatFrom)
eRes = TCD_DOCT_BIN2;
else if(AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatFrom)
eRes = TCD_XLST_BIN2;
else if(AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION == nFormatFrom)
eRes = TCD_PPTT_BIN2;
else if(0 != (AVS_OFFICESTUDIO_FILE_CROSSPLATFORM & nFormatFrom))
eRes = TCD_CROSSPLATFORM2;
else if(AVS_OFFICESTUDIO_FILE_CANVAS_PDF == nFormatFrom)
eRes = TCD_CANVAS_PDF2;
else if(AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatFrom && AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatTo)
eRes = TCD_UNZIPDIR;
else if(AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatFrom && AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatTo)
eRes = TCD_ZIPDIR;
}
else if(NULL != m_sFileFrom && NULL != m_sFileTo)
{
eRes = TCD_AUTO;
}
else
eRes = TCD_ERROR;
return eRes;
}
TConversionDirection processDownloadFile()
{
TConversionDirection eRes = TCD_AUTO;
int nFormatFrom = *m_nFormatFrom;
if(AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO == nFormatFrom)
eRes = TCD_ERROR;
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom && NULL == m_nCsvTxtEncoding)
{
int nCodePage = getEncodingByContent();
if(nCodePage < 0)
{
if(!getDontSaveAdditional())
{
size_t nIndex = m_sFileFrom->rfind('.');
NSFile::CFileBinary::Copy(*m_sFileFrom, NSSystemPath::GetDirectoryName(*m_sFileTo) + FILE_SEPARATOR_STR + _T("origin") + m_sFileFrom->substr(nIndex));
}
eRes = TCD_ERROR;
}
}
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom && (NULL == m_nCsvTxtEncoding || NULL == m_nCsvDelimiter))
{
if(!getDontSaveAdditional())
{
int nCodePage = getEncodingByContent();
if(nCodePage < 0)
nCodePage = 46;//65001 Unicode (UTF-8)
int nDelimiter = getDelimiterByContent();
NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(_T("{\"codepage\":"));
oBuilder.AddInt(nCodePage);
oBuilder.WriteString(_T(",\"delimiter\":"));
oBuilder.AddInt(nDelimiter);
oBuilder.WriteString(_T("}"));
std::wstring sFilePath = NSSystemPath::GetDirectoryName(*m_sFileTo) + FILE_SEPARATOR_STR + _T("settings.json");
NSFile::CFileBinary::SaveToFile(sFilePath, oBuilder.GetData());
size_t nIndex = m_sFileFrom->rfind('.');
NSFile::CFileBinary::Copy(*m_sFileFrom, NSSystemPath::GetDirectoryName(*m_sFileTo) + FILE_SEPARATOR_STR + _T("origin") + m_sFileFrom->substr(nIndex));
}
eRes = TCD_ERROR;
}
return eRes;
}
int getEncodingByContent()
{
int nRes = -1;
//todo использовать codepage
NSFile::CFileBinary file;
if(file.OpenFile(*m_sFileFrom))
{
DWORD dwBytesRead = 0;
BYTE pBuffer[3];
file.ReadFile(pBuffer, 3, dwBytesRead);
if(dwBytesRead >= 2)
{
if (pBuffer[0] == 0xFF && pBuffer[1] == 0xFE)
nRes = 48;//1200 Unicode (UTF-16)
else if (pBuffer[0] == 0xFE && pBuffer[1] == 0xFF)
nRes = 49;//1201 Unicode (UTF-16 Big Endian)
}
if(dwBytesRead >= 3)
{
if (pBuffer[0] == 0xEF && pBuffer[1] == 0xBB && pBuffer[2] == 0xBF)
nRes = 46;//65001 Unicode (UTF-8)
}
file.CloseFile();
}
return nRes;
}
int getDelimiterByContent()
{
int nRes = TCSVD_NONE;
NSFile::CFileBinary file;
if(file.OpenFile(*m_sFileFrom))
{
DWORD dwBytesRead = 0;
BYTE pBuffer[1000];
file.ReadFile(pBuffer, 1000, dwBytesRead);
int nDelimitersCount = 6;
int aDelimiters[6] = { 0, 0, 0, 0, 0, 0 };
for(int i = 0; i < dwBytesRead; ++i)
{
char cCurChar = pBuffer[i];
if ('\n' == cCurChar)
{
break;
}
else if ('\t' == cCurChar)
aDelimiters[TCSVD_TAB]++;
else if (';' == cCurChar)
aDelimiters[TCSVD_SEMICOLON]++;
else if (':' == cCurChar)
aDelimiters[TCSVD_COLON]++;
else if (',' == cCurChar)
aDelimiters[TCSVD_COMMA]++;
else if (' ' == cCurChar)
aDelimiters[TCSVD_SPACE]++;
}
int nMaxVal = 0;
int nMaxIndex = 0;
for(int i = 0; i < nDelimitersCount; ++i)
{
if(nMaxVal < aDelimiters[i])
{
nMaxVal = aDelimiters[i];
nMaxIndex = i;
}
}
nRes = nMaxIndex;
file.CloseFile();
}
return nRes;
}
void processInnerFormats()
{
int toFormat = *m_nFormatTo;
int formatFrom = *m_nFormatFrom;
if (AVS_OFFICESTUDIO_FILE_CANVAS == toFormat) {
if (AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY == formatFrom || 0 != (AVS_OFFICESTUDIO_FILE_SPREADSHEET & formatFrom)) {
toFormat = AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET;
} else if (AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY == formatFrom || 0 != (AVS_OFFICESTUDIO_FILE_PRESENTATION & formatFrom)) {
toFormat = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
} else {
toFormat = AVS_OFFICESTUDIO_FILE_CANVAS_WORD;
}
} else if (AVS_OFFICESTUDIO_FILE_OTHER_TEAMLAB_INNER == toFormat) {
if (AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == formatFrom || AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY == formatFrom || 0 != (AVS_OFFICESTUDIO_FILE_SPREADSHEET & formatFrom)) {
toFormat = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
} else if (AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION == formatFrom || AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY == formatFrom || 0 != (AVS_OFFICESTUDIO_FILE_PRESENTATION & formatFrom)) {
toFormat = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
} else {
toFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
}
size_t nIndex = m_sFileTo->rfind('.');
COfficeFileFormatChecker FileFormatChecker;
if(-1 != nIndex)
m_sFileTo->replace(nIndex, std::wstring::npos, FileFormatChecker.GetExtensionByType(toFormat));
else
m_sFileTo->append(FileFormatChecker.GetExtensionByType(toFormat));
}
*m_nFormatTo = toFormat;
}
bool getDontSaveAdditional() const
{
return NULL != m_bDontSaveAdditional && *m_bDontSaveAdditional;
}
};
static std::wstring string_replaceAll(std::wstring str, const std::wstring& from, const std::wstring& to)
{
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != std::wstring::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length();
}
return str;
}
static int getReturnErrorCode(int nDefine)
{
return 0 == nDefine ? 0 : nDefine - AVS_ERROR_FIRST - AVS_FILEUTILS_ERROR_FIRST;
}
static std::wstring getXMLOptionsFromFile(std::wstring xmlFileName)
{
std::wstring sXMLOptions;
std::wifstream options_stream;
#if defined(_WIN32) || defined (_WIN64)
options_stream.open(xmlFileName.c_str());
#else
options_stream.open(stringWstingToUtf8String(xmlFileName));
#endif
if (options_stream.is_open())
{
while(true)
{
std::wstring line;
std::getline(options_stream,line);
if (line.size() < 1)break;
sXMLOptions += line;
}
options_stream.close();
}
return sXMLOptions;
}
static const TConversionDirection getConversionDirection (const std::wstring &sArg3)
{
TConversionDirection res = TCD_ERROR;
if (0 == sArg3.compare(_T("auto"))) {
res = TCD_AUTO;
}
else if (0 == sArg3.compare(_T("docx2doct"))) {
res = TCD_DOCX2DOCT;
}
else if (0 == sArg3.compare(_T("doct2docx"))) {
res = TCD_DOCT2DOCX;
}
else if (0 == sArg3.compare(_T("docx2doct_bin"))) {
res = TCD_DOCX2DOCT_BIN;
}
else if (0 == sArg3.compare(_T("doct_bin2docx"))) {
res = TCD_DOCT_BIN2DOCX;
}
else if (0 == sArg3.compare(_T("xslx2xlst"))) {
res = TCD_XLSX2XLST;
}
else if (0 == sArg3.compare(_T("xslt2xlsx"))) {
res = TCD_XLST2XLSX;
}
else if (0 == sArg3.compare(_T("xslx2xlst_bin"))) {
res = TCD_XLSX2XLST_BIN;
}
else if (0 == sArg3.compare(_T("xslt_bin2xlsx"))) {
res = TCD_XLST_BIN2XLSX;
}
else if (0 == sArg3.compare(_T("pptx2pptt"))) {
res = TCD_PPTX2PPTT;
}
else if (0 == sArg3.compare(_T("pptt2pptx"))) {
res = TCD_PPTT2PPTX;
}
else if (0 == sArg3.compare(_T("pptx2pptt_bin"))) {
res = TCD_PPTX2PPTT_BIN;
}
else if (0 == sArg3.compare(_T("pptt_bin2pptx"))) {
res = TCD_PPTT_BIN2PPTX;
}
else if (0 == sArg3.compare(_T("zip2dir"))) {
res = TCD_ZIPDIR;
}
else if (0 == sArg3.compare(_T("dir2zip"))) {
res = TCD_UNZIPDIR;
}
else if (0 == sArg3.compare(_T("csv2xlsx"))) {
res = TCD_CSV2XLSX;
}
else if (0 == sArg3.compare(_T("csv2xlst"))) {
res = TCD_CSV2XLST;
}
else if (0 == sArg3.compare(_T("xlsx2csv"))) {
res = TCD_XLSX2CSV;
}
else if (0 == sArg3.compare(_T("xlst2csv"))) {
res = TCD_XLST2CSV;
}
else if (0 == sArg3.compare(_T("bin2pdf"))) {
res = TCD_BIN2PDF;
}
else if (0 == sArg3.compare(_T("bin2t"))) {
res = TCD_BIN2T;
}
else if (0 == sArg3.compare(_T("t2bin"))) {
res = TCD_T2BIN;
}
else if (0 == sArg3.compare(_T("ppsx2pptx"))) {
res = TCD_PPSX2PPTX;
}
else if (0 == sArg3.compare(_T("ppt2pptx"))) {
res = TCD_PPT2PPTX;
}
else if (0 == sArg3.compare(_T("doc2docx"))) {
res = TCD_DOC2DOCX;
}
else if (0 == sArg3.compare(_T("rtf2docx"))) {
res = TCD_RTF2DOCX;
}
else if (0 == sArg3.compare(_T("docx2rtf"))) {
res = TCD_DOCX2RTF;
}
else if (0 == sArg3.compare(_T("txt2docx"))) {
res = TCD_TXT2DOCX;
}
else if (0 == sArg3.compare(_T("docx2txt"))) {
res = TCD_DOCX2TXT;
}
return res;
}
const TConversionDirection getConversionDirectionFromExt (const std::wstring &sFile1, const std::wstring &sFile2);
static bool compare_string_by_length (const std::wstring &x, const std::wstring &y)
{
if (!x.empty() && !y.empty())
{
if (x.length() == y.length())
return x.compare(y) <= 0;
else
return ((int)(x.length()) - (int)(y.length())) <= 0;
}
else
{
if (!x.empty())
return false;
else if (!y.empty())
return true;
}
return true;
}
std::wstring getMailMergeXml(const std::wstring& sJsonPath, int nRecordFrom, int nRecordTo, const std::wstring& sField);
std::wstring getDoctXml(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, NSDoctRenderer::DoctRendererFormat::FormatFile eToType,
const std::wstring& sTFileDir, const std::wstring& sPdfBinFile, const std::wstring& sFontPath, const std::wstring& sImagesDirectory,
const std::wstring& sThemeDir, int nTopIndex, const std::wstring& sMailMerge, const InputParams& params);
int apply_changes(const std::wstring &sBinFrom, const std::wstring &sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile eType, const std::wstring &sFontDir, const std::wstring &sThemeDir, std::wstring &sBinTo, const InputParams& params);
}
#endif // CEXTRACTTOOLS_H

#include "cextracttools.h"
#include "ASCConverters.h"
#include "../../../ServerComponents/Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../../ServerComponents/DesktopEditor/common/Directory.h"
//#include <iostream>
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
using namespace NExtractTools;
#if !defined(_WIN32) && !defined (_WIN64)
static std::wstring utf8_to_unicode(const char *src)
{
if (src == NULL) return _T("");
std::string temp = src;
unsigned int nLength = temp.length();
UTF32 *pStrUtf32 = new UTF32 [nLength+1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) src;
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv,
&pStrUtf8[nLength]
, &pStrUtf32_Conv
, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return L"";
}
std::wstring wsEntryName ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
return wsEntryName;
}
#endif
int main(int argc, char *argv[])
{
// check arguments
if (argc < 2)
{
// print out help topic
std::cout << std::endl;
std::cout << std::endl;
std::cout << "-------------------------------------------------------------------------------" << std::endl;
std::cout << "\t\tOOX/binary file converter. Version: " VALUE(INTVER) << std::endl;
std::cout << "-------------------------------------------------------------------------------" << std::endl;
std::cout << std::endl;
std::cout << "USAGE: x2t \"path_to_params_xml\"" << std::endl;
std::cout << "or" << std::endl;
std::cout << "USAGE: x2t \"path_to_file_1\" \"path_to_file_2\" [\"path_to_font_selection\"] [conversion_direction] [XmlOptionsFile]" << std::endl;
std::cout << "WHERE:" << std::endl;
std::cout << "\t\"path_to_file_1\" is a path to file to be converted" << std::endl;
std::cout << "\t\"path_to_file_2\" is a path to the corresponding output file" << std::endl;
std::cout << "\t\"path_to_font_selection\" is a path to 'font_selection.bin' location" << std::endl << std::endl;
std::cout << "NOTE: if 'conversion_direction' is empty or 'auto' conversion direction will be calculated from file extensions" << std::endl << std::endl;
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS);
}
std::wstring sArg1, sExePath;
InputParams oInputParams;
TConversionDirection conversion = TCD_AUTO;
std::wstring sXmlOptions;
#if !defined(_WIN32) && !defined (_WIN64)
sExePath = utf8_to_unicode(argv [0]);
sArg1 = utf8_to_unicode(argv [1]);
#else
sExePath = CA2T(argv [0]);
sArg1 = CA2T(argv [1]);
#endif
std::wstring sXmlExt = _T(".xml");
if(sXmlExt == sArg1.substr(sArg1.length() - sXmlExt.length(), sXmlExt.length()))
{
oInputParams.FromXmlFile(sArg1);
conversion = oInputParams.getConversionDirection();
sXmlOptions = oInputParams.getXmlOptions();
}
else
{
std::wstring sArg2, sArg3, sArg4, sArg5;
#if !defined(_WIN32) && !defined (_WIN64)
if (argc >= 3) sArg2 = utf8_to_unicode(argv [2]);
if (argc >= 4) sArg3 = utf8_to_unicode(argv [3]);
if (argc >= 5) sArg4 = utf8_to_unicode(argv [4]);
if (argc >= 6) sArg5 = utf8_to_unicode(argv [5]);
#else
if (argc >= 3) sArg2 = CA2T(argv [2]);
if (argc >= 4) sArg3 = CA2T(argv [3]);
if (argc >= 5) sArg4 = CA2T(argv [4]);
if (argc >= 6) sArg5 = CA2T(argv [5]);
#endif
oInputParams.m_sFileFrom = new std::wstring(sArg1);
oInputParams.m_sFileTo = new std::wstring(sArg2);
// get conversion direction from 3rd argument
if (argc > 3)
{
oInputParams.m_sFontDir = new std::wstring(sArg3);
}
if (argc > 5)
{
sXmlOptions = getXMLOptionsFromFile(sArg5);
}
if (argc > 4)
{
conversion = getConversionDirection (sArg4);
if (TCD_ERROR == conversion && argc < 5 )
{
sXmlOptions = getXMLOptionsFromFile(sArg4);
conversion = TCD_AUTO;
}
}
}
std::wstring sFileFrom = *oInputParams.m_sFileFrom;
std::wstring sFileTo = *oInputParams.m_sFileTo;
int nFormatFrom = AVS_OFFICESTUDIO_FILE_UNKNOWN;
if(NULL != oInputParams.m_nFormatFrom)
nFormatFrom = *oInputParams.m_nFormatFrom;
int nFormatTo = AVS_OFFICESTUDIO_FILE_UNKNOWN;
if(NULL != oInputParams.m_nFormatTo)
nFormatTo = *oInputParams.m_nFormatTo;
if (TCD_ERROR == conversion)
{
if(AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO == nFormatFrom)
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_MS_OFFCRYPTO);
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatFrom || AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_NEED_PARAMS);
else{
// print out conversion direction error
std::cerr << "Couldn't recognize conversion direction from an argument" << std::endl;
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS);
}
}
if (sFileFrom.empty() || sFileTo.empty())
{
std::cerr << "Empty sFileFrom or sFileTo" << std::endl;
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS);
}
// get conversion direction from file extensions
if (TCD_AUTO == conversion)
{
conversion = getConversionDirectionFromExt (sFileFrom, sFileTo);
}
if (TCD_ERROR == conversion)
{
// print out conversion direction error
std::cerr << "Couldn't automatically recognize conversion direction from extensions" << std::endl;
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS);
}
std::wstring sFontPath;
if(NULL != oInputParams.m_sFontDir)
sFontPath = *oInputParams.m_sFontDir;
bool bFromChanges = false;
if(NULL != oInputParams.m_bFromChanges)
bFromChanges = *oInputParams.m_bFromChanges;
bool bPaid = true;
if(NULL != oInputParams.m_bPaid)
bPaid = *oInputParams.m_bPaid;
std::wstring sThemeDir;
if(NULL != oInputParams.m_sThemeDir)
sThemeDir = *oInputParams.m_sThemeDir;
InputParamsMailMerge* oMailMerge = NULL;
if(NULL != oInputParams.m_oMailMergeSend)
oMailMerge = oInputParams.m_oMailMergeSend;
std::wstring sTempDir = FileSystem::Directory::GetFolderPath(sFileFrom) + FILE_SEPARATOR_STR + _T("Temp");
NSDirectory::CreateDirectory(sTempDir);
if (sTempDir.empty())
{
std::cerr << "Couldn't create temp folder" << std::endl;
return getReturnErrorCode(AVS_FILEUTILS_ERROR_UNKNOWN);
}
int result = 0;
if (TCD_DOCX2DOCT == conversion)
{
result = docx2doct (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_DOCT2DOCX == conversion)
{
result = doct2docx (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_XLSX2XLST == conversion)
{
result = xlsx2xlst (sFileFrom, sFileTo, sTempDir, sFontPath, sXmlOptions);
}
else if (TCD_XLST2XLSX == conversion)
{
result = xlst2xlsx (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_PPTX2PPTT == conversion)
{
result = pptx2pptt (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_PPTT2PPTX == conversion)
{
result = pptt2pptx (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_ZIPDIR == conversion)
{
result = dir2zip (sFileFrom, sFileTo);
}
else if (TCD_UNZIPDIR == conversion)
{
result = zip2dir (sFileFrom, sFileTo);
}
else if (TCD_CSV2XLSX == conversion)
{
result = csv2xlsx (sFileFrom, sFileTo, sXmlOptions, sTempDir, sFontPath);
}
else if (TCD_CSV2XLST == conversion)
{
result = csv2xlst (sFileFrom, sFileTo, sXmlOptions, sTempDir, sFontPath);
}
else if (TCD_XLSX2CSV == conversion)
{
result = xlsx2csv (sFileFrom, sFileTo, sXmlOptions, sTempDir, sFontPath);
}
else if (TCD_XLST2CSV == conversion)
{
result = xlst2csv (sFileFrom, sFileTo, sXmlOptions, sTempDir, sFontPath);
}
else if (TCD_DOCX2DOCT_BIN == conversion)
{
result = docx2doct_bin (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_DOCT_BIN2DOCX == conversion)
{
result = doct_bin2docx (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_XLSX2XLST_BIN == conversion)
{
result = xlsx2xlst_bin (sFileFrom, sFileTo, sTempDir, sFontPath, sXmlOptions);
}
else if (TCD_XLST_BIN2XLSX == conversion)
{
result = xlst_bin2xlsx (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_PPTX2PPTT_BIN == conversion)
{
result = pptx2pptt_bin (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_PPTT_BIN2PPTX == conversion)
{
result = pptt_bin2pptx (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_BIN2PDF == conversion)
{
result = bin2pdf (sFileFrom, sFileTo, sTempDir, sFontPath, bPaid, sThemeDir);
}
else if (TCD_BIN2T == conversion)
{
result = dir2zip (FileSystem::Directory::GetFolderPath(sFileFrom), sFileTo);
}
else if (TCD_T2BIN == conversion)
{
result = zip2dir (sFileFrom, FileSystem::Directory::GetFolderPath(sFileTo));
}
else if (TCD_PPSX2PPTX == conversion)
{
result = ppsx2pptx (sFileFrom, sFileTo, sTempDir);
}
else if (TCD_PPT2PPTX == conversion)
{
result = ppt2pptx (sFileFrom, sFileTo, sTempDir);
}
else if (TCD_PPT2PPTT == conversion)
{
result = ppt2pptt (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_PPT2PPTT_BIN == conversion)
{
result = ppt2pptt_bin (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_RTF2DOCX == conversion)
{
result = rtf2docx (sFileFrom, sFileTo, sTempDir);
}
else if (TCD_RTF2DOCT == conversion)
{
result = rtf2doct (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_RTF2DOCT_BIN == conversion)
{
result = rtf2doct_bin (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_DOCX2RTF == conversion)
{
result = docx2rtf (sFileFrom, sFileTo, sTempDir);
}
else if (TCD_DOC2DOCX == conversion)
{
result = doc2docx (sFileFrom, sFileTo, sTempDir);
}
else if (TCD_DOCT2RTF == conversion)
{
result = doct2rtf (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_DOCT_BIN2RTF == conversion)
{
result = doct_bin2rtf (sFileFrom, sFileTo, sTempDir, sFontPath, bFromChanges, sThemeDir, oInputParams);
}
else if (TCD_TXT2DOCX == conversion)
{
result = txt2docx (sFileFrom, sFileTo, sXmlOptions, sTempDir);
}
else if (TCD_TXT2DOCT == conversion)
{
result = txt2doct (sFileFrom, sFileTo, sXmlOptions, sTempDir, sFontPath);
}
else if (TCD_TXT2DOCT_BIN == conversion)
{
result = txt2doct_bin (sFileFrom, sFileTo, sXmlOptions, sTempDir, sFontPath);
}
else if (TCD_XLS2XLSX == conversion)
{
result = xls2xlsx (sFileFrom, sFileTo, sTempDir);
}
else if (TCD_XLS2XLST == conversion)
{
result = xls2xlst (sFileFrom, sFileTo, sTempDir, sFontPath, sXmlOptions);
}
else if (TCD_XLS2XLST_BIN == conversion)
{
result = xls2xlst_bin (sFileFrom, sFileTo, sTempDir, sFontPath, sXmlOptions);
}
else if (TCD_ODF2OOX == conversion)
{
result = odf2oox (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_ODF2OOT == conversion)
{
result = odf2oot (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_ODF2OOT_BIN == conversion)
{
result = odf2oot_bin (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_DOCX2ODT == conversion)
{
result = docx2odt (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_XLSX2ODS == conversion)
{
result = xlsx2ods (sFileFrom, sFileTo, sTempDir, sFontPath);
}
else if (TCD_MAILMERGE == conversion)
{
result = convertmailmerge(*oMailMerge, sFileFrom, sFileTo, sTempDir, sFontPath, bPaid, sThemeDir, oInputParams);
}
else if (TCD_DOCUMENT2 == conversion)
{
result = fromDocument(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_SPREADSHEET2 == conversion)
{
result = fromSpreadsheet(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_PRESENTATION2 == conversion)
{
result = fromPresentation(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_T2 == conversion)
{
result = fromT(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_DOCT_BIN2 == conversion)
{
result = fromDoctBin(sFileFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_XLST_BIN2 == conversion)
{
result = fromXlstBin(sFileFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_PPTT_BIN2 == conversion)
{
result = fromPpttBin(sFileFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_CROSSPLATFORM2 == conversion)
{
result = fromCrossPlatform(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid, oInputParams);
}
else if (TCD_CANVAS_PDF2 == conversion)
{
result = fromCanvasPdf(sFileFrom, nFormatFrom, sFileTo, nFormatTo, sTempDir, sFontPath, sXmlOptions, sThemeDir, bFromChanges, bPaid);
}
// delete temp dir
NSDirectory::DeleteDirectory(sTempDir);
return getReturnErrorCode(result);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment