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
695c38c8
Commit
695c38c8
authored
Oct 10, 2016
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docx, xlsx, pptx to image
parent
8e17291c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
5 deletions
+164
-5
DesktopEditor/graphics/MetafileToGraphicsRenderer.h
DesktopEditor/graphics/MetafileToGraphicsRenderer.h
+1
-0
DesktopEditor/graphics/MetafileToRenderer.h
DesktopEditor/graphics/MetafileToRenderer.h
+4
-4
X2tConverter/build/Qt/X2tConverter.pro
X2tConverter/build/Qt/X2tConverter.pro
+3
-1
X2tConverter/src/ASCConverters.cpp
X2tConverter/src/ASCConverters.cpp
+91
-0
X2tConverter/src/cextracttools.h
X2tConverter/src/cextracttools.h
+65
-0
No files found.
DesktopEditor/graphics/MetafileToGraphicsRenderer.h
View file @
695c38c8
...
@@ -240,6 +240,7 @@ namespace NSOnlineOfficeBinToPdf
...
@@ -240,6 +240,7 @@ namespace NSOnlineOfficeBinToPdf
oRenderer
.
CreateFromBgraFrame
(
&
oFrame
);
oRenderer
.
CreateFromBgraFrame
(
&
oFrame
);
oRenderer
.
SetTileImageDpi
(
96.0
);
oRenderer
.
SetTileImageDpi
(
96.0
);
oRenderer
.
SetSwapRGB
(
false
);
this
->
m_pRenderer
=
&
oRenderer
;
this
->
m_pRenderer
=
&
oRenderer
;
BYTE
*
pBufferPage
=
oInfo
.
arSizes
[
nPageIndex
].
data
;
BYTE
*
pBufferPage
=
oInfo
.
arSizes
[
nPageIndex
].
data
;
...
...
DesktopEditor/graphics/MetafileToRenderer.h
View file @
695c38c8
...
@@ -882,18 +882,18 @@ namespace NSOnlineOfficeBinToPdf
...
@@ -882,18 +882,18 @@ namespace NSOnlineOfficeBinToPdf
{
{
case
ctPageWidth
:
case
ctPageWidth
:
{
{
arSizes
[
PagesCount
].
width
=
(
ReadInt
(
current
,
curindex
)
/
100000.0
);
arSizes
[
PagesCount
-
1
].
width
=
(
ReadInt
(
current
,
curindex
)
/
100000.0
);
break
;
break
;
}
}
case
ctPageHeight
:
case
ctPageHeight
:
{
{
arSizes
[
PagesCount
].
height
=
(
ReadInt
(
current
,
curindex
)
/
100000.0
);
arSizes
[
PagesCount
-
1
].
height
=
(
ReadInt
(
current
,
curindex
)
/
100000.0
);
break
;
break
;
}
}
case
ctPageStart
:
case
ctPageStart
:
{
{
AddPage
();
AddPage
();
arSizes
[
PagesCount
].
data
=
current
;
arSizes
[
PagesCount
-
1
].
data
=
current
;
break
;
break
;
}
}
case
ctPageEnd
:
case
ctPageEnd
:
...
@@ -1021,7 +1021,7 @@ namespace NSOnlineOfficeBinToPdf
...
@@ -1021,7 +1021,7 @@ namespace NSOnlineOfficeBinToPdf
LONG
lColorsCount
=
(
LONG
)
ReadInt
(
current
,
curindex
);
LONG
lColorsCount
=
(
LONG
)
ReadInt
(
current
,
curindex
);
if
(
0
<=
lColorsCount
)
if
(
0
<=
lColorsCount
)
{
{
SkipInt
(
current
,
curindex
,
8
*
lColorsCount
);
SkipInt
(
current
,
curindex
,
2
*
lColorsCount
);
}
}
break
;
break
;
...
...
X2tConverter/build/Qt/X2tConverter.pro
View file @
695c38c8
...
@@ -83,6 +83,7 @@ core_mac {
...
@@ -83,6 +83,7 @@ core_mac {
INCLUDEPATH
+=
..
/../../
DesktopEditor
/
xml
/
libxml2
/
include
INCLUDEPATH
+=
..
/../../
DesktopEditor
/
xml
/
libxml2
/
include
INCLUDEPATH
+=
..
/../../
DesktopEditor
/
freetype
-
2.5
.
2
/
include
INCLUDEPATH
+=
..
/../../
DesktopEditor
/
freetype
-
2.5
.
2
/
include
INCLUDEPATH
+=
..
/../../
DesktopEditor
/
agg
-
2.4
/
include
INCLUDEPATH
+=
$$
PWD
/../../../
Common
/
DocxFormat
INCLUDEPATH
+=
$$
PWD
/../../../
Common
/
DocxFormat
DEPENDPATH
+=
$$
PWD
/../../../
Common
/
DocxFormat
DEPENDPATH
+=
$$
PWD
/../../../
Common
/
DocxFormat
...
@@ -107,7 +108,8 @@ SOURCES += ../../src/main.cpp \
...
@@ -107,7 +108,8 @@ SOURCES += ../../src/main.cpp \
..
/../
src
/
ASCConverters
.
cpp
..
/../
src
/
ASCConverters
.
cpp
HEADERS
+=
..
/../
src
/
cextracttools
.
h
\
HEADERS
+=
..
/../
src
/
cextracttools
.
h
\
..
/../../
Common
/
OfficeFileFormatChecker
.
h
\
..
/../../
Common
/
OfficeFileFormatChecker
.
h
\
..
/../
src
/
ASCConverters
.
h
..
/../
src
/
ASCConverters
.
h
\
..
/../../
DesktopEditor
/
graphics
/
MetafileToGraphicsRenderer
.
h
###############################################################################################################
###############################################################################################################
...
...
X2tConverter/src/ASCConverters.cpp
View file @
695c38c8
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#include "../../ASCOfficeOdfFileW/source/Oox2OdfConverter/Oox2OdfConverter.h"
#include "../../ASCOfficeOdfFileW/source/Oox2OdfConverter/Oox2OdfConverter.h"
#include "../../DesktopEditor/doctrenderer/doctrenderer.h"
#include "../../DesktopEditor/doctrenderer/doctrenderer.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include "../../DesktopEditor/graphics/MetafileToGraphicsRenderer.h"
#include "../../PdfReader/PdfReader.h"
#include "../../PdfReader/PdfReader.h"
#include "../../PdfReader/Src/ErrorConstants.h"
#include "../../PdfReader/Src/ErrorConstants.h"
#include "../../DjVuFile/DjVu.h"
#include "../../DjVuFile/DjVu.h"
...
@@ -695,6 +696,81 @@ namespace NExtractTools
...
@@ -695,6 +696,81 @@ namespace NExtractTools
NSFile
::
CFileBinary
::
Remove
(
sPdfBinFile
);
NSFile
::
CFileBinary
::
Remove
(
sPdfBinFile
);
return
nRes
;
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
=
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
,
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
);
NSOnlineOfficeBinToPdf
::
CMetafileToRenderterRaster
imageWriter
(
NULL
);
imageWriter
.
wsHtmlPlace
=
sTFileDir
;
imageWriter
.
wsThemesPlace
=
sThemeDir
;
imageWriter
.
wsTempDir
=
sTemp
;
imageWriter
.
appFonts
=
&
oApplicationFonts
;
if
(
NULL
!=
params
.
m_oThumbnail
)
{
InputParamsThumbnail
*
oThumbnail
=
params
.
m_oThumbnail
;
if
(
NULL
!=
oThumbnail
->
format
)
{
imageWriter
.
m_nRasterFormat
=
*
oThumbnail
->
format
;
}
if
(
NULL
!=
oThumbnail
->
aspect
)
{
imageWriter
.
m_nSaveType
=
*
oThumbnail
->
aspect
;
}
if
(
NULL
!=
oThumbnail
->
first
)
{
imageWriter
.
m_bIsOnlyFirst
=
*
oThumbnail
->
first
;
}
if
(
NULL
!=
oThumbnail
->
width
)
{
imageWriter
.
m_nRasterW
=
*
oThumbnail
->
width
;
}
if
(
NULL
!=
oThumbnail
->
height
)
{
imageWriter
.
m_nRasterH
=
*
oThumbnail
->
height
;
}
}
std
::
wstring
sThumbnailDir
;
if
(
imageWriter
.
m_bIsOnlyFirst
)
{
imageWriter
.
m_sFileName
=
sTo
;
}
else
{
sThumbnailDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"thumbnails"
);
FileSystem
::
Directory
::
CreateDirectory
(
sThumbnailDir
);
std
::
wstring
::
size_type
pos
=
sTo
.
find_last_of
(
'.'
);
std
::
wstring
sExt
=
std
::
wstring
::
npos
==
pos
?
L""
:
sTo
.
substr
(
pos
);
imageWriter
.
m_sFileName
=
sThumbnailDir
+
FILE_SEPARATOR_STR
+
L"image"
+
sExt
;
}
BYTE
*
pData
;
DWORD
nBytesCount
;
NSFile
::
CFileBinary
::
ReadAllBytes
(
sPdfBinFile
,
&
pData
,
nBytesCount
);
nRes
=
imageWriter
.
ConvertBuffer
(
pData
,
nBytesCount
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
if
(
!
imageWriter
.
m_bIsOnlyFirst
)
{
COfficeUtils
oCOfficeUtils
(
NULL
);
nRes
=
S_OK
==
oCOfficeUtils
.
CompressFileOrDirectory
(
sThumbnailDir
,
sTo
,
-
1
)
?
nRes
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
return
nRes
;
}
// ppsx -> pptx
// ppsx -> pptx
int
ppsx2pptx
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
int
ppsx2pptx
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
...
@@ -1696,6 +1772,11 @@ namespace NExtractTools
...
@@ -1696,6 +1772,11 @@ namespace NExtractTools
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
DOCT
;
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
DOCT
;
nRes
=
doct_bin2pdf
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
nRes
=
doct_bin2pdf
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
}
}
else
if
(
AVS_OFFICESTUDIO_FILE_IMAGE
==
nFormatTo
)
{
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
DOCT
;
nRes
=
doct_bin2image
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
}
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_DOCUMENT
&
nFormatTo
))
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_DOCUMENT
&
nFormatTo
))
{
{
std
::
wstring
sDocxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"docx_unpacked"
);
std
::
wstring
sDocxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"docx_unpacked"
);
...
@@ -1858,6 +1939,11 @@ namespace NExtractTools
...
@@ -1858,6 +1939,11 @@ namespace NExtractTools
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
XLST
;
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
XLST
;
nRes
=
doct_bin2pdf
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
nRes
=
doct_bin2pdf
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
}
}
else
if
(
AVS_OFFICESTUDIO_FILE_IMAGE
==
nFormatTo
)
{
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
XLST
;
nRes
=
doct_bin2image
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
}
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_SPREADSHEET
&
nFormatTo
))
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_SPREADSHEET
&
nFormatTo
))
{
{
std
::
wstring
sXlsxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"xlsx_unpacked"
);
std
::
wstring
sXlsxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"xlsx_unpacked"
);
...
@@ -1982,6 +2068,11 @@ namespace NExtractTools
...
@@ -1982,6 +2068,11 @@ namespace NExtractTools
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
PPTT
;
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
PPTT
;
nRes
=
doct_bin2pdf
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
nRes
=
doct_bin2pdf
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
}
}
else
if
(
AVS_OFFICESTUDIO_FILE_IMAGE
==
nFormatTo
)
{
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
eFromType
=
NSDoctRenderer
::
DoctRendererFormat
::
FormatFile
::
PPTT
;
nRes
=
doct_bin2image
(
eFromType
,
sFrom
,
sTo
,
sTemp
,
bPaid
,
sThemeDir
,
params
);
}
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_PRESENTATION
&
nFormatTo
))
else
if
(
0
!=
(
AVS_OFFICESTUDIO_FILE_PRESENTATION
&
nFormatTo
))
{
{
std
::
wstring
sPptxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"pptx_unpacked"
);
std
::
wstring
sPptxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"pptx_unpacked"
);
...
...
X2tConverter/src/cextracttools.h
View file @
695c38c8
...
@@ -259,6 +259,63 @@ namespace NExtractTools
...
@@ -259,6 +259,63 @@ namespace NExtractTools
}
}
};
};
class
InputParamsThumbnail
{
public:
int
*
format
;
int
*
aspect
;
bool
*
first
;
int
*
width
;
int
*
height
;
InputParamsThumbnail
()
{
format
=
NULL
;
aspect
=
NULL
;
first
=
NULL
;
width
=
NULL
;
height
=
NULL
;
}
~
InputParamsThumbnail
()
{
RELEASEOBJECT
(
format
);
RELEASEOBJECT
(
aspect
);
RELEASEOBJECT
(
first
);
RELEASEOBJECT
(
width
);
RELEASEOBJECT
(
height
);
}
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
(
"format"
)
==
sName
)
format
=
new
int
(
XmlUtils
::
GetInteger
(
sValue
));
else
if
(
_T
(
"aspect"
)
==
sName
)
aspect
=
new
int
(
XmlUtils
::
GetInteger
(
sValue
));
else
if
(
_T
(
"first"
)
==
sName
)
first
=
new
bool
(
XmlUtils
::
GetBoolean2
(
sValue
));
else
if
(
_T
(
"width"
)
==
sName
)
width
=
new
int
(
XmlUtils
::
GetInteger
(
sValue
));
else
if
(
_T
(
"height"
)
==
sName
)
height
=
new
int
(
XmlUtils
::
GetInteger
(
sValue
));
}
}
}
}
return
true
;
}
};
class
InputParams
class
InputParams
{
{
public:
public:
...
@@ -276,6 +333,7 @@ namespace NExtractTools
...
@@ -276,6 +333,7 @@ namespace NExtractTools
std
::
wstring
*
m_sFontDir
;
std
::
wstring
*
m_sFontDir
;
std
::
wstring
*
m_sThemeDir
;
std
::
wstring
*
m_sThemeDir
;
InputParamsMailMerge
*
m_oMailMergeSend
;
InputParamsMailMerge
*
m_oMailMergeSend
;
InputParamsThumbnail
*
m_oThumbnail
;
int
*
m_nDoctParams
;
int
*
m_nDoctParams
;
std
::
wstring
*
m_sHtmlFileInternalPath
;
std
::
wstring
*
m_sHtmlFileInternalPath
;
std
::
wstring
*
m_sPassword
;
std
::
wstring
*
m_sPassword
;
...
@@ -296,6 +354,7 @@ namespace NExtractTools
...
@@ -296,6 +354,7 @@ namespace NExtractTools
m_sFontDir
=
NULL
;
m_sFontDir
=
NULL
;
m_sThemeDir
=
NULL
;
m_sThemeDir
=
NULL
;
m_oMailMergeSend
=
NULL
;
m_oMailMergeSend
=
NULL
;
m_oThumbnail
=
NULL
;
m_nDoctParams
=
NULL
;
m_nDoctParams
=
NULL
;
m_sHtmlFileInternalPath
=
NULL
;
m_sHtmlFileInternalPath
=
NULL
;
m_sPassword
=
NULL
;
m_sPassword
=
NULL
;
...
@@ -316,6 +375,7 @@ namespace NExtractTools
...
@@ -316,6 +375,7 @@ namespace NExtractTools
RELEASEOBJECT
(
m_sFontDir
);
RELEASEOBJECT
(
m_sFontDir
);
RELEASEOBJECT
(
m_sThemeDir
);
RELEASEOBJECT
(
m_sThemeDir
);
RELEASEOBJECT
(
m_oMailMergeSend
);
RELEASEOBJECT
(
m_oMailMergeSend
);
RELEASEOBJECT
(
m_oThumbnail
);
RELEASEOBJECT
(
m_nDoctParams
);
RELEASEOBJECT
(
m_nDoctParams
);
RELEASEOBJECT
(
m_sHtmlFileInternalPath
);
RELEASEOBJECT
(
m_sHtmlFileInternalPath
);
RELEASEOBJECT
(
m_sPassword
);
RELEASEOBJECT
(
m_sPassword
);
...
@@ -340,6 +400,11 @@ namespace NExtractTools
...
@@ -340,6 +400,11 @@ namespace NExtractTools
m_oMailMergeSend
=
new
InputParamsMailMerge
();
m_oMailMergeSend
=
new
InputParamsMailMerge
();
m_oMailMergeSend
->
FromXmlNode
(
oXmlNode
);
m_oMailMergeSend
->
FromXmlNode
(
oXmlNode
);
}
}
else
if
(
_T
(
"m_oThumbnail"
)
==
sName
)
{
m_oThumbnail
=
new
InputParamsThumbnail
();
m_oThumbnail
->
FromXmlNode
(
oXmlNode
);
}
else
else
{
{
CString
sValue
;
CString
sValue
;
...
...
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