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
2836fee4
Commit
2836fee4
authored
Jan 16, 2017
by
Sergey Konovalov
Committed by
GitHub
Jan 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ASCConverters.cpp
add bin2imageBase64 to generate thumbnail from pdf command in base64 format
parent
0b096a4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
28 deletions
+77
-28
X2tConverter/src/ASCConverters.cpp
X2tConverter/src/ASCConverters.cpp
+77
-28
No files found.
X2tConverter/src/ASCConverters.cpp
View file @
2836fee4
...
...
@@ -76,6 +76,26 @@ namespace NExtractTools
else
oApplicationFonts
.
InitializeFromFolder
(
sFontPath
);
}
std
::
wstring
getExtentionByRasterFormat
(
int
format
)
{
std
::
wstring
sExt
;
switch
(
format
)
{
case
1
:
sExt
=
L".bmp"
;
break
;
case
2
:
sExt
=
L".gif"
;
break
;
case
3
:
sExt
=
L".jpg"
;
break
;
default:
sExt
=
L".png"
;
break
;
}
return
sExt
;
}
// docx -> bin
int
docx2doct_bin
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
...
...
@@ -665,10 +685,9 @@ namespace NExtractTools
int
nReg
=
(
bPaid
==
false
)
?
0
:
1
;
return
S_OK
==
pdfWriter
.
OnlineWordToPdf
(
sFrom
,
sTo
)
?
0
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
int
bin2image
(
const
std
::
wstring
&
s
From
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
int
bin2image
(
const
std
::
wstring
&
s
TFileDir
,
BYTE
*
pBuffer
,
LONG
lBufferLen
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
{
long
nRes
=
0
;
std
::
wstring
sTFileDir
=
NSDirectory
::
GetFolderPath
(
sFrom
);
CApplicationFonts
oApplicationFonts
;
initApplicationFonts
(
oApplicationFonts
,
params
);
NSOnlineOfficeBinToPdf
::
CMetafileToRenderterRaster
imageWriter
(
NULL
);
...
...
@@ -711,10 +730,7 @@ namespace NExtractTools
NSDirectory
::
CreateDirectory
(
sThumbnailDir
);
imageWriter
.
m_sFileName
=
sThumbnailDir
+
FILE_SEPARATOR_STR
+
L"image"
+
getExtentionByRasterFormat
(
imageWriter
.
m_nRasterFormat
);
}
BYTE
*
pData
;
DWORD
nBytesCount
;
NSFile
::
CFileBinary
::
ReadAllBytes
(
sFrom
,
&
pData
,
nBytesCount
);
nRes
=
imageWriter
.
ConvertBuffer
(
pData
,
nBytesCount
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
nRes
=
imageWriter
.
ConvertBuffer
(
pBuffer
,
lBufferLen
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
!
imageWriter
.
m_bIsOnlyFirst
)
{
COfficeUtils
oCOfficeUtils
(
NULL
);
...
...
@@ -722,6 +738,48 @@ namespace NExtractTools
}
return
nRes
;
}
int
bin2imageBase64
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
const
std
::
wstring
&
sThemeDir
,
InputParams
&
params
)
{
long
nRes
=
0
;
NSFile
::
CFileBinary
oFile
;
if
(
!
oFile
.
OpenFile
(
sFrom
))
return
AVS_FILEUTILS_ERROR_CONVERT
;
DWORD
dwFileSize
=
oFile
.
GetFileSize
();
BYTE
*
pFileContent
=
new
BYTE
[
dwFileSize
];
if
(
!
pFileContent
)
{
oFile
.
CloseFile
();
return
AVS_FILEUTILS_ERROR_CONVERT
;
}
DWORD
dwReaded
;
oFile
.
ReadFile
(
pFileContent
,
dwFileSize
,
dwReaded
);
oFile
.
CloseFile
();
int
nBufferLen
=
NSBase64
::
Base64DecodeGetRequiredLength
(
dwFileSize
);
BYTE
*
pBuffer
=
new
BYTE
[
nBufferLen
];
if
(
!
pBuffer
)
{
RELEASEARRAYOBJECTS
(
pFileContent
);
return
AVS_FILEUTILS_ERROR_CONVERT
;
}
if
(
NSBase64
::
Base64Decode
((
const
char
*
)
pFileContent
,
dwFileSize
,
pBuffer
,
&
nBufferLen
))
{
std
::
wstring
sTFileDir
=
NSDirectory
::
GetFolderPath
(
sFrom
);
nRes
=
bin2image
(
sTFileDir
,
pBuffer
,
nBufferLen
,
sTo
,
sTemp
,
sThemeDir
,
params
);
}
else
{
nRes
=
AVS_FILEUTILS_ERROR_CONVERT
;
}
RELEASEARRAYOBJECTS
(
pBuffer
);
RELEASEARRAYOBJECTS
(
pFileContent
);
return
nRes
;
}
//doct_bin -> pdf
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
)
{
...
...
@@ -754,26 +812,7 @@ namespace NExtractTools
NSFile
::
CFileBinary
::
Remove
(
sPdfBinFile
);
return
nRes
;
}
std
::
wstring
getExtentionByRasterFormat
(
int
format
)
{
std
::
wstring
sExt
;
switch
(
format
)
{
case
1
:
sExt
=
L".bmp"
;
break
;
case
2
:
sExt
=
L".gif"
;
break
;
case
3
:
sExt
=
L".jpg"
;
break
;
default:
sExt
=
L".png"
;
break
;
}
return
sExt
;
}
//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
)
{
...
...
@@ -793,7 +832,17 @@ namespace NExtractTools
}
else
{
nRes
=
0
==
bin2image
(
sPdfBinFile
,
sTo
,
sTemp
,
sThemeDir
,
params
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
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
))
...
...
@@ -2381,7 +2430,7 @@ namespace NExtractTools
}
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_IMAGE
&
nFormatTo
))
{
nRes
=
bin2image
(
sFrom
,
sTo
,
sTemp
,
sThemeDir
,
params
);
nRes
=
bin2image
Base64
(
sFrom
,
sTo
,
sTemp
,
sThemeDir
,
params
);
}
else
{
...
...
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