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
d8b17741
Commit
d8b17741
authored
Dec 05, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x2t - options for check macro in file
parent
717b6280
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
39 deletions
+97
-39
ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h
ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h
+4
-3
Common/OfficeFileErrorDescription.h
Common/OfficeFileErrorDescription.h
+1
-0
Common/OfficeFileFormatChecker.h
Common/OfficeFileFormatChecker.h
+4
-2
Common/OfficeFileFormatChecker2.cpp
Common/OfficeFileFormatChecker2.cpp
+49
-23
X2tConverter/src/ASCConverters.cpp
X2tConverter/src/ASCConverters.cpp
+17
-0
X2tConverter/src/ASCConverters.h
X2tConverter/src/ASCConverters.h
+1
-0
X2tConverter/src/main.cpp
X2tConverter/src/main.cpp
+21
-11
No files found.
ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h
View file @
d8b17741
...
...
@@ -67,7 +67,9 @@ public:
}
HRESULT
LoadFromFile
(
std
::
wstring
sSrcFileName
,
std
::
wstring
sDstPath
,
std
::
wstring
password
,
bool
&
bMacros
);
long
OpenFile
(
const
std
::
wstring
&
fileName
,
const
std
::
wstring
&
password
,
bool
&
bMacros
);
bool
CloseFile
();
private:
int
m_Status
;
...
...
@@ -76,8 +78,7 @@ private:
std
::
wstring
m_strTempDirectory
;
std
::
wstring
m_sTempDecryptFileName
;
long
OpenFile
(
const
std
::
wstring
&
fileName
,
const
std
::
wstring
&
password
,
bool
&
bMacros
);
bool
CloseFile
();
std
::
wstring
GetDirectory
(
std
::
wstring
strFileName
);
};
...
...
Common/OfficeFileErrorDescription.h
View file @
d8b17741
...
...
@@ -44,6 +44,7 @@
#define AVS_ERROR_FILEFORMAT (AVS_ERROR_FIRST + 0x0004)
#define AVS_ERROR_PASSWORD (AVS_ERROR_FIRST + 0x0005)
#define AVS_ERROR_DRM (AVS_ERROR_FIRST + 0x0006)
#define AVS_ERROR_MACRO (AVS_ERROR_FIRST + 0x0007)
// AVSOfficeUniversalConverter 0x0050 - 0x0075
#define AVS_UNIVERSALDOCUMENTCONVERTER_ERROR_FIRST (AVS_ERROR_FIRST + 0x0050)
...
...
Common/OfficeFileFormatChecker.h
View file @
d8b17741
...
...
@@ -42,11 +42,13 @@ namespace POLE
class
COfficeFileFormatChecker
{
public:
int
nFileType
;
int
nFileType
;
bool
bMacroEnabled
;
COfficeFileFormatChecker
()
{
nFileType
=
AVS_OFFICESTUDIO_FILE_UNKNOWN
;
nFileType
=
AVS_OFFICESTUDIO_FILE_UNKNOWN
;
bMacroEnabled
=
false
;
}
COfficeFileFormatChecker
(
std
::
wstring
sFileName
)
{
...
...
Common/OfficeFileFormatChecker2.cpp
View file @
d8b17741
...
...
@@ -33,6 +33,7 @@
#include "../DesktopEditor/common/File.h"
#include "../OfficeUtils/src/OfficeUtils.h"
#include "../ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h"
#include "3dParty/pole/pole.h"
#include <algorithm>
...
...
@@ -145,6 +146,10 @@ bool COfficeFileFormatChecker::isDocFormatFile (POLE::Storage * storage)
if
(
entries
.
size
()
>
0
)
return
false
;
if
(
storage
->
isDirectory
(
L"Macros"
))
{
bMacroEnabled
=
true
;
}
return
true
;
}
...
...
@@ -158,31 +163,36 @@ bool COfficeFileFormatChecker::isXlsFormatFile (POLE::Storage * storage)
POLE
::
Stream
stream
(
storage
,
L"Workbook"
);
if
(
stream
.
read
(
buffer
,
10
)
>
0
)
return
true
;
POLE
::
Stream
stream2
(
storage
,
L"Book"
);
if
(
stream2
.
read
(
buffer
,
10
)
>
0
)
return
true
;
POLE
::
Stream
stream3
(
storage
,
L"WORKBOOK"
);
if
(
stream3
.
read
(
buffer
,
10
)
>
0
)
return
true
;
if
(
stream
.
read
(
buffer
,
10
)
<
1
)
{
POLE
::
Stream
stream2
(
storage
,
L"Book"
);
POLE
::
Stream
stream4
(
storage
,
L"BOOK"
);
if
(
stream2
.
read
(
buffer
,
10
)
<
1
)
{
POLE
::
Stream
stream3
(
storage
,
L"WORKBOOK"
);
if
(
stream4
.
read
(
buffer
,
10
)
>
0
)
return
true
;
if
(
stream3
.
read
(
buffer
,
10
)
<
1
)
{
POLE
::
Stream
stream4
(
storage
,
L"BOOK"
);
POLE
::
Stream
stream5
(
storage
,
L"book"
);
if
(
stream4
.
read
(
buffer
,
10
)
<
1
)
{
POLE
::
Stream
stream5
(
storage
,
L"book"
);
if
(
stream5
.
read
(
buffer
,
10
)
>
0
)
return
true
;
if
(
stream5
.
read
(
buffer
,
10
)
<
1
)
return
false
;
}
}
}
}
if
(
storage
->
isDirectory
(
L"_VBA_PROJECT_CUR"
))
{
bMacroEnabled
=
true
;
}
return
fals
e
;
return
tru
e
;
}
bool
COfficeFileFormatChecker
::
isPptFormatFile
(
POLE
::
Storage
*
storage
)
{
if
(
storage
==
NULL
)
return
false
;
...
...
@@ -190,10 +200,10 @@ bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
POLE
::
Stream
stream
(
storage
,
L"PowerPoint Document"
);
unsigned
char
buffer
[
10
];
if
(
stream
.
read
(
buffer
,
10
)
>
0
)
return
tru
e
;
if
(
stream
.
read
(
buffer
,
10
)
<
1
)
return
fals
e
;
return
fals
e
;
return
tru
e
;
}
bool
COfficeFileFormatChecker
::
isMS_OFFCRYPTOFormatFile
(
POLE
::
Storage
*
storage
)
{
...
...
@@ -227,7 +237,16 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName)
}
else
if
(
isPptFormatFile
(
&
storage
)
)
{
nFileType
=
AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT
;
COfficePPTFile
pptFile
;
bMacroEnabled
=
true
;
long
nResult
=
pptFile
.
OpenFile
(
fileName
,
L""
,
bMacroEnabled
);
if
(
nResult
!=
S_OK
)
{
return
false
;
}
pptFile
.
CloseFile
();
nFileType
=
AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT
;
return
true
;
}
else
if
(
isMS_OFFCRYPTOFormatFile
(
&
storage
)
)
...
...
@@ -380,6 +399,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
docmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM
;
bMacroEnabled
=
true
;
}
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
dotxFormatLine
))
{
...
...
@@ -388,6 +408,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
dotmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM
;
bMacroEnabled
=
true
;
}
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
xlsxFormatLine
))
{
...
...
@@ -396,6 +417,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
xlsmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM
;
bMacroEnabled
=
true
;
}
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
xltxFormatLine
))
{
...
...
@@ -404,6 +426,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
xltmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM
;
bMacroEnabled
=
true
;
}
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
pptxFormatLine
))
{
...
...
@@ -412,10 +435,12 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
pptmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM
;
bMacroEnabled
=
true
;
}
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
ppsmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM
;
bMacroEnabled
=
true
;
}
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
ppsxFormatLine
))
{
...
...
@@ -428,6 +453,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else
if
(
std
::
string
::
npos
!=
strContentTypes
.
find
(
potmFormatLine
))
{
nFileType
=
AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM
;
bMacroEnabled
=
true
;
}
delete
[]
pBuffer
;
pBuffer
=
NULL
;
...
...
X2tConverter/src/ASCConverters.cpp
View file @
d8b17741
...
...
@@ -3801,6 +3801,23 @@ namespace NExtractTools
}
//------------------------------------------------------------------------------------------------------------------
int
detectMacroInFile
(
InputParams
&
oInputParams
)
{
int
nRes
=
0
;
// no macro
std
::
wstring
sFileFrom
=
*
oInputParams
.
m_sFileFrom
;
COfficeFileFormatChecker
OfficeFileFormatChecker
;
if
(
OfficeFileFormatChecker
.
isOfficeFile
(
sFileFrom
))
{
if
(
OfficeFileFormatChecker
.
bMacroEnabled
)
{
nRes
=
AVS_ERROR_MACRO
;
}
}
return
nRes
;
}
int
fromInputParams
(
InputParams
&
oInputParams
)
{
TConversionDirection
conversion
=
oInputParams
.
getConversionDirection
();
...
...
X2tConverter/src/ASCConverters.h
View file @
d8b17741
...
...
@@ -199,6 +199,7 @@ namespace NExtractTools
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
);
int
fromInputParams
(
InputParams
&
oInputParams
);
int
detectMacroInFile
(
InputParams
&
oInputParams
);
X2T_DECL_EXPORT
int
FromFile
(
const
std
::
wstring
&
file
);
X2T_DECL_EXPORT
int
FromXml
(
const
std
::
wstring
&
xml
);
...
...
X2tConverter/src/main.cpp
View file @
d8b17741
...
...
@@ -118,7 +118,7 @@ static std::wstring utf8_to_unicode(const char *src)
int
result
=
0
;
std
::
wstring
sXmlExt
=
_T
(
".xml"
);
if
(
sXmlExt
==
sArg1
.
substr
(
sArg1
.
length
()
-
sXmlExt
.
length
(),
sXmlExt
.
length
(
)))
if
(
(
sArg1
.
length
()
>
3
)
&&
(
sXmlExt
==
sArg1
.
substr
(
sArg1
.
length
()
-
sXmlExt
.
length
(),
sXmlExt
.
length
()
)))
{
NExtractTools
::
InputParams
oInputParams
;
if
(
oInputParams
.
FromXmlFile
(
sArg1
)
&&
(
sArg2
.
empty
()
||
oInputParams
.
FromXml
(
sArg2
)))
...
...
@@ -143,20 +143,30 @@ static std::wstring utf8_to_unicode(const char *src)
if
(
argc
>=
5
)
sArg4
=
std
::
wstring
(
argv
[
4
]);
if
(
argc
>=
6
)
sArg5
=
std
::
wstring
(
argv
[
5
]);
#endif
InputParams
oInputParams
;
oInputParams
.
m_sFileFrom
=
new
std
::
wstring
(
sArg1
);
oInputParams
.
m_sFileTo
=
new
std
::
wstring
(
sArg2
);
if
(
argc
>
3
)
if
(
sArg1
==
L"-detectmacro"
)
{
oInputParams
.
m_sFontDir
=
new
std
::
wstring
(
sArg3
);
InputParams
oInputParams
;
oInputParams
.
m_sFileFrom
=
new
std
::
wstring
(
sArg2
);
result
=
NExtractTools
::
detectMacroInFile
(
oInputParams
);
}
if
(
argc
>
4
)
else
{
oInputParams
.
m_sPassword
=
new
std
::
wstring
(
sArg4
);
oInputParams
.
m_sSavePassword
=
new
std
::
wstring
(
sArg4
);
InputParams
oInputParams
;
oInputParams
.
m_sFileFrom
=
new
std
::
wstring
(
sArg1
);
oInputParams
.
m_sFileTo
=
new
std
::
wstring
(
sArg2
);
if
(
argc
>
3
)
{
oInputParams
.
m_sFontDir
=
new
std
::
wstring
(
sArg3
);
}
if
(
argc
>
4
)
{
oInputParams
.
m_sPassword
=
new
std
::
wstring
(
sArg4
);
oInputParams
.
m_sSavePassword
=
new
std
::
wstring
(
sArg4
);
}
result
=
NExtractTools
::
fromInputParams
(
oInputParams
);
}
result
=
NExtractTools
::
fromInputParams
(
oInputParams
);
}
return
getReturnErrorCode
(
result
);
...
...
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