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
d8c7d414
Commit
d8c7d414
authored
Sep 20, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DocFormat - vba macros
parent
b69051a5
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
273 additions
and
60 deletions
+273
-60
ASCOfficeDocFile/DocDocxConverter/ContentTypes.h
ASCOfficeDocFile/DocDocxConverter/ContentTypes.h
+1
-0
ASCOfficeDocFile/DocDocxConverter/Converter.cpp
ASCOfficeDocFile/DocDocxConverter/Converter.cpp
+10
-12
ASCOfficeDocFile/DocDocxConverter/Converter.h
ASCOfficeDocFile/DocDocxConverter/Converter.h
+1
-1
ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp
ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp
+1
-2
ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp
ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp
+8
-2
ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h
ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h
+4
-2
ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h
ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h
+76
-1
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
+17
-4
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
+5
-6
ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp
ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp
+30
-3
ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h
ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h
+2
-1
ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp
ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp
+2
-2
ASCOfficeDocFile/DocFormatLib/DocFormatLib.h
ASCOfficeDocFile/DocFormatLib/DocFormatLib.h
+1
-1
ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp
ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp
+13
-3
ASCOfficeXlsFile2/source/XlsFormat/Binary/CompoundFile.cpp
ASCOfficeXlsFile2/source/XlsFormat/Binary/CompoundFile.cpp
+20
-6
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/ODRAW/OfficeArtContainer.cpp
...Format/Logic/Biff_structures/ODRAW/OfficeArtContainer.cpp
+2
-0
X2tConverter/src/ASCConverters.cpp
X2tConverter/src/ASCConverters.cpp
+71
-11
X2tConverter/src/ASCConverters.h
X2tConverter/src/ASCConverters.h
+2
-0
X2tConverter/src/cextracttools.cpp
X2tConverter/src/cextracttools.cpp
+1
-1
X2tConverter/src/cextracttools.h
X2tConverter/src/cextracttools.h
+6
-2
No files found.
ASCOfficeDocFile/DocDocxConverter/ContentTypes.h
View file @
d8c7d414
...
...
@@ -157,6 +157,7 @@ namespace OpenXmlRelationshipTypes
static
const
wchar_t
*
OleObject
=
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"
;
static
const
wchar_t
*
GlossaryDocument
=
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"
;
static
const
wchar_t
*
Package
=
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"
;
static
const
wchar_t
*
VbaProject
=
L"http://schemas.microsoft.com/office/2006/relationships/vbaProject"
;
}
namespace
MicrosoftWordRelationshipTypes
...
...
ASCOfficeDocFile/DocDocxConverter/Converter.cpp
View file @
d8c7d414
...
...
@@ -65,7 +65,7 @@ namespace DocFileFormat
{
ConversionContext
context
(
doc
,
docx
);
//Write styles.xml
//Write styles.xml
if
(
doc
->
Styles
)
{
StyleSheetMapping
styleSheetMapping
(
&
context
);
...
...
@@ -88,9 +88,7 @@ namespace DocFileFormat
return
S_FALSE
;
}
}
//Write numbering.xml
//Write numbering.xml
if
(
doc
->
listTable
)
{
NumberingMapping
numberingMapping
(
&
context
);
...
...
@@ -110,7 +108,7 @@ namespace DocFileFormat
}
}
//Write fontTable.xml
//Write fontTable.xml
if
(
doc
->
FontTable
)
{
FontTableMapping
fontTableMapping
(
&
context
);
...
...
@@ -130,7 +128,7 @@ namespace DocFileFormat
}
}
//write the footnotes
//write the footnotes
FootnotesMapping
footnotesMapping
(
&
context
);
doc
->
Convert
(
&
footnotesMapping
);
...
...
@@ -147,7 +145,7 @@ namespace DocFileFormat
}
}
//write the endnotes
//write the endnotes
EndnotesMapping
endnotesMapping
(
&
context
);
doc
->
Convert
(
&
endnotesMapping
);
...
...
@@ -164,7 +162,7 @@ namespace DocFileFormat
}
}
//write the comments
//write the comments
CommentsMapping
commentsMapping
(
&
context
);
doc
->
Convert
(
&
commentsMapping
);
...
...
@@ -181,13 +179,13 @@ namespace DocFileFormat
}
}
//write settings.xml at last because of the rsid list
//write settings.xml at last because of the rsid list
if
(
doc
->
DocProperties
)
{
SettingsMapping
settingsMapping
(
&
context
);
doc
->
DocProperties
->
Convert
(
&
settingsMapping
);
}
if
(
progress
!=
NULL
)
{
progress
->
OnProgress
(
progress
->
caller
,
DOC_ONPROGRESSEVENT_ID
,
975000
);
...
...
@@ -204,7 +202,7 @@ namespace DocFileFormat
return
S_OK
;
}
long
Converter
::
LoadAndConvert
(
const
std
::
wstring
&
strSrcFile
,
const
std
::
wstring
&
strDstDirectory
,
const
std
::
wstring
&
password
,
const
ProgressCallback
*
progress
)
long
Converter
::
LoadAndConvert
(
const
std
::
wstring
&
strSrcFile
,
const
std
::
wstring
&
strDstDirectory
,
const
std
::
wstring
&
password
,
const
ProgressCallback
*
progress
,
bool
&
bMacros
)
{
long
result
=
S_FALSE
;
...
...
@@ -219,7 +217,7 @@ namespace DocFileFormat
if
(
result
==
S_OK
)
{
docx
.
SaveDocument
();
docx
.
SaveDocument
(
bMacros
);
if
(
progress
)
progress
->
OnProgress
(
progress
->
caller
,
DOC_ONPROGRESSEVENT_ID
,
1000000
);
...
...
ASCOfficeDocFile/DocDocxConverter/Converter.h
View file @
d8c7d414
...
...
@@ -48,7 +48,7 @@ namespace DocFileFormat
std
::
wstring
m_sTempFolder
;
long
LoadAndConvert
(
const
std
::
wstring
&
strSrcFile
,
const
std
::
wstring
&
strDstDirectory
,
const
std
::
wstring
&
password
,
const
ProgressCallback
*
progress
);
long
LoadAndConvert
(
const
std
::
wstring
&
strSrcFile
,
const
std
::
wstring
&
strDstDirectory
,
const
std
::
wstring
&
password
,
const
ProgressCallback
*
progress
,
bool
&
bMacros
);
private:
long
Convert
(
WordDocument
*
doc
,
WordprocessingDocument
*
docx
,
const
ProgressCallback
*
progress
);
...
...
ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp
View file @
d8c7d414
...
...
@@ -50,8 +50,7 @@ namespace DocFileFormat
void
MainDocumentMapping
::
Apply
(
IVisitable
*
visited
)
{
m_document
=
static_cast
<
WordDocument
*>
(
visited
);
m_context
->
_docx
->
RegisterDocument
();
// Header
m_pXmlWriter
->
WriteNodeBegin
(
L"?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?"
);
m_pXmlWriter
->
WriteNodeBegin
(
L"w:document"
,
TRUE
);
...
...
ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp
View file @
d8c7d414
...
...
@@ -73,7 +73,6 @@ namespace DocFileFormat
NSDirectory
::
CreateDirectory
(
m_strOutputPath
+
FILE_SEPARATOR_STR
+
L"word"
+
FILE_SEPARATOR_STR
+
L"_rels"
);
WriteRelsFile
(
DocumentRelationshipsFile
);
WriteRelsFile
(
FootnotesRelationshipsFile
);
...
...
@@ -199,7 +198,14 @@ namespace DocFileFormat
{
return
AddPart
(
L"word"
,
L"document.xml"
,
WordprocessingMLContentTypes
::
MainDocument
,
L""
);
}
int
OpenXmlPackage
::
RegisterDocumentMacros
()
{
return
AddPart
(
L"word"
,
L"document.xml"
,
WordprocessingMLContentTypes
::
MainDocumentMacro
,
L""
);
}
int
OpenXmlPackage
::
RegisterVbaProject
()
{
return
AddPart
(
L"word"
,
L"vbaProject.bin"
,
MicrosoftWordContentTypes
::
VbaProject
,
OpenXmlRelationshipTypes
::
VbaProject
);
}
int
OpenXmlPackage
::
RegisterFontTable
()
{
return
AddPart
(
L"word"
,
L"fontTable.xml"
,
WordprocessingMLContentTypes
::
FontTable
,
OpenXmlRelationshipTypes
::
FontTable
);
...
...
ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h
View file @
d8c7d414
...
...
@@ -118,6 +118,8 @@ namespace DocFileFormat
class
OpenXmlPackage
{
public:
const
WordDocument
*
docFile
;
private:
ContentTypesFile
DocumentContentTypesFile
;
RelationshipsFile
MainRelationshipsFile
;
...
...
@@ -137,8 +139,6 @@ namespace DocFileFormat
int
_footerCounter
;
int
_oleCounter
;
const
WordDocument
*
docFile
;
int
AddHeaderPart
(
const
std
::
wstring
&
fileName
,
const
std
::
wstring
&
relationshipType
=
L""
,
const
std
::
wstring
&
targetMode
=
L""
);
int
AddFooterPart
(
const
std
::
wstring
&
fileName
,
const
std
::
wstring
&
relationshipType
=
L""
,
const
std
::
wstring
&
targetMode
=
L""
);
int
AddFootnotesPart
(
const
std
::
wstring
&
fileName
,
const
std
::
wstring
&
relationshipType
=
L""
,
const
std
::
wstring
&
targetMode
=
L""
);
...
...
@@ -166,6 +166,7 @@ namespace DocFileFormat
HRESULT
SaveEmbeddedObject
(
const
std
::
wstring
&
fileName
,
const
std
::
string
&
data
);
int
RegisterDocument
();
int
RegisterDocumentMacros
();
int
RegisterFontTable
();
int
RegisterNumbering
();
int
RegisterSettings
();
...
...
@@ -179,5 +180,6 @@ namespace DocFileFormat
int
RegisterOLEObject
(
const
IMapping
*
mapping
,
const
std
::
wstring
&
objectType
);
int
RegisterPackage
(
const
IMapping
*
mapping
,
const
std
::
wstring
&
objectType
);
int
RegisterExternalOLEObject
(
const
IMapping
*
mapping
,
const
std
::
wstring
&
objectType
,
const
std
::
wstring
&
uri
);
int
RegisterVbaProject
();
};
}
ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h
View file @
d8c7d414
...
...
@@ -42,7 +42,6 @@ namespace DocFileFormat
{
}
~
StructuredStorageReader
()
{
if
(
m_pStorage
)
...
...
@@ -62,6 +61,12 @@ namespace DocFileFormat
}
return
false
;
}
bool
isDirectory
(
const
std
::
string
&
name
)
{
if
(
!
m_pStorage
)
return
false
;
return
m_pStorage
->
isDirectory
(
name
);
}
bool
GetStream
(
const
char
*
path
,
POLE
::
Stream
**
ppStream
)
{
...
...
@@ -79,8 +84,78 @@ namespace DocFileFormat
{
return
m_pStorage
;
}
void
copy
(
int
indent
,
std
::
string
path
,
POLE
::
Storage
*
storageOut
,
bool
withRoot
=
true
)
{
std
::
list
<
std
::
string
>
entries
,
entries_sort
;
entries
=
m_pStorage
->
entries
(
path
);
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
entries
.
begin
();
it
!=
entries
.
end
();
it
++
)
{
std
::
string
name
=
*
it
;
std
::
string
fullname
=
path
+
name
;
if
(
m_pStorage
->
isDirectory
(
fullname
)
)
{
entries_sort
.
push_back
(
name
);
}
else
{
entries_sort
.
push_front
(
name
);
}
}
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
entries_sort
.
begin
();
it
!=
entries_sort
.
end
();
it
++
)
{
std
::
string
name
=
*
it
;
std
::
string
fullname
=
path
+
name
;
if
(
m_pStorage
->
isDirectory
(
fullname
)
)
{
copy
(
indent
+
1
,
fullname
+
"/"
,
storageOut
,
withRoot
);
}
else
{
copy_stream
(
fullname
,
storageOut
,
withRoot
);
}
}
}
private:
void
copy_stream
(
std
::
string
streamName
,
POLE
::
Storage
*
storageOut
,
bool
withRoot
=
true
)
{
POLE
::
Stream
*
stream
=
new
POLE
::
Stream
(
m_pStorage
,
streamName
);
if
(
!
stream
)
return
;
stream
->
seek
(
0
);
int
size_stream
=
stream
->
size
();
if
(
withRoot
==
false
)
{
int
pos
=
streamName
.
find
(
"/"
);
if
(
pos
>=
0
)
streamName
=
streamName
.
substr
(
pos
+
1
);
}
POLE
::
Stream
*
streamNew
=
new
POLE
::
Stream
(
storageOut
,
streamName
,
true
,
size_stream
);
if
(
!
streamNew
)
return
;
unsigned
char
*
data_stream
=
new
unsigned
char
[
size_stream
];
if
(
data_stream
)
{
stream
->
read
(
data_stream
,
size_stream
);
streamNew
->
write
(
data_stream
,
size_stream
);
delete
[]
data_stream
;
data_stream
=
NULL
;
}
streamNew
->
flush
();
delete
streamNew
;
delete
stream
;
}
POLE
::
Storage
*
m_pStorage
;
};
...
...
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
View file @
d8c7d414
...
...
@@ -528,11 +528,24 @@ namespace DocFileFormat
}
void
WordDocument
::
DecryptStream
(
int
level
,
std
::
string
path
,
POLE
::
Storage
*
storageIn
,
POLE
::
Storage
*
storageOut
,
CRYPT
::
Decryptor
*
Decryptor
)
{
std
::
list
<
std
::
string
>
entries
;
std
::
list
<
std
::
string
>
entries
,
entries_sort
;
entries
=
storageIn
->
entries
(
path
);
std
::
list
<
std
::
string
>::
iterator
it
;
for
(
it
=
entries
.
begin
();
it
!=
entries
.
end
();
++
it
)
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
entries
.
begin
();
it
!=
entries
.
end
();
it
++
)
{
std
::
string
name
=
*
it
;
std
::
string
fullname
=
path
+
name
;
if
(
storageIn
->
isDirectory
(
fullname
)
)
{
entries_sort
.
push_back
(
name
);
}
else
{
entries_sort
.
push_front
(
name
);
}
}
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
entries_sort
.
begin
();
it
!=
entries_sort
.
end
();
++
it
)
{
std
::
string
name
=
*
it
;
std
::
string
fullname
=
path
+
name
;
...
...
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
View file @
d8c7d414
...
...
@@ -99,18 +99,17 @@ namespace DocFileFormat
bool
bOlderVersion
;
int
document_code_page
;
inline
StructuredStorageReader
*
GetStorage
()
const
{
return
m_pStorage
;
}
private:
bool
DecryptOfficeFile
(
CRYPT
::
Decryptor
*
Decryptor
);
bool
DecryptStream
(
std
::
string
streamName
,
POLE
::
Storage
*
storageIn
,
POLE
::
Storage
*
storageOut
,
CRYPT
::
Decryptor
*
Decryptor
);
void
DecryptStream
(
int
level
,
std
::
string
streamName
,
POLE
::
Storage
*
storageIn
,
POLE
::
Storage
*
storageOut
,
CRYPT
::
Decryptor
*
Decryptor
);
inline
StructuredStorageReader
*
GetStorage
()
const
{
return
m_pStorage
;
}
inline
OfficeArtContent
*
GetOfficeArt
()
{
return
officeArtContent
;
...
...
ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp
View file @
d8c7d414
...
...
@@ -180,10 +180,37 @@ namespace DocFileFormat
{
}
void
WordprocessingDocument
::
SaveDocument
()
void
WordprocessingDocument
::
SaveDocument
(
bool
&
bMacros
)
{
std
::
wstring
pathWord
=
m_strOutputPath
+
FILE_SEPARATOR_STR
+
L"word"
;
NSDirectory
::
CreateDirectory
(
pathWord
);
std
::
wstring
pathWord
=
m_strOutputPath
+
FILE_SEPARATOR_STR
+
L"word"
;
NSDirectory
::
CreateDirectory
(
pathWord
);
if
(
bMacros
&&
docFile
->
GetStorage
()
->
isDirectory
(
"Macros"
))
{
std
::
wstring
sVbaProjectFile
=
pathWord
+
FILE_SEPARATOR_STR
+
L"vbaProject.bin"
;
POLE
::
Storage
*
storageVbaProject
=
new
POLE
::
Storage
(
sVbaProjectFile
.
c_str
());
if
((
storageVbaProject
)
&&
(
storageVbaProject
->
open
(
true
,
true
)))
{
docFile
->
GetStorage
()
->
copy
(
0
,
"Macros/"
,
storageVbaProject
,
false
);
storageVbaProject
->
close
();
delete
storageVbaProject
;
RegisterDocumentMacros
();
RegisterVbaProject
();
//output_document->get_xl_files().add_vba_project();
}
else
bMacros
=
false
;
}
else
bMacros
=
false
;
if
(
!
bMacros
)
{
RegisterDocument
();
}
WritePackage
();
...
...
ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h
View file @
d8c7d414
...
...
@@ -76,6 +76,7 @@ namespace DocFileFormat
public:
WordprocessingDocument
(
const
std
::
wstring
&
_docxDirectory
,
const
WordDocument
*
_docFile
);
virtual
~
WordprocessingDocument
();
void
SaveDocument
();
void
SaveDocument
(
bool
&
bMacros
);
};
}
\ No newline at end of file
ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp
View file @
d8c7d414
...
...
@@ -34,14 +34,14 @@
#include "../DocDocxConverter/Converter.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
HRESULT
COfficeDocFile
::
LoadFromFile
(
const
std
::
wstring
&
docFile
,
const
std
::
wstring
&
docxDirectory
,
const
std
::
wstring
&
password
,
ProgressCallback
*
ffCallBack
)
HRESULT
COfficeDocFile
::
LoadFromFile
(
const
std
::
wstring
&
docFile
,
const
std
::
wstring
&
docxDirectory
,
const
std
::
wstring
&
password
,
bool
&
bMacros
,
ProgressCallback
*
ffCallBack
)
{
HRESULT
hr
=
S_FALSE
;
DocFileFormat
::
Converter
docToDocx
;
docToDocx
.
m_sTempFolder
=
m_sTempFolder
;
hr
=
docToDocx
.
LoadAndConvert
(
docFile
,
docxDirectory
,
password
,
ffCallBack
);
hr
=
docToDocx
.
LoadAndConvert
(
docFile
,
docxDirectory
,
password
,
ffCallBack
,
bMacros
);
return
hr
;
}
...
...
ASCOfficeDocFile/DocFormatLib/DocFormatLib.h
View file @
d8c7d414
...
...
@@ -53,7 +53,7 @@ public:
std
::
wstring
m_sTempFolder
;
HRESULT
LoadFromFile
(
const
std
::
wstring
&
sSrcFileName
,
const
std
::
wstring
&
sDstFileName
,
const
std
::
wstring
&
password
,
ProgressCallback
*
ffCallBack
=
NULL
);
HRESULT
LoadFromFile
(
const
std
::
wstring
&
sSrcFileName
,
const
std
::
wstring
&
sDstFileName
,
const
std
::
wstring
&
password
,
bool
&
bMacros
,
ProgressCallback
*
ffCallBack
=
NULL
);
HRESULT
SaveToFile
(
const
std
::
wstring
&
sDstFileName
,
const
std
::
wstring
&
sSrcFileName
,
ProgressCallback
*
ffCallBack
=
NULL
);
};
...
...
ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp
View file @
d8c7d414
...
...
@@ -54,17 +54,27 @@ int _tmain(int argc, _TCHAR* argv[])
if
(
argc
<
2
)
return
1
;
std
::
wstring
sSrcDoc
=
argv
[
1
];
std
::
wstring
sDstDocx
=
argc
>
2
?
argv
[
2
]
:
sSrcDoc
+
L"-my.docx"
;
std
::
wstring
sDstDocx
;
std
::
wstring
outputDir
=
NSDirectory
::
GetFolderPath
(
s
DstDocx
);
std
::
wstring
outputDir
=
NSDirectory
::
GetFolderPath
(
s
SrcDoc
);
std
::
wstring
dstTempPath
=
NSDirectory
::
CreateDirectoryWithUniqueName
(
outputDir
);
COfficeDocFile
docFile
;
docFile
.
m_sTempFolder
=
outputDir
;
HRESULT
hRes
=
docFile
.
LoadFromFile
(
sSrcDoc
,
dstTempPath
,
L"password"
,
NULL
);
bool
bMacros
=
true
;
HRESULT
hRes
=
docFile
.
LoadFromFile
(
sSrcDoc
,
dstTempPath
,
L"password"
,
bMacros
,
NULL
);
if
(
bMacros
)
{
sDstDocx
=
sSrcDoc
+
L"-my.docm"
;
}
else
{
sDstDocx
=
sSrcDoc
+
L"-my.docx"
;
}
if
(
hRes
==
S_OK
)
{
COfficeUtils
oCOfficeUtils
(
NULL
);
...
...
ASCOfficeXlsFile2/source/XlsFormat/Binary/CompoundFile.cpp
View file @
d8c7d414
...
...
@@ -134,12 +134,26 @@ void CompoundFile::copy_stream(std::string streamName, POLE::Storage * storageOu
void
CompoundFile
::
copy
(
int
indent
,
std
::
string
path
,
POLE
::
Storage
*
storageOut
,
bool
withRoot
)
{
std
::
list
<
std
::
string
>
entries
;
std
::
list
<
std
::
string
>
entries
,
entries_sort
;
entries
=
storage_
->
entries
(
path
);
std
::
list
<
std
::
string
>::
iterator
it
;
for
(
it
=
entries
.
begin
();
it
!=
entries
.
end
();
++
it
)
{
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
entries
.
begin
();
it
!=
entries
.
end
();
it
++
)
{
std
::
string
name
=
*
it
;
std
::
string
fullname
=
path
+
name
;
if
(
storage_
->
isDirectory
(
fullname
)
)
{
entries_sort
.
push_back
(
name
);
}
else
{
entries_sort
.
push_front
(
name
);
}
}
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
entries_sort
.
begin
();
it
!=
entries_sort
.
end
();
it
++
)
{
std
::
string
name
=
*
it
;
std
::
string
fullname
=
path
+
name
;
...
...
@@ -151,7 +165,7 @@ void CompoundFile::copy( int indent, std::string path, POLE::Storage * storageOu
{
copy_stream
(
fullname
,
storageOut
,
withRoot
);
}
}
}
}
CFStreamPtr
CompoundFile
::
getWorkbookStream
()
{
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/ODRAW/OfficeArtContainer.cpp
View file @
d8c7d414
...
...
@@ -206,6 +206,8 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
}
else
// If the found record is not implemented or unknown
{
if
(
rh_child
.
recType
==
0xf150
)
break
;
if
(
rh_child
.
size
()
>
record
.
getDataSize
()
-
container_beginning_ptr
)
break
;
try
...
...
X2tConverter/src/ASCConverters.cpp
View file @
d8c7d414
...
...
@@ -1914,7 +1914,7 @@ namespace NExtractTools
// doc -> docx
int
doc2docx
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
{
std
::
wstring
sResultDocxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"docx_unpacked"
);
NSDirectory
::
CreateDirectory
(
sResultDocxDir
);
...
...
@@ -1939,12 +1939,66 @@ namespace NExtractTools
return
AVS_FILEUTILS_ERROR_CONVERT_PASSWORD
;
}
return
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
int
doc2docx_dir
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
COfficeDocFile
docFile
;
docFile
.
m_sTempFolder
=
sTemp
;
bool
bMacros
=
false
;
long
hRes
=
docFile
.
LoadFromFile
(
sFrom
,
sTo
,
params
.
getPassword
(),
bMacros
,
NULL
);
if
(
AVS_ERROR_DRM
==
hRes
)
{
if
(
!
params
.
getDontSaveAdditional
())
{
copyOrigin
(
sFrom
,
*
params
.
m_sFileTo
);
}
return
AVS_FILEUTILS_ERROR_CONVERT_DRM
;
}
else
if
(
AVS_ERROR_PASSWORD
==
hRes
)
{
return
AVS_FILEUTILS_ERROR_CONVERT_PASSWORD
;
}
return
0
==
hRes
?
0
:
AVS_FILEUTILS_ERROR_CONVERT
;
}
// doc -> docm
int
doc2docm
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
std
::
wstring
sResultDocxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"docx_unpacked"
);
NSDirectory
::
CreateDirectory
(
sResultDocxDir
);
long
hRes
=
doc2docm_dir
(
sFrom
,
sResultDocxDir
,
sTemp
,
params
);
if
(
SUCCEEDED_X2T
(
hRes
))
{
COfficeUtils
oCOfficeUtils
(
NULL
);
if
(
S_OK
==
oCOfficeUtils
.
CompressFileOrDirectory
(
sResultDocxDir
,
sTo
,
true
))
return
0
;
}
else
if
(
AVS_ERROR_DRM
==
hRes
)
{
if
(
!
params
.
getDontSaveAdditional
())
{
copyOrigin
(
sFrom
,
*
params
.
m_sFileTo
);
}
return
AVS_FILEUTILS_ERROR_CONVERT_DRM
;
}
else
if
(
AVS_ERROR_PASSWORD
==
hRes
)
{
return
AVS_FILEUTILS_ERROR_CONVERT_PASSWORD
;
}
return
AVS_FILEUTILS_ERROR_CONVERT
;
}
int
doc2docm_dir
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
COfficeDocFile
docFile
;
docFile
.
m_sTempFolder
=
sTemp
;
long
hRes
=
docFile
.
LoadFromFile
(
sFrom
,
sTo
,
params
.
getPassword
(),
NULL
);
bool
bMacros
=
true
;
long
hRes
=
docFile
.
LoadFromFile
(
sFrom
,
sTo
,
params
.
getPassword
(),
bMacros
,
NULL
);
if
(
AVS_ERROR_DRM
==
hRes
)
{
if
(
!
params
.
getDontSaveAdditional
())
...
...
@@ -1962,7 +2016,7 @@ namespace NExtractTools
// doc -> doct
int
doc2doct
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
{
// 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"
);
...
...
@@ -1978,11 +2032,11 @@ namespace NExtractTools
}
return
nRes
;
}
}
// doc -> doct_bin
int
doc2doct_bin
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
{
std
::
wstring
sResultDocxDir
=
sTemp
+
FILE_SEPARATOR_STR
+
_T
(
"docx_unpacked"
);
NSDirectory
::
CreateDirectory
(
sResultDocxDir
);
...
...
@@ -1990,7 +2044,9 @@ namespace NExtractTools
COfficeDocFile
docFile
;
docFile
.
m_sTempFolder
=
sTemp
;
long
nRes
=
docFile
.
LoadFromFile
(
sFrom
,
sResultDocxDir
,
params
.
getPassword
(),
NULL
);
bool
bMacros
=
true
;
long
nRes
=
docFile
.
LoadFromFile
(
sFrom
,
sResultDocxDir
,
params
.
getPassword
(),
bMacros
,
NULL
);
if
(
SUCCEEDED_X2T
(
nRes
))
{
...
...
@@ -2017,17 +2073,17 @@ namespace NExtractTools
return
AVS_FILEUTILS_ERROR_CONVERT_PASSWORD
;
}
return
AVS_FILEUTILS_ERROR_CONVERT
;
}
}
int
docx_dir2doc
(
const
std
::
wstring
&
sDocxDir
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
)
{
{
return
AVS_FILEUTILS_ERROR_CONVERT
;
COfficeDocFile
docFile
;
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
,
bool
bFromChanges
,
const
std
::
wstring
&
sThemeDir
,
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"
);
...
...
@@ -3943,6 +3999,10 @@ namespace NExtractTools
{
result
=
doc2docx
(
sFileFrom
,
sFileTo
,
sTempDir
,
oInputParams
);
}
break
;
case
TCD_DOC2DOCM
:
{
result
=
doc2docm
(
sFileFrom
,
sFileTo
,
sTempDir
,
oInputParams
);
}
break
;
case
TCD_DOCT2RTF
:
{
result
=
doct2rtf
(
sFileFrom
,
sFileTo
,
sTempDir
,
bFromChanges
,
sThemeDir
,
oInputParams
);
...
...
X2tConverter/src/ASCConverters.h
View file @
d8c7d414
...
...
@@ -130,6 +130,8 @@ namespace NExtractTools
int
doc2doct
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
int
doc2doct_bin
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
int
docx_dir2doc
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
int
doc2docm
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
int
doc2docm_dir
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
int
xls2xlsx
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
int
xls2xlsx_dir
(
const
std
::
wstring
&
sFrom
,
const
std
::
wstring
&
sTo
,
const
std
::
wstring
&
sTemp
,
InputParams
&
params
);
...
...
X2tConverter/src/cextracttools.cpp
View file @
d8c7d414
...
...
@@ -240,7 +240,7 @@ namespace NExtractTools
case
AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC
:
{
if
(
0
==
sExt2
.
compare
(
_T
(
".docx"
)))
res
=
TCD_DOC2DOCX
;
else
if
(
0
==
sExt2
.
compare
(
_T
(
".docm"
)))
res
=
TCD_DOC2DOC
X
;
else
if
(
0
==
sExt2
.
compare
(
_T
(
".docm"
)))
res
=
TCD_DOC2DOC
M
;
else
if
(
0
==
sExt2
.
compare
(
_T
(
".doct"
)))
res
=
TCD_DOC2DOCT
;
else
if
(
0
==
sExt2
.
compare
(
_T
(
".bin"
)))
res
=
TCD_DOC2DOCT_BIN
;
}
break
;
...
...
X2tConverter/src/cextracttools.h
View file @
d8c7d414
...
...
@@ -112,7 +112,8 @@ namespace NExtractTools
TCD_DOC2DOCT
,
TCD_DOC2DOCT_BIN
,
TCD_DOC2DOCX
,
//doc 2
TCD_DOC2DOCM
,
//xls 2
TCD_XLS2XLST
,
TCD_XLS2XLST_BIN
,
TCD_XLS2XLSX
,
...
...
@@ -956,7 +957,10 @@ namespace NExtractTools
else
if
(
0
==
sArg3
.
compare
(
_T
(
"doc2docx"
)))
{
res
=
TCD_DOC2DOCX
;
}
else
if
(
0
==
sArg3
.
compare
(
_T
(
"rtf2docx"
)))
{
else
if
(
0
==
sArg3
.
compare
(
_T
(
"doc2docm"
)))
{
res
=
TCD_DOC2DOCM
;
}
else
if
(
0
==
sArg3
.
compare
(
_T
(
"rtf2docx"
)))
{
res
=
TCD_RTF2DOCX
;
}
else
if
(
0
==
sArg3
.
compare
(
_T
(
"docx2rtf"
)))
{
...
...
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