Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
377c0d3c
Commit
377c0d3c
authored
Jan 12, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable not used libraries
parent
22ede0c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
511 deletions
+10
-511
Makefile
Makefile
+2
-2
X2tConverter/build/Qt/X2tConverter.pri
X2tConverter/build/Qt/X2tConverter.pri
+7
-7
X2tConverter/src/ASCConverters.cpp
X2tConverter/src/ASCConverters.cpp
+1
-437
X2tConverter/src/cextracttools.cpp
X2tConverter/src/cextracttools.cpp
+0
-65
No files found.
Makefile
View file @
377c0d3c
...
...
@@ -274,9 +274,9 @@ endef
all
:
lib bin
bin
:
$(X2T)
$(ALLFONTSGEN)
bin
:
$(X2T)
lib
:
$(
PDFWRITER) $(DOCTRENDERER) $(HTMLRENDERER) $(PDFREADER) $(DJVUFILE) $(XPSFILE) $(HTMLFILE) $(
UNICODECONVERTER)
lib
:
$(UNICODECONVERTER)
ext
:
$(ASCDOCUMENTSCORE) $(HTMLFILEINTERNAL) $(DOCBUILDER)
...
...
X2tConverter/build/Qt/X2tConverter.pri
View file @
377c0d3c
...
...
@@ -121,7 +121,7 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lRtfFormatLib
#txt(xml) file
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lTxtXmlFormatLib
# pdf writer
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPdfWriter
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPdfWriter
#docxfile2
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lASCOfficeDocxFile2Lib
#pptxformat
...
...
@@ -133,14 +133,14 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lOfficeUtils
#graphics
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lgraphics
#doctrenderer
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
#HtmlRenderer
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lHtmlRenderer
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPdfReader
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lDjVuFile
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lXpsFile
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lHtmlRenderer
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPdfReader
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lDjVuFile
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lXpsFile
#HtmlFile
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lHtmlFile
#
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lHtmlFile
#UnicodeConverter
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter
#Crypto++
...
...
X2tConverter/src/ASCConverters.cpp
View file @
377c0d3c
...
...
@@ -1120,20 +1120,6 @@ namespace NExtractTools
// bin -> pdf
int
bin2pdf
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
bool
bPaid
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
{
CApplicationFonts
oApplicationFonts
;
initApplicationFonts
(
oApplicationFonts
,
params
);
CPdfRenderer
pdfWriter
(
&
oApplicationFonts
);
pdfWriter
.
SetTempFolder
(
sTemp
);
pdfWriter
.
SetThemesPlace
(
sThemeDir
);
int
nReg
=
(
bPaid
==
false
)
?
0
:
1
;
if
(
params
.
getIsNoBase64
())
{
return
S_OK
==
pdfWriter
.
OnlineWordToPdfFromBinary
(
sFrom
,
sTo
)
?
0
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
else
{
return
S_OK
==
pdfWriter
.
OnlineWordToPdf
(
sFrom
,
sTo
)
?
0
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
int
bin2image
(
const
std
::
wstring
&
sTFileDir
,
BYTE
*
pBuffer
,
LONG
lBufferLen
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
{
...
...
@@ -1234,70 +1220,12 @@ namespace NExtractTools
int
doct_bin2pdf
(
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
,
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
bool
bPaid
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
{
int
nRes
=
0
;
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eToType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
PDF
;
std
::
wstring
sTFileDir
=
NSDirectory
::
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
,
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
,
params
);
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
;
}
//doct_bin -> image
int
doct_bin2image
(
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
,
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
bool
bPaid
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
{
int
nRes
=
0
;
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eToType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
PDF
;
std
::
wstring
sTFileDir
=
NSDirectory
::
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
,
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
{
BYTE
*
pData
=
NULL
;
DWORD
nBytesCount
;
if
(
NSFile
::
CFileBinary
::
ReadAllBytes
(
sPdfBinFile
,
&
pData
,
nBytesCount
))
{
nRes
=
0
==
bin2image
(
sTFileDir
,
pData
,
nBytesCount
,
sTo
,
sTemp
,
sThemeDir
,
params
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
RELEASEARRAYOBJECTS
(
pData
);
}
else
{
nRes
=
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
//delete sPdfBinFile, because it is not in Temp
if
(
NSFile
::
CFileBinary
::
Exists
(
sPdfBinFile
))
NSFile
::
CFileBinary
::
Remove
(
sPdfBinFile
);
return
nRes
;
}
// ppsx -> pptx
...
...
@@ -2633,350 +2561,29 @@ namespace NExtractTools
//html
int
html2doct_dir
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
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
,
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
,
InputParams
&
params
)
{
std
::
wstring
sEpubDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"epub_unpacked"
);
NSDirectory
::
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
,
bool
bPaid
,
const
std
::
wstring
&
sThemeDir
,
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
:
case
AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM
:
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
,
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
(
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
=
oXmlNode
.
GetAttribute
(
L"path"
);
std
::
wstring
wsFilePathInFilename
=
NSSystemPath
::
GetFileName
(
sFilePathIn
);
std
::
wstring
sFilePathOut
=
sFileToDir
+
FILE_SEPARATOR_STR
+
wsFilePathInFilename
;
if
(
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
DOCT
==
eTypeTo
)
{
sFilePathOut
+=
L".docx"
;
std
::
wstring
sTempDocx
=
sTemp
+
FILE_SEPARATOR_STR
+
wsFilePathInFilename
+
L"_DOCX"
;
NSDirectory
::
CreateDirectory
(
sTempDocx
);
BinDocxRW
::
CDocxSerializer
m_oCDocxSerializer
;
m_oCDocxSerializer
.
setIsNoBase64
(
params
.
getIsNoBase64
());
m_oCDocxSerializer
.
setFontDir
(
params
.
getFontPath
());
std
::
wstring
sXmlOptions
;
std
::
wstring
sThemePath
;
// will be filled by 'CreateDocxFolders' method
std
::
wstring
sMediaPath
;
// will be filled by 'CreateDocxFolders' method
std
::
wstring
sEmbedPath
;
// will be filled by 'CreateDocxFolders' method
m_oCDocxSerializer
.
CreateDocxFolders
(
sTempDocx
,
sThemePath
,
sMediaPath
,
sEmbedPath
);
nRes
=
m_oCDocxSerializer
.
loadFromFile
(
sFilePathIn
,
sTempDocx
,
sXmlOptions
,
sThemePath
,
sMediaPath
,
sEmbedPath
)
?
0
:
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
SUCCEEDED_X2T
(
nRes
))
{
COfficeUtils
oCOfficeUtils
(
NULL
);
nRes
=
(
S_OK
==
oCOfficeUtils
.
CompressFileOrDirectory
(
sTempDocx
,
sFilePathOut
,
true
))
?
0
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
else
if
(
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
PDF
==
eTypeTo
)
{
sFilePathOut
+=
_T
(
".pdf"
);
CApplicationFonts
oApplicationFonts
;
initApplicationFonts
(
oApplicationFonts
,
params
);
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
;
}
int
PdfDjvuXpsToRenderer
(
IOfficeDrawingFile
**
ppReader
,
IRenderer
*
pRenderer
,
const
std
::
wstring
&
sFrom
,
int
nFormatFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
,
CApplicationFonts
*
pApplicationFonts
)
{
int
nRes
=
0
;
IOfficeDrawingFile
*
pReader
=
NULL
;
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF
==
nFormatFrom
)
{
pReader
=
new
PdfReader
::
CPdfReader
(
pApplicationFonts
);
}
else
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU
==
nFormatFrom
)
{
pReader
=
new
CDjVuFile
(
pApplicationFonts
);
}
else
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS
==
nFormatFrom
)
{
pReader
=
new
CXpsFile
(
pApplicationFonts
);
}
else
nRes
=
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
SUCCEEDED_X2T
(
nRes
))
{
*
ppReader
=
pReader
;
pReader
->
SetTempDirectory
(
sTemp
);
std
::
wstring
sPassword
=
params
.
getPassword
();
bool
bResult
=
pReader
->
LoadFromFile
(
sFrom
.
c_str
(),
L""
,
sPassword
,
sPassword
);
if
(
bResult
)
{
int
nPagesCount
=
pReader
->
GetPagesCount
();
for
(
int
i
=
0
;
i
<
nPagesCount
;
++
i
)
{
pRenderer
->
NewPage
();
pRenderer
->
BeginCommand
(
c_nPageType
);
double
dPageDpiX
,
dPageDpiY
;
double
dWidth
,
dHeight
;
pReader
->
GetPageInfo
(
i
,
&
dWidth
,
&
dHeight
,
&
dPageDpiX
,
&
dPageDpiY
);
dWidth
*=
25.4
/
dPageDpiX
;
dHeight
*=
25.4
/
dPageDpiY
;
pRenderer
->
put_Width
(
dWidth
);
pRenderer
->
put_Height
(
dHeight
);
pReader
->
DrawPageOnRenderer
(
pRenderer
,
i
,
NULL
);
pRenderer
->
EndCommand
(
c_nPageType
);
}
}
else
{
nRes
=
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF
==
nFormatFrom
)
{
PdfReader
::
CPdfReader
*
pPdfReader
=
static_cast
<
PdfReader
::
CPdfReader
*>
(
pReader
);
if
(
PdfReader
::
errorEncrypted
==
pPdfReader
->
GetError
())
{
if
(
sPassword
.
empty
())
{
if
(
!
params
.
getDontSaveAdditional
())
{
copyOrigin
(
sFrom
,
*
params
.
m_sFileTo
);
}
nRes
=
AVS_FILEUTILS_ERROR_CONVERT_DRM
;
}
else
{
nRes
=
AVS_FILEUTILS_ERROR_CONVERT_PASSWORD
;
}
}
}
}
}
return
nRes
;
}
int
PdfDjvuXpsToImage
(
IOfficeDrawingFile
**
ppReader
,
const
std
::
wstring
&
sFrom
,
int
nFormatFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
,
CApplicationFonts
*
pApplicationFonts
)
{
int
nRes
=
0
;
IOfficeDrawingFile
*
pReader
=
NULL
;
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF
==
nFormatFrom
)
{
pReader
=
new
PdfReader
::
CPdfReader
(
pApplicationFonts
);
}
else
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU
==
nFormatFrom
)
{
pReader
=
new
CDjVuFile
(
pApplicationFonts
);
}
else
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS
==
nFormatFrom
)
{
pReader
=
new
CXpsFile
(
pApplicationFonts
);
}
else
nRes
=
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
SUCCEEDED_X2T
(
nRes
))
{
*
ppReader
=
pReader
;
pReader
->
SetTempDirectory
(
sTemp
);
std
::
wstring
sPassword
=
params
.
getPassword
();
bool
bResult
=
pReader
->
LoadFromFile
(
sFrom
.
c_str
(),
L""
,
sPassword
,
sPassword
);
if
(
bResult
)
{
//default as in CMetafileToRenderterRaster
int
nRasterFormat
=
4
;
int
nSaveType
=
2
;
bool
bIsOnlyFirst
=
true
;
int
nRasterW
=
100
;
int
nRasterH
=
100
;
if
(
NULL
!=
params
.
m_oThumbnail
)
{
InputParamsThumbnail
*
oThumbnail
=
params
.
m_oThumbnail
;
if
(
NULL
!=
oThumbnail
->
format
)
{
nRasterFormat
=
*
oThumbnail
->
format
;
}
if
(
NULL
!=
oThumbnail
->
aspect
)
{
nSaveType
=
*
oThumbnail
->
aspect
;
}
if
(
NULL
!=
oThumbnail
->
first
)
{
bIsOnlyFirst
=
*
oThumbnail
->
first
;
}
if
(
NULL
!=
oThumbnail
->
width
)
{
nRasterW
=
*
oThumbnail
->
width
;
}
if
(
NULL
!=
oThumbnail
->
height
)
{
nRasterH
=
*
oThumbnail
->
height
;
}
}
std
::
wstring
sThumbnailDir
;
std
::
wstring
sFileToExt
;
if
(
!
bIsOnlyFirst
)
{
sThumbnailDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"thumbnails"
);
NSDirectory
::
CreateDirectory
(
sThumbnailDir
);
sFileToExt
=
getExtentionByRasterFormat
(
nRasterFormat
);
}
int
nPagesCount
=
pReader
->
GetPagesCount
();
if
(
bIsOnlyFirst
)
nPagesCount
=
1
;
for
(
int
i
=
0
;
i
<
nPagesCount
;
++
i
)
{
int
nRasterWCur
=
nRasterW
;
int
nRasterHCur
=
nRasterH
;
if
(
1
==
nSaveType
)
{
double
dPageDpiX
,
dPageDpiY
;
double
dWidth
,
dHeight
;
pReader
->
GetPageInfo
(
i
,
&
dWidth
,
&
dHeight
,
&
dPageDpiX
,
&
dPageDpiY
);
double
dKoef1
=
nRasterWCur
/
dWidth
;
double
dKoef2
=
nRasterHCur
/
dHeight
;
if
(
dKoef1
>
dKoef2
)
dKoef1
=
dKoef2
;
nRasterWCur
=
(
int
)(
dWidth
*
dKoef1
+
0.5
);
nRasterHCur
=
(
int
)(
dHeight
*
dKoef1
+
0.5
);
}
std
::
wstring
sFileTo
;
if
(
bIsOnlyFirst
)
{
sFileTo
=
sTo
;
}
else
{
sFileTo
=
sThumbnailDir
+
FILE_SEPARATOR_STR
+
L"image"
+
std
::
to_wstring
(
i
+
1
)
+
sFileToExt
;
}
pReader
->
ConvertToRaster
(
i
,
sFileTo
,
nRasterFormat
,
nRasterWCur
,
nRasterHCur
);
}
//zip
if
(
!
bIsOnlyFirst
)
{
COfficeUtils
oCOfficeUtils
(
NULL
);
nRes
=
S_OK
==
oCOfficeUtils
.
CompressFileOrDirectory
(
sThumbnailDir
,
sTo
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
else
{
nRes
=
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF
==
nFormatFrom
)
{
PdfReader
::
CPdfReader
*
pPdfReader
=
static_cast
<
PdfReader
::
CPdfReader
*>
(
pReader
);
if
(
PdfReader
::
errorEncrypted
==
pPdfReader
->
GetError
())
{
if
(
sPassword
.
empty
())
{
if
(
!
params
.
getDontSaveAdditional
())
{
copyOrigin
(
sFrom
,
*
params
.
m_sFileTo
);
}
nRes
=
AVS_FILEUTILS_ERROR_CONVERT_DRM
;
}
else
{
nRes
=
AVS_FILEUTILS_ERROR_CONVERT_PASSWORD
;
}
}
}
}
}
return
nRes
;
}
...
...
@@ -3578,49 +3185,6 @@ namespace NExtractTools
int
fromCrossPlatform
(
const
std
::
wstring
&
sFrom
,
int
nFormatFrom
,
const
std
::
wstring
&
sTo
,
int
nFormatTo
,
const
std
::
wstring
&
sTemp
,
const
std
::
wstring
&
sThemeDir
,
bool
bFromChanges
,
bool
bPaid
,
InputParams
&
params
)
{
int
nRes
=
0
;
CApplicationFonts
oApplicationFonts
;
initApplicationFonts
(
oApplicationFonts
,
params
);
if
(
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF
==
nFormatTo
)
{
if
(
nFormatFrom
==
nFormatTo
)
{
NSFile
::
CFileBinary
::
Copy
(
sFrom
,
sTo
);
}
else
{
CPdfRenderer
pdfWriter
(
&
oApplicationFonts
);
pdfWriter
.
SetTempFolder
(
sTemp
);
IOfficeDrawingFile
*
pReader
=
NULL
;
nRes
=
PdfDjvuXpsToRenderer
(
&
pReader
,
&
pdfWriter
,
sFrom
,
nFormatFrom
,
sTo
,
sTemp
,
params
,
&
oApplicationFonts
);
pdfWriter
.
SaveToFile
(
sTo
);
RELEASEOBJECT
(
pReader
);
}
}
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_CANVAS
&
nFormatTo
))
{
std
::
wstring
sToDir
=
NSSystemPath
::
GetDirectoryName
(
sTo
);
if
(
!
params
.
getDontSaveAdditional
())
{
//save origin to print
copyOrigin
(
sFrom
,
*
params
.
m_sFileTo
);
}
NSHtmlRenderer
::
CASCHTMLRenderer3
oHtmlRenderer
;
oHtmlRenderer
.
CreateOfficeFile
(
sToDir
);
IOfficeDrawingFile
*
pReader
=
NULL
;
nRes
=
PdfDjvuXpsToRenderer
(
&
pReader
,
&
oHtmlRenderer
,
sFrom
,
nFormatFrom
,
sTo
,
sTemp
,
params
,
&
oApplicationFonts
);
oHtmlRenderer
.
CloseFile
(
params
.
getIsNoBase64
());
RELEASEOBJECT
(
pReader
);
}
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_IMAGE
&
nFormatTo
))
{
IOfficeDrawingFile
*
pReader
=
NULL
;
nRes
=
PdfDjvuXpsToImage
(
&
pReader
,
sFrom
,
nFormatFrom
,
sTo
,
sTemp
,
params
,
&
oApplicationFonts
);
RELEASEOBJECT
(
pReader
);
}
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
&
sThemeDir
,
bool
bFromChanges
,
bool
bPaid
,
InputParams
&
params
)
...
...
@@ -4224,7 +3788,7 @@ namespace NExtractTools
}
//clean up v8
NSDoctRenderer
::
CDocBuilder
::
Dispose
();
//
NSDoctRenderer::CDocBuilder::Dispose();
if
(
SUCCEEDED_X2T
(
result
)
&&
oInputParams
.
m_bOutputConvertCorrupted
)
{
return
AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED
;
...
...
X2tConverter/src/cextracttools.cpp
View file @
377c0d3c
...
...
@@ -403,71 +403,6 @@ namespace NExtractTools
}
int
apply_changes
(
const
std
::
wstring
&
sBinFrom
,
const
std
::
wstring
&
sToResult
,
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eType
,
const
std
::
wstring
&
sThemeDir
,
std
::
wstring
&
sBinTo
,
const
InputParams
&
params
)
{
std
::
wstring
sBinDir
=
NSDirectory
::
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
,
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
;
params
.
m_bOutputConvertCorrupted
=
true
;
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
);
}
////copy doct for version history
// std::wstring sBinCopy = sChangesDir + FILE_SEPARATOR_STR + NSSystemPath::GetFileName(sBinFrom);
// NSFile::CFileBinary::Copy(sBinFrom, sBinCopy);
std
::
wstring
sToResultDir
=
NSDirectory
::
GetFolderPath
(
sToResult
);
std
::
wstring
sTo
=
sToResultDir
+
FILE_SEPARATOR_STR
+
_T
(
"changes.zip"
);
COfficeUtils
oCOfficeUtils
(
NULL
);
oCOfficeUtils
.
CompressFileOrDirectory
(
sChangesDir
,
sTo
);
}
break
;
}
}
}
else
sBinTo
=
sBinFrom
;
return
0
;
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment