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
89aba918
Commit
89aba918
authored
Aug 14, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OoxFormat - read/write vbaProject in binary
parent
47c1e6f6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
11 deletions
+68
-11
ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp
ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp
+1
-0
ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
+1
-0
ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp
ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp
+2
-0
Common/DocxFormat/Source/DocxFormat/Media/Media.h
Common/DocxFormat/Source/DocxFormat/Media/Media.h
+4
-1
Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp
.../DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp
+0
-2
XlsxSerializerCom/Common/BinReaderWriterDefines.h
XlsxSerializerCom/Common/BinReaderWriterDefines.h
+2
-1
XlsxSerializerCom/Reader/BinaryWriter.h
XlsxSerializerCom/Reader/BinaryWriter.h
+22
-2
XlsxSerializerCom/Writer/BinaryReader.h
XlsxSerializerCom/Writer/BinaryReader.h
+36
-5
No files found.
ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp
View file @
89aba918
...
...
@@ -39,6 +39,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/Base64.h"
...
...
ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
View file @
89aba918
...
...
@@ -63,6 +63,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalImage.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalAudio.h"
...
...
ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp
View file @
89aba918
...
...
@@ -42,6 +42,8 @@
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
namespace
PPTX
{
namespace
Logic
...
...
Common/DocxFormat/Source/DocxFormat/Media/Media.h
View file @
89aba918
...
...
@@ -78,8 +78,11 @@ namespace OOX
{
return
m_filename
;
}
void
copy_to
(
const
CPath
&
path
)
const
v
irtual
v
oid
copy_to
(
const
CPath
&
path
)
const
{
OOX
::
CPath
pathSaveItem
=
path
+
FILE_SEPARATOR_STR
+
m_filename
.
GetFilename
();
NSFile
::
CFileBinary
::
Copy
(
m_filename
.
GetPath
(),
pathSaveItem
.
GetPath
());
}
virtual
const
CPath
DefaultDirectory
()
const
{
...
...
Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp
View file @
89aba918
...
...
@@ -182,8 +182,6 @@ namespace OOX
return
smart_ptr
<
OOX
::
File
>
(
new
OOX
::
ActiveX_xml
(
oRootPath
,
oFileName
));
else
if
(
pRelation
->
Type
()
==
OOX
::
FileTypes
::
ActiveX_bin
)
return
smart_ptr
<
OOX
::
File
>
(
new
OOX
::
ActiveX_bin
(
oFileName
));
else
if
(
pRelation
->
Type
()
==
OOX
::
FileTypes
::
VbaProject
)
return
smart_ptr
<
OOX
::
File
>
(
new
OOX
::
VbaProject
(
oRootPath
,
oFileName
));
return
smart_ptr
<
OOX
::
File
>
(
new
UnknowTypeFile
()
);
}
...
...
XlsxSerializerCom/Common/BinReaderWriterDefines.h
View file @
89aba918
...
...
@@ -191,7 +191,8 @@ namespace BinXlsxRW
PivotCache
=
8
,
ExternalBook
=
9
,
OleLink
=
10
,
DdeLink
=
11
DdeLink
=
11
,
VbaProject
=
12
};}
namespace
c_oSerWorkbookPrTypes
{
enum
c_oSerWorkbookPrTypes
{
...
...
XlsxSerializerCom/Reader/BinaryWriter.h
View file @
89aba918
...
...
@@ -38,6 +38,7 @@
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/OfficeFileFormats.h"
#include "../../Common/Base64.h"
...
...
@@ -1521,6 +1522,14 @@ namespace BinXlsxRW
WriteExternalReferences
(
workbook
.
m_oExternalReferences
.
get
(),
workbook
);
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
smart_ptr
<
OOX
::
File
>
vbaProject
=
workbook
.
Get
(
OOX
::
FileTypes
::
VbaProject
);
if
(
vbaProject
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSerWorkbookTypes
::
VbaProject
);
WriteVbaProject
(
vbaProject
.
smart_dynamic_cast
<
OOX
::
VbaProject
>
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
};
void
WriteWorkbookPr
(
const
OOX
::
Spreadsheet
::
CWorkbookPr
&
workbookPr
)
{
...
...
@@ -1925,7 +1934,6 @@ namespace BinXlsxRW
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteDefinedName
(
const
OOX
::
Spreadsheet
::
CDefinedName
&
definedName
)
{
int
nCurPos
=
0
;
...
...
@@ -1961,7 +1969,19 @@ namespace BinXlsxRW
m_oBcw
.
m_oStream
.
WriteBYTE
(
c_oSerDefinedNameTypes
::
Comment
);
m_oBcw
.
m_oStream
.
WriteStringW
(
definedName
.
m_oComment
.
get2
());
}
};
}
void
WriteVbaProject
(
smart_ptr
<
OOX
::
VbaProject
>
&
fileVbaProject
)
{
std
::
wstring
file_name
=
fileVbaProject
->
filename
().
GetFilename
();
m_oBcw
.
m_oStream
.
WriteBYTE
(
NSBinPptxRW
::
g_nodeAttributeStart
);
m_oBcw
.
m_oStream
.
WriteString1
(
0
,
file_name
);
m_oBcw
.
m_oStream
.
WriteBYTE
(
NSBinPptxRW
::
g_nodeAttributeEnd
);
//... todooo write parsing vba project
//copy file bin
fileVbaProject
->
copy_to
(
m_oBcw
.
m_oStream
.
m_pCommon
->
m_pImageManager
->
m_strDstMedia
);
}
};
class
BinaryWorksheetTableWriter
{
...
...
XlsxSerializerCom/Writer/BinaryReader.h
View file @
89aba918
...
...
@@ -36,6 +36,8 @@
#include "../../Common/ATLDefine.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../DesktopEditor/common/Path.h"
#include "../../DesktopEditor/common/Directory.h"
...
...
@@ -1504,8 +1506,10 @@ namespace BinXlsxRW {
{
OOX
::
Spreadsheet
::
CWorkbook
&
m_oWorkbook
;
std
::
map
<
long
,
NSCommon
::
smart_ptr
<
OOX
::
File
>>&
m_mapPivotCacheDefinitions
;
const
std
::
wstring
&
m_sDestinationDir
;
public:
BinaryWorkbookTableReader
(
NSBinPptxRW
::
CBinaryFileReader
&
oBufferedStream
,
OOX
::
Spreadsheet
::
CWorkbook
&
oWorkbook
,
std
::
map
<
long
,
NSCommon
::
smart_ptr
<
OOX
::
File
>>&
mapPivotCacheDefinitions
)
:
Binary_CommonReader
(
oBufferedStream
),
m_oWorkbook
(
oWorkbook
),
m_mapPivotCacheDefinitions
(
mapPivotCacheDefinitions
)
BinaryWorkbookTableReader
(
NSBinPptxRW
::
CBinaryFileReader
&
oBufferedStream
,
OOX
::
Spreadsheet
::
CWorkbook
&
oWorkbook
,
std
::
map
<
long
,
NSCommon
::
smart_ptr
<
OOX
::
File
>>&
mapPivotCacheDefinitions
,
const
std
::
wstring
&
sDestinationDir
)
:
Binary_CommonReader
(
oBufferedStream
),
m_oWorkbook
(
oWorkbook
),
m_mapPivotCacheDefinitions
(
mapPivotCacheDefinitions
),
m_sDestinationDir
(
sDestinationDir
)
{
}
int
Read
()
...
...
@@ -1542,6 +1546,10 @@ namespace BinXlsxRW {
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadPivotCaches
,
this
,
poResult
);
m_oWorkbook
.
m_oPivotCachesXml
->
append
(
L"</pivotCaches>"
);
}
else
if
(
c_oSerWorkbookTypes
::
VbaProject
==
type
)
{
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadVbaProject
,
this
,
poResult
);
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
...
...
@@ -2068,7 +2076,7 @@ namespace BinXlsxRW {
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
}
;
}
int
ReadPivotCache
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
PivotCachesTemp
*
pPivotCachesTemp
=
static_cast
<
PivotCachesTemp
*>
(
poResult
);
...
...
@@ -2090,13 +2098,36 @@ namespace BinXlsxRW {
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
}
int
ReadVbaProject
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSerWorkbookTypes
::
VbaProject
==
type
)
{
std
::
wstring
file_name
=
m_oBufferedStream
.
GetString3
(
length
);
OOX
::
CPath
inputPath
=
m_oBufferedStream
.
m_strFolder
+
FILE_SEPARATOR_STR
+
_T
(
"media"
)
+
FILE_SEPARATOR_STR
+
file_name
;
OOX
::
CPath
outputPath
=
m_sDestinationDir
+
FILE_SEPARATOR_STR
+
_T
(
"xl"
)
+
FILE_SEPARATOR_STR
+
_T
(
"vbaProject.bin"
);
NSFile
::
CFileBinary
::
Copy
(
inputPath
.
GetPath
(),
outputPath
.
GetPath
());
smart_ptr
<
OOX
::
VbaProject
>
oFile
;
oFile
->
set_filename
(
outputPath
);
const
OOX
::
RId
oRId
=
m_oWorkbook
.
Add
(
oFile
.
smart_dynamic_cast
<
OOX
::
File
>
());
return
res
;
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
}
};
class
BinaryCommentReader
:
public
Binary_CommonReader
<
BinaryCommentReader
>
{
OOX
::
Spreadsheet
::
CWorksheet
*
m_pCurWorksheet
;
public:
BinaryCommentReader
(
NSBinPptxRW
::
CBinaryFileReader
&
oBufferedStream
,
OOX
::
Spreadsheet
::
CWorksheet
*
pCurWorksheet
)
:
Binary_CommonReader
(
oBufferedStream
),
m_pCurWorksheet
(
pCurWorksheet
)
BinaryCommentReader
(
NSBinPptxRW
::
CBinaryFileReader
&
oBufferedStream
,
OOX
::
Spreadsheet
::
CWorksheet
*
pCurWorksheet
)
:
Binary_CommonReader
(
oBufferedStream
),
m_pCurWorksheet
(
pCurWorksheet
)
{
}
int
Read
(
long
length
,
void
*
poResult
)
...
...
@@ -4414,7 +4445,7 @@ namespace BinXlsxRW {
if
(
-
1
!=
nWorkbookOffBits
)
{
oBufferedStream
.
Seek
(
nWorkbookOffBits
);
res
=
BinaryWorkbookTableReader
(
oBufferedStream
,
*
pWorkbook
,
m_mapPivotCacheDefinitions
).
Read
();
res
=
BinaryWorkbookTableReader
(
oBufferedStream
,
*
pWorkbook
,
m_mapPivotCacheDefinitions
,
sOutDir
).
Read
();
if
(
c_oSerConstants
::
ReadOk
!=
res
)
return
res
;
}
...
...
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