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
3c58cd96
Commit
3c58cd96
authored
Jun 05, 2017
by
Sergey Konovalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for bug 27765
parent
e50864fa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
808 additions
and
28 deletions
+808
-28
Common/DocxFormat/Source/DocxFormat/WritingElement.h
Common/DocxFormat/Source/DocxFormat/WritingElement.h
+7
-0
Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinks.h
...ocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinks.h
+454
-1
XlsxSerializerCom/Common/BinReaderWriterDefines.h
XlsxSerializerCom/Common/BinReaderWriterDefines.h
+23
-1
XlsxSerializerCom/Reader/BinaryWriter.h
XlsxSerializerCom/Reader/BinaryWriter.h
+143
-6
XlsxSerializerCom/Writer/BinaryReader.h
XlsxSerializerCom/Writer/BinaryReader.h
+181
-20
No files found.
Common/DocxFormat/Source/DocxFormat/WritingElement.h
View file @
3c58cd96
...
...
@@ -1092,6 +1092,13 @@ namespace OOX
et_x_SheetPr
,
et_x_Pane
,
et_x_ExternalBook
,
et_x_ExternalSheetNames
,
et_x_ExternalDefinedNames
,
et_x_ExternalDefinedName
,
et_x_ExternalSheetDataSet
,
et_x_ExternalSheetData
,
et_x_ExternalRow
,
et_x_ExternalCell
,
et_x_Selection
,
et_x_LegacyDrawingWorksheet
,
et_x_LegacyDrawingHFWorksheet
,
...
...
Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinks.h
View file @
3c58cd96
...
...
@@ -39,6 +39,427 @@ namespace OOX
{
namespace
Spreadsheet
{
class
CExternalSheetNames
:
public
WritingElementWithChilds
<
ComplexTypes
::
Spreadsheet
::
String
>
{
public:
WritingElement_AdditionConstructors
(
CExternalSheetNames
)
CExternalSheetNames
()
{
}
virtual
~
CExternalSheetNames
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
if
(
oReader
.
IsEmptyNode
()
)
return
;
int
nCurDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"sheetName"
==
sName
)
{
m_arrItems
.
push_back
(
new
ComplexTypes
::
Spreadsheet
::
String
(
oReader
));
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<sheetNames>"
);
for
(
size_t
i
=
0
;
i
<
m_arrItems
.
size
();
++
i
)
{
writer
.
WriteString
(
L"<sheetName "
);
writer
.
WriteString
(
m_arrItems
[
i
]
->
ToString
());
writer
.
WriteString
(
L"/>"
);
}
writer
.
WriteString
(
L"</sheetNames>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalSheetNames
;
}
};
class
CExternalDefinedName
:
public
WritingElement
{
public:
WritingElement_AdditionConstructors
(
CExternalDefinedName
)
CExternalDefinedName
()
{
}
virtual
~
CExternalDefinedName
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
ReadAttributes
(
oReader
);
if
(
!
oReader
.
IsEmptyNode
()
)
oReader
.
ReadTillEnd
();
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<definedName"
);
WritingStringNullableAttrString
(
L"name"
,
m_oName
,
m_oName
.
get
());
WritingStringNullableAttrString
(
L"refersTo"
,
m_oRefersTo
,
m_oRefersTo
.
get
());
WritingStringNullableAttrInt
(
L"sheetId"
,
m_oSheetId
,
m_oSheetId
->
GetValue
());
writer
.
WriteString
(
L"/>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalDefinedName
;
}
void
ReadAttributes
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
WritingElement_ReadAttributes_Start
(
oReader
)
WritingElement_ReadAttributes_Read_if
(
oReader
,
_T
(
"name"
),
m_oName
)
WritingElement_ReadAttributes_Read_else_if
(
oReader
,
_T
(
"refersTo"
),
m_oRefersTo
)
WritingElement_ReadAttributes_Read_else_if
(
oReader
,
_T
(
"sheetId"
),
m_oSheetId
)
WritingElement_ReadAttributes_End
(
oReader
)
}
public:
nullable
<
std
::
wstring
>
m_oName
;
nullable
<
std
::
wstring
>
m_oRefersTo
;
nullable
<
SimpleTypes
::
CUnsignedDecimalNumber
<>>
m_oSheetId
;
};
class
CExternalDefinedNames
:
public
WritingElementWithChilds
<
CExternalDefinedName
>
{
public:
WritingElement_AdditionConstructors
(
CExternalDefinedNames
)
CExternalDefinedNames
()
{
}
virtual
~
CExternalDefinedNames
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
if
(
oReader
.
IsEmptyNode
()
)
return
;
int
nCurDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"definedName"
==
sName
)
{
m_arrItems
.
push_back
(
new
CExternalDefinedName
(
oReader
));
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<definedNames>"
);
for
(
size_t
i
=
0
;
i
<
m_arrItems
.
size
();
++
i
)
{
m_arrItems
[
i
]
->
toXML
(
writer
);
}
writer
.
WriteString
(
L"</definedNames>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalDefinedNames
;
}
};
class
CExternalCell
:
public
WritingElement
{
public:
WritingElement_AdditionConstructors
(
CExternalCell
)
CExternalCell
()
{
}
virtual
~
CExternalCell
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
ReadAttributes
(
oReader
);
if
(
oReader
.
IsEmptyNode
()
)
return
;
int
nCurDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"v"
==
sName
)
{
m_oValue
=
oReader
;
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<cell"
);
WritingStringNullableAttrString
(
L"r"
,
m_oRef
,
m_oRef
.
get
());
WritingStringNullableAttrString
(
L"t"
,
m_oType
,
m_oType
->
ToString
());
WritingStringNullableAttrInt
(
L"vm"
,
m_oValueMetadata
,
m_oValueMetadata
->
GetValue
());
writer
.
WriteString
(
L">"
);
if
(
m_oValue
.
IsInit
())
m_oValue
->
toXML2
(
writer
,
_T
(
"v"
));
writer
.
WriteString
(
L"</cell>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalCell
;
}
void
ReadAttributes
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
WritingElement_ReadAttributes_Start
(
oReader
)
WritingElement_ReadAttributes_Read_if
(
oReader
,
_T
(
"r"
),
m_oRef
)
WritingElement_ReadAttributes_Read_else_if
(
oReader
,
_T
(
"t"
),
m_oType
)
WritingElement_ReadAttributes_Read_else_if
(
oReader
,
_T
(
"vm"
),
m_oValueMetadata
)
WritingElement_ReadAttributes_End
(
oReader
)
}
public:
nullable
<
std
::
wstring
>
m_oRef
;
nullable
<
SimpleTypes
::
Spreadsheet
::
CCellTypeType
<>>
m_oType
;
nullable
<
SimpleTypes
::
CUnsignedDecimalNumber
<>>
m_oValueMetadata
;
nullable
<
CText
>
m_oValue
;
};
class
CExternalRow
:
public
WritingElementWithChilds
<
CExternalCell
>
{
public:
WritingElement_AdditionConstructors
(
CExternalRow
)
CExternalRow
()
{
}
virtual
~
CExternalRow
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
ReadAttributes
(
oReader
);
if
(
oReader
.
IsEmptyNode
()
)
return
;
int
nCurDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"cell"
==
sName
)
{
m_arrItems
.
push_back
(
new
CExternalCell
(
oReader
));
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<row"
);
WritingStringNullableAttrInt
(
L"r"
,
m_oR
,
m_oR
->
GetValue
());
writer
.
WriteString
(
L">"
);
for
(
size_t
i
=
0
;
i
<
m_arrItems
.
size
();
++
i
)
{
m_arrItems
[
i
]
->
toXML
(
writer
);
}
writer
.
WriteString
(
L"</row>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalRow
;
}
void
ReadAttributes
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
WritingElement_ReadAttributes_Start
(
oReader
)
WritingElement_ReadAttributes_ReadSingle
(
oReader
,
_T
(
"r"
),
m_oR
)
WritingElement_ReadAttributes_End
(
oReader
)
}
public:
nullable
<
SimpleTypes
::
CUnsignedDecimalNumber
<>>
m_oR
;
};
class
CExternalSheetData
:
public
WritingElementWithChilds
<
CExternalRow
>
{
public:
WritingElement_AdditionConstructors
(
CExternalSheetData
)
CExternalSheetData
()
{
}
virtual
~
CExternalSheetData
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
ReadAttributes
(
oReader
);
if
(
oReader
.
IsEmptyNode
()
)
return
;
int
nCurDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"row"
==
sName
)
{
m_arrItems
.
push_back
(
new
CExternalRow
(
oReader
));
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<sheetData"
);
WritingStringNullableAttrInt
(
L"sheetId"
,
m_oSheetId
,
m_oSheetId
->
GetValue
());
WritingStringNullableAttrBool
(
L"refreshError"
,
m_oRefreshError
);
writer
.
WriteString
(
L">"
);
for
(
size_t
i
=
0
;
i
<
m_arrItems
.
size
();
++
i
)
{
m_arrItems
[
i
]
->
toXML
(
writer
);
}
writer
.
WriteString
(
L"</sheetData>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalSheetData
;
}
void
ReadAttributes
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
WritingElement_ReadAttributes_Start
(
oReader
)
WritingElement_ReadAttributes_Read_if
(
oReader
,
_T
(
"sheetId"
),
m_oSheetId
)
WritingElement_ReadAttributes_Read_else_if
(
oReader
,
_T
(
"refreshError"
),
m_oRefreshError
)
WritingElement_ReadAttributes_End
(
oReader
)
}
public:
nullable
<
SimpleTypes
::
CUnsignedDecimalNumber
<>>
m_oSheetId
;
nullable
<
SimpleTypes
::
COnOff
<
SimpleTypes
::
onoffTrue
>>
m_oRefreshError
;
};
class
CExternalSheetDataSet
:
public
WritingElementWithChilds
<
CExternalSheetData
>
{
public:
WritingElement_AdditionConstructors
(
CExternalSheetDataSet
)
CExternalSheetDataSet
()
{
}
virtual
~
CExternalSheetDataSet
()
{
}
public:
virtual
void
fromXML
(
XmlUtils
::
CXmlNode
&
oNode
)
{
// TO DO: Реализовать
}
virtual
void
fromXML
(
XmlUtils
::
CXmlLiteReader
&
oReader
)
{
if
(
oReader
.
IsEmptyNode
()
)
return
;
int
nCurDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"sheetData"
==
sName
)
{
m_arrItems
.
push_back
(
new
CExternalSheetData
(
oReader
));
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
{
writer
.
WriteString
(
L"<sheetDataSet>"
);
for
(
size_t
i
=
0
;
i
<
m_arrItems
.
size
();
++
i
)
{
m_arrItems
[
i
]
->
toXML
(
writer
);
}
writer
.
WriteString
(
L"</sheetDataSet>"
);
}
virtual
std
::
wstring
toXML
()
const
{
NSStringUtils
::
CStringBuilder
writer
;
toXML
(
writer
);
return
writer
.
GetData
().
c_str
();
}
virtual
EElementType
getType
()
const
{
return
et_x_ExternalSheetDataSet
;
}
};
class
CExternalBook
:
public
WritingElement
{
public:
...
...
@@ -67,6 +488,19 @@ namespace OOX
while
(
oReader
.
ReadNextSiblingNode
(
nCurDepth
)
)
{
std
::
wstring
sName
=
oReader
.
GetName
();
if
(
L"sheetNames"
==
sName
)
{
m_oSheetNames
=
oReader
;
}
else
if
(
L"definedNames"
==
sName
)
{
m_oDefinedNames
=
oReader
;
}
else
if
(
L"sheetDataSet"
==
sName
)
{
m_oSheetDataSet
=
oReader
;
}
}
}
virtual
void
toXML
(
NSStringUtils
::
CStringBuilder
&
writer
)
const
...
...
@@ -78,7 +512,20 @@ namespace OOX
writer
.
WriteString
(
m_oRid
->
ToString
());
writer
.
WriteString
(
L"
\"
xmlns:r=
\"
http://schemas.openxmlformats.org/officeDocument/2006/relationships
\"
"
);
}
writer
.
WriteString
(
L"/>"
);
writer
.
WriteString
(
L">"
);
if
(
m_oSheetNames
.
IsInit
())
{
m_oSheetNames
->
toXML
(
writer
);
}
if
(
m_oDefinedNames
.
IsInit
())
{
m_oDefinedNames
->
toXML
(
writer
);
}
if
(
m_oSheetDataSet
.
IsInit
())
{
m_oSheetDataSet
->
toXML
(
writer
);
}
writer
.
WriteString
(
L"</externalBook>"
);
}
virtual
std
::
wstring
toXML
()
const
{
...
...
@@ -99,6 +546,10 @@ namespace OOX
public:
nullable
<
SimpleTypes
::
CRelationshipId
>
m_oRid
;
nullable
<
CExternalSheetNames
>
m_oSheetNames
;
nullable
<
CExternalDefinedNames
>
m_oDefinedNames
;
nullable
<
CExternalSheetDataSet
>
m_oSheetDataSet
;
};
class
CExternalLink
:
public
OOX
::
FileGlobalEnumerated
,
public
OOX
::
IFileContainer
...
...
@@ -106,9 +557,11 @@ namespace OOX
public:
CExternalLink
()
{
m_bSpreadsheets
=
true
;
}
CExternalLink
(
const
CPath
&
oRootPath
,
const
CPath
&
oPath
)
{
m_bSpreadsheets
=
true
;
read
(
oRootPath
,
oPath
);
}
virtual
~
CExternalLink
()
...
...
XlsxSerializerCom/Common/BinReaderWriterDefines.h
View file @
3c58cd96
...
...
@@ -187,7 +187,8 @@ namespace BinXlsxRW
ExternalReferences
=
5
,
ExternalReference
=
6
,
PivotCaches
=
7
,
PivotCache
=
8
PivotCache
=
8
,
ExternalBook
=
9
};}
namespace
c_oSerWorkbookPrTypes
{
enum
c_oSerWorkbookPrTypes
{
...
...
@@ -819,6 +820,27 @@ namespace BinXlsxRW
cacheId
=
3
,
table
=
4
};}
namespace
c_oSer_ExternalLinkTypes
{
enum
c_oSer_ExternalLinkTypes
{
Id
=
0
,
SheetNames
=
1
,
SheetName
=
2
,
DefinedNames
=
3
,
DefinedName
=
4
,
DefinedNameName
=
5
,
DefinedNameRefersTo
=
6
,
DefinedNameSheetId
=
7
,
SheetDataSet
=
8
,
SheetData
=
9
,
SheetDataSheetId
=
10
,
SheetDataRefreshError
=
11
,
SheetDataRow
=
12
,
SheetDataRowR
=
13
,
SheetDataRowCell
=
14
,
SheetDataRowCellRef
=
15
,
SheetDataRowCellType
=
16
,
SheetDataRowCellValue
=
17
};}
}
#endif //
XlsxSerializerCom/Reader/BinaryWriter.h
View file @
3c58cd96
...
...
@@ -1601,8 +1601,8 @@ namespace BinXlsxRW
}
if
(
!
sLink
.
empty
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSerWorkbookTypes
::
External
Reference
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
sLink
);
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSerWorkbookTypes
::
External
Book
);
WriteExternalBook
(
pExternalLink
->
m_oExternalBook
.
get
(),
sLink
);
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
...
...
@@ -1610,7 +1610,144 @@ namespace BinXlsxRW
}
}
};
void
WriteExternalBook
(
const
OOX
::
Spreadsheet
::
CExternalBook
&
externalBook
,
const
std
::
wstring
&
sLink
)
{
int
nCurPos
=
0
;
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
Id
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
sLink
);
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
if
(
externalBook
.
m_oSheetNames
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetNames
);
WriteExternalSheetNames
(
externalBook
.
m_oSheetNames
.
get
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
externalBook
.
m_oDefinedNames
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
DefinedNames
);
WriteExternalDefinedNames
(
externalBook
.
m_oDefinedNames
.
get
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
externalBook
.
m_oSheetDataSet
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataSet
);
WriteExternalSheetDataSet
(
externalBook
.
m_oSheetDataSet
.
get
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteExternalSheetNames
(
const
OOX
::
Spreadsheet
::
CExternalSheetNames
&
sheetNames
)
{
int
nCurPos
=
0
;
for
(
size_t
i
=
0
,
length
=
sheetNames
.
m_arrItems
.
size
();
i
<
length
;
++
i
)
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetName
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
sheetNames
.
m_arrItems
[
i
]
->
ToString2
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteExternalDefinedNames
(
const
OOX
::
Spreadsheet
::
CExternalDefinedNames
&
definedNames
)
{
int
nCurPos
=
0
;
for
(
size_t
i
=
0
,
length
=
definedNames
.
m_arrItems
.
size
();
i
<
length
;
++
i
)
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
DefinedName
);
WriteExternalDefinedName
(
*
definedNames
.
m_arrItems
[
i
]);
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteExternalDefinedName
(
const
OOX
::
Spreadsheet
::
CExternalDefinedName
&
definedName
)
{
int
nCurPos
=
0
;
if
(
definedName
.
m_oName
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
DefinedNameName
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
definedName
.
m_oName
.
get
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
definedName
.
m_oRefersTo
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
DefinedNameRefersTo
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
definedName
.
m_oRefersTo
.
get
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
definedName
.
m_oSheetId
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
DefinedNameSheetId
);
m_oBcw
.
m_oStream
.
WriteULONG
(
definedName
.
m_oSheetId
->
GetValue
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteExternalSheetDataSet
(
const
OOX
::
Spreadsheet
::
CExternalSheetDataSet
&
sheetDataSet
)
{
int
nCurPos
=
0
;
for
(
size_t
i
=
0
,
length
=
sheetDataSet
.
m_arrItems
.
size
();
i
<
length
;
++
i
)
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetData
);
WriteExternalSheetData
(
*
sheetDataSet
.
m_arrItems
[
i
]);
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteExternalSheetData
(
const
OOX
::
Spreadsheet
::
CExternalSheetData
&
sheetData
)
{
int
nCurPos
=
0
;
if
(
sheetData
.
m_oSheetId
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataSheetId
);
m_oBcw
.
m_oStream
.
WriteULONG
(
sheetData
.
m_oSheetId
->
GetValue
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
sheetData
.
m_oRefreshError
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRefreshError
);
m_oBcw
.
m_oStream
.
WriteBOOL
(
sheetData
.
m_oRefreshError
->
ToBool
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
for
(
size_t
i
=
0
,
length
=
sheetData
.
m_arrItems
.
size
();
i
<
length
;
++
i
)
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRow
);
WriteExternalRow
(
*
sheetData
.
m_arrItems
[
i
]);
m_oBcw
.
WriteItemEnd
(
nCurPos
);
}
}
void
WriteExternalRow
(
const
OOX
::
Spreadsheet
::
CExternalRow
&
row
)
{
int
nCurPos
=
0
;
if
(
row
.
m_oR
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRowR
);
m_oBcw
.
m_oStream
.
WriteULONG
(
row
.
m_oR
->
GetValue
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
for
(
size_t
i
=
0
,
length
=
row
.
m_arrItems
.
size
();
i
<
length
;
++
i
)
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCell
);
WriteExternalCell
(
*
row
.
m_arrItems
[
i
]);
m_oBcw
.
WriteItemEnd
(
nCurPos
);
}
}
void
WriteExternalCell
(
const
OOX
::
Spreadsheet
::
CExternalCell
&
cell
)
{
int
nCurPos
=
0
;
if
(
cell
.
m_oRef
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCellRef
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
cell
.
m_oRef
.
get
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
cell
.
m_oType
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCellType
);
m_oBcw
.
m_oStream
.
WriteBYTE
(
cell
.
m_oType
->
GetValue
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
if
(
cell
.
m_oValue
.
IsInit
())
{
nCurPos
=
m_oBcw
.
WriteItemStart
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCellValue
);
m_oBcw
.
m_oStream
.
WriteStringW3
(
cell
.
m_oValue
->
ToString
());
m_oBcw
.
WriteItemWithLengthEnd
(
nCurPos
);
}
}
void
WriteDefinedName
(
const
OOX
::
Spreadsheet
::
CDefinedName
&
definedName
)
{
int
nCurPos
=
0
;
...
...
XlsxSerializerCom/Writer/BinaryReader.h
View file @
3c58cd96
...
...
@@ -1592,34 +1592,27 @@ namespace BinXlsxRW {
int
ReadExternalReferences
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSerWorkbookTypes
::
External
Reference
==
type
)
if
(
c_oSerWorkbookTypes
::
External
Book
==
type
)
{
std
::
wstring
sName
(
m_oBufferedStream
.
GetString3
(
length
));
if
(
sName
.
empty
()
==
false
)
OOX
::
Spreadsheet
::
CExternalLink
*
extLink
=
new
OOX
::
Spreadsheet
::
CExternalLink
();
extLink
->
m_oExternalBook
.
Init
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalBook
,
this
,
extLink
);
if
(
extLink
->
m_oExternalBook
->
m_oRid
.
IsInit
())
{
OOX
::
Spreadsheet
::
CExternalReference
*
pExternalReference
=
new
OOX
::
Spreadsheet
::
CExternalReference
();
OOX
::
Spreadsheet
::
CExternalLink
*
extLink
=
new
OOX
::
Spreadsheet
::
CExternalLink
();
smart_ptr
<
OOX
::
File
>
oCurFile
(
extLink
);
const
OOX
::
RId
oRId
=
m_oWorkbook
.
Add
(
oCurFile
);
pExternalReference
->
m_oRid
.
Init
();
pExternalReference
->
m_oRid
->
SetValue
(
oRId
.
get
());
extLink
->
m_oExternalBook
.
Init
();
OOX
::
Spreadsheet
::
ExternalLinkPath
*
link
=
new
OOX
::
Spreadsheet
::
ExternalLinkPath
(
sName
);
smart_ptr
<
OOX
::
File
>
oLinkFile
(
link
);
const
OOX
::
RId
oRIdLink
=
extLink
->
Add
(
oLinkFile
);
extLink
->
m_oExternalBook
->
m_oRid
.
Init
();
extLink
->
m_oExternalBook
->
m_oRid
->
SetValue
(
oRIdLink
.
get
());
m_oWorkbook
.
m_oExternalReferences
->
m_arrItems
.
push_back
(
pExternalReference
);
}
else
{
RELEASEOBJECT
(
extLink
)
}
}
else
...
...
@@ -1672,6 +1665,174 @@ namespace BinXlsxRW {
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalBook
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalLink
*
extLink
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalLink
*>
(
poResult
);
OOX
::
Spreadsheet
::
CExternalBook
*
pExternalBook
=
extLink
->
m_oExternalBook
.
GetPointer
();
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
Id
==
type
)
{
std
::
wstring
sName
(
m_oBufferedStream
.
GetString3
(
length
));
OOX
::
Spreadsheet
::
ExternalLinkPath
*
link
=
new
OOX
::
Spreadsheet
::
ExternalLinkPath
(
sName
);
smart_ptr
<
OOX
::
File
>
oLinkFile
(
link
);
const
OOX
::
RId
oRIdLink
=
extLink
->
Add
(
oLinkFile
);
pExternalBook
->
m_oRid
.
Init
();
pExternalBook
->
m_oRid
->
SetValue
(
oRIdLink
.
get
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetNames
==
type
)
{
pExternalBook
->
m_oSheetNames
.
Init
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalSheetNames
,
this
,
pExternalBook
->
m_oSheetNames
.
GetPointer
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
DefinedNames
==
type
)
{
pExternalBook
->
m_oDefinedNames
.
Init
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalDefinedNames
,
this
,
pExternalBook
->
m_oDefinedNames
.
GetPointer
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetDataSet
==
type
)
{
pExternalBook
->
m_oSheetDataSet
.
Init
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalSheetDataSet
,
this
,
pExternalBook
->
m_oSheetDataSet
.
GetPointer
());
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalSheetNames
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalSheetNames
*
pSheetNames
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalSheetNames
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
SheetName
==
type
)
{
ComplexTypes
::
Spreadsheet
::
String
*
pSheetName
=
new
ComplexTypes
::
Spreadsheet
::
String
();
pSheetName
->
m_sVal
.
Init
();
pSheetName
->
m_sVal
->
append
(
m_oBufferedStream
.
GetString4
(
length
));
pSheetNames
->
m_arrItems
.
push_back
(
pSheetName
);
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalDefinedNames
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalDefinedNames
*
pDefinedNames
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalDefinedNames
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
DefinedName
==
type
)
{
OOX
::
Spreadsheet
::
CExternalDefinedName
*
pDefinedName
=
new
OOX
::
Spreadsheet
::
CExternalDefinedName
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalDefinedName
,
this
,
pDefinedName
);
pDefinedNames
->
m_arrItems
.
push_back
(
pDefinedName
);
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalDefinedName
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalDefinedName
*
pDefinedName
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalDefinedName
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
DefinedNameName
==
type
)
{
pDefinedName
->
m_oName
.
Init
();
pDefinedName
->
m_oName
->
append
(
m_oBufferedStream
.
GetString3
(
length
));
}
else
if
(
c_oSer_ExternalLinkTypes
::
DefinedNameRefersTo
==
type
)
{
pDefinedName
->
m_oRefersTo
.
Init
();
pDefinedName
->
m_oRefersTo
->
append
(
m_oBufferedStream
.
GetString3
(
length
));
}
else
if
(
c_oSer_ExternalLinkTypes
::
DefinedNameSheetId
==
type
)
{
pDefinedName
->
m_oSheetId
.
Init
();
pDefinedName
->
m_oSheetId
->
SetValue
(
m_oBufferedStream
.
GetULong
());
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalSheetDataSet
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalSheetDataSet
*
pSheetDataSet
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalSheetDataSet
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
SheetData
==
type
)
{
OOX
::
Spreadsheet
::
CExternalSheetData
*
pSheetData
=
new
OOX
::
Spreadsheet
::
CExternalSheetData
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalSheetData
,
this
,
pSheetData
);
pSheetDataSet
->
m_arrItems
.
push_back
(
pSheetData
);
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalSheetData
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalSheetData
*
pSheetData
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalSheetData
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
SheetDataSheetId
==
type
)
{
pSheetData
->
m_oSheetId
.
Init
();
pSheetData
->
m_oSheetId
->
SetValue
(
m_oBufferedStream
.
GetULong
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRefreshError
==
type
)
{
pSheetData
->
m_oRefreshError
.
Init
();
pSheetData
->
m_oRefreshError
->
FromBool
(
m_oBufferedStream
.
GetBool
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRow
==
type
)
{
OOX
::
Spreadsheet
::
CExternalRow
*
pRow
=
new
OOX
::
Spreadsheet
::
CExternalRow
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalRow
,
this
,
pRow
);
pSheetData
->
m_arrItems
.
push_back
(
pRow
);
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalRow
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalRow
*
pRow
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalRow
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRowR
==
type
)
{
pRow
->
m_oR
.
Init
();
pRow
->
m_oR
->
SetValue
(
m_oBufferedStream
.
GetULong
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCell
==
type
)
{
OOX
::
Spreadsheet
::
CExternalCell
*
pCell
=
new
OOX
::
Spreadsheet
::
CExternalCell
();
res
=
Read1
(
length
,
&
BinaryWorkbookTableReader
::
ReadExternalCell
,
this
,
pCell
);
pRow
->
m_arrItems
.
push_back
(
pCell
);
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadExternalCell
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
OOX
::
Spreadsheet
::
CExternalCell
*
pCell
=
static_cast
<
OOX
::
Spreadsheet
::
CExternalCell
*>
(
poResult
);
int
res
=
c_oSerConstants
::
ReadOk
;
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCellRef
==
type
)
{
pCell
->
m_oRef
.
Init
();
pCell
->
m_oRef
->
append
(
m_oBufferedStream
.
GetString3
(
length
));
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCellType
==
type
)
{
pCell
->
m_oType
.
Init
();
pCell
->
m_oType
->
SetValue
((
SimpleTypes
::
Spreadsheet
::
ECellTypeType
)
m_oBufferedStream
.
GetUChar
());
}
else
if
(
c_oSer_ExternalLinkTypes
::
SheetDataRowCellValue
==
type
)
{
pCell
->
m_oValue
.
Init
();
pCell
->
m_oValue
->
m_sText
.
append
(
m_oBufferedStream
.
GetString3
(
length
));
}
else
res
=
c_oSerConstants
::
ReadUnknown
;
return
res
;
};
int
ReadPivotCaches
(
BYTE
type
,
long
length
,
void
*
poResult
)
{
int
res
=
c_oSerConstants
::
ReadOk
;
...
...
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