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
53078551
Commit
53078551
authored
Jul 03, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XlsFormat - convert pivot tables view
parent
3c9a91af
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
347 additions
and
64 deletions
+347
-64
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXDBB.cpp
...iceXlsFile2/source/XlsFormat/Logic/Biff_records/SXDBB.cpp
+4
-15
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXDBB.h
...fficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXDBB.h
+2
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXFDB.cpp
...iceXlsFile2/source/XlsFormat/Logic/Biff_records/SXFDB.cpp
+6
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXFormula.cpp
...lsFile2/source/XlsFormat/Logic/Biff_records/SXFormula.cpp
+3
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXFormula.h
...eXlsFile2/source/XlsFormat/Logic/Biff_records/SXFormula.h
+1
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SxDXF.h
...fficeXlsFile2/source/XlsFormat/Logic/Biff_records/SxDXF.h
+0
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/DBB.cpp
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/DBB.cpp
+45
-3
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/DBB.h
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/DBB.h
+5
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCACHE.cpp
...lsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCACHE.cpp
+13
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCACHEDEFINITION.cpp
...urce/XlsFormat/Logic/Biff_unions/PIVOTCACHEDEFINITION.cpp
+3
-3
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCORE.cpp
...XlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCORE.cpp
+8
-11
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTFRT9.cpp
...XlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTFRT9.cpp
+0
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEW.cpp
...XlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEW.cpp
+97
-6
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEW.h
...ceXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEW.h
+4
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEWEX.cpp
...sFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEWEX.cpp
+0
-4
ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h
...fficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h
+2
-0
ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp
ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp
+5
-0
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_conversion_context.cpp
...File2/source/XlsXlsxConverter/xlsx_conversion_context.cpp
+20
-3
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_package.cpp
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_package.cpp
+53
-4
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_package.h
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_package.h
+33
-3
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_pivots_context.cpp
...eXlsFile2/source/XlsXlsxConverter/xlsx_pivots_context.cpp
+34
-5
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_pivots_context.h
...iceXlsFile2/source/XlsXlsxConverter/xlsx_pivots_context.h
+9
-3
No files found.
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXDBB.cpp
View file @
53078551
...
...
@@ -52,24 +52,13 @@ BaseObjectPtr SXDBB::clone()
void
SXDBB
::
readFields
(
CFRecord
&
record
)
{
unsigned
int
sz
=
record
.
getDataSize
()
-
record
.
getRdPtr
();
size
=
record
.
getDataSize
()
-
record
.
getRdPtr
();
//std::list<CFRecordPtr>& recs = continue_records[rt_Continue]
;
blob
=
boost
::
shared_array
<
unsigned
char
>
(
new
unsigned
char
[
size
])
;
//while (record.getRdPtr() + lcb > record.getDataSize() && !recs.empty())
//{
// record.appendRawData(recs.front());
// recs.pop_front();
//}
memcpy
(
blob
.
get
(),
record
.
getCurData
<
unsigned
char
>
(),
size
);
if
(
record
.
checkFitReadSafe
(
sz
))
{
blob
=
boost
::
shared_array
<
char
>
(
new
char
[
sz
]);
memcpy
(
blob
.
get
(),
record
.
getCurData
<
char
>
(),
sz
);
record
.
skipNunBytes
(
sz
);
}
record
.
skipNunBytes
(
size
);
}
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXDBB.h
View file @
53078551
...
...
@@ -50,7 +50,8 @@ public:
static
const
ElementType
type
=
typeSXDBB
;
boost
::
shared_array
<
char
>
blob
;
boost
::
shared_array
<
unsigned
char
>
blob
;
unsigned
int
size
;
};
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXFDB.cpp
View file @
53078551
...
...
@@ -69,6 +69,12 @@ void SXFDB::readFields(CFRecord& record)
fServerBased
=
GETBIT
(
flags
,
13
);
fCantGetUniqueItems
=
GETBIT
(
flags
,
14
);
fCalculatedField
=
GETBIT
(
flags
,
15
);
if
(
fAllAtoms
)
{
GlobalWorkbookInfoPtr
global_info
=
record
.
getGlobalWorkbookInfo
();
global_info
->
arCacheFieldShortSize
.
push_back
(
fShortIitms
);
}
}
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXFormula.cpp
View file @
53078551
...
...
@@ -51,6 +51,9 @@ BaseObjectPtr SXFormula::clone()
void
SXFormula
::
readFields
(
CFRecord
&
record
)
{
unsigned
short
reserved
;
record
>>
reserved
>>
ifdb
;
}
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SXFormula.h
View file @
53078551
...
...
@@ -50,7 +50,7 @@ public:
static
const
ElementType
type
=
typeSXFormula
;
short
ifdb
;
};
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/SxDXF.h
View file @
53078551
...
...
@@ -54,7 +54,6 @@ public:
DXFN
dxfn
;
XFExtNoFRT
xfext
;
};
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/DBB.cpp
View file @
53078551
...
...
@@ -38,12 +38,11 @@
namespace
XLS
{
DBB
::
DBB
()
{
fShortIitms
=
false
;
}
DBB
::~
DBB
()
{
}
...
...
@@ -53,7 +52,6 @@ BaseObjectPtr DBB::clone()
return
BaseObjectPtr
(
new
DBB
(
*
this
));
}
// DBB = [SXDBB] *SXOPER
const
bool
DBB
::
loadContent
(
BinProcessor
&
proc
)
{
...
...
@@ -73,6 +71,50 @@ const bool DBB::loadContent(BinProcessor& proc)
return
true
;
}
int
DBB
::
serialize
(
std
::
wostream
&
strm
)
{
SXDBB
*
dbb
=
dynamic_cast
<
SXDBB
*>
(
m_SXDBB
.
get
());
if
(
!
dbb
&&
m_arSXOPER
.
empty
())
return
0
;
CP_XML_WRITER
(
strm
)
{
CP_XML_NODE
(
L"r"
)
{
if
(
m_arSXOPER
.
empty
()
==
false
)
{
for
(
size_t
i
=
0
;
i
<
m_arSXOPER
.
size
();
i
++
)
{
m_arSXOPER
[
i
]
->
serialize
(
CP_XML_STREAM
());
}
}
else
{
if
(
fShortIitms
==
false
)
{
for
(
size_t
i
=
0
;
i
<
dbb
->
size
;
i
++
)
{
CP_XML_NODE
(
L"x"
)
{
CP_XML_ATTR
(
L"v"
,
dbb
->
blob
[
i
]);
}
}
}
else
{
unsigned
short
*
values
=
(
unsigned
short
*
)
dbb
->
blob
.
get
();
for
(
size_t
i
=
0
;
i
<
dbb
->
size
/
2
;
i
++
)
{
CP_XML_NODE
(
L"x"
)
{
CP_XML_ATTR
(
L"v"
,
values
[
i
]);
}
}
}
}
}
}
return
0
;
}
}
// namespace XLS
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/DBB.h
View file @
53078551
...
...
@@ -47,10 +47,15 @@ public:
virtual
const
bool
loadContent
(
BinProcessor
&
proc
);
int
serialize
(
std
::
wostream
&
strm
);
static
const
ElementType
type
=
typeDBB
;
BaseObjectPtr
m_SXDBB
;
std
::
vector
<
BaseObjectPtr
>
m_arSXOPER
;
//---------------------------------------------------
bool
fShortIitms
;
};
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCACHE.cpp
View file @
53078551
...
...
@@ -60,6 +60,8 @@ BaseObjectPtr PIVOTCACHE::clone()
// PIVOTCACHE = SXDB SXDBEx *SXFORMULA *FDB *DBB EOF
const
bool
PIVOTCACHE
::
loadContent
(
BinProcessor
&
proc
)
{
GlobalWorkbookInfoPtr
global_info
=
proc
.
getGlobalWorkbookInfo
();
if
(
!
proc
.
mandatory
<
SXDB
>
())
{
return
false
;
...
...
@@ -90,6 +92,17 @@ const bool PIVOTCACHE::loadContent(BinProcessor& proc)
while
(
count
--
)
{
m_arDBB
.
push_back
(
elements_
.
front
());
elements_
.
pop_front
();
DBB
*
dbb
=
dynamic_cast
<
DBB
*>
(
m_arDBB
.
back
().
get
());
if
(
global_info
->
arCacheFieldShortSize
.
size
()
>=
m_arDBB
.
size
())
{
dbb
->
fShortIitms
=
global_info
->
arCacheFieldShortSize
[
m_arDBB
.
size
()
-
1
];
}
else
{
//???? группы??
}
}
if
(
proc
.
optional
<
EOF_T
>
())
{
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCACHEDEFINITION.cpp
View file @
53078551
...
...
@@ -116,9 +116,9 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
{
CP_XML_ATTR
(
L"r:id"
,
L"rId1"
);
}
CP_XML_ATTR
(
L"re
cordCount"
,
db
->
crdbUsed
);
CP_XML_ATTR
(
L"refreshed
By"
,
db
->
rgb
.
value
()
);
CP_XML_ATTR
(
L"re
freshedDate"
,
db_ex
->
numDate
.
data
.
value
);
CP_XML_ATTR
(
L"re
freshedBy"
,
db
->
rgb
.
value
()
);
CP_XML_ATTR
(
L"refreshed
Date"
,
db_ex
->
numDate
.
data
.
value
);
CP_XML_ATTR
(
L"re
cordCount"
,
db
->
crdbUsed
);
//createdVersion="1"
//refreshedVersion="2"
//upgradeOnRefresh="1">
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTCORE.cpp
View file @
53078551
...
...
@@ -31,34 +31,31 @@
*/
#include "PIVOTCORE.h"
#include <Logic/Biff_records/SxView.h>
#include <Logic/Biff_unions/PIVOTVD.h>
#include <Logic/Biff_unions/PIVOTIVD.h>
#include <Logic/Biff_unions/PIVOTPI.h>
#include <Logic/Biff_records/SXDI.h>
#include <Logic/Biff_unions/PIVOTLI.h>
#include <Logic/Biff_unions/PIVOTEX.h>
#include "PIVOTVD.h"
#include "PIVOTIVD.h"
#include "PIVOTPI.h"
#include "PIVOTLI.h"
#include "PIVOTEX.h"
#include "../Biff_records/SXDI.h"
#include "../Biff_records/SxView.h"
namespace
XLS
{
PIVOTCORE
::
PIVOTCORE
()
{
}
PIVOTCORE
::~
PIVOTCORE
()
{
}
BaseObjectPtr
PIVOTCORE
::
clone
()
{
return
BaseObjectPtr
(
new
PIVOTCORE
(
*
this
));
}
// PIVOTCORE = SxView *PIVOTVD *2PIVOTIVD [PIVOTPI] *SXDI *PIVOTLI PIVOTEX
const
bool
PIVOTCORE
::
loadContent
(
BinProcessor
&
proc
)
{
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTFRT9.cpp
View file @
53078551
...
...
@@ -55,7 +55,6 @@ BaseObjectPtr PIVOTFRT9::clone()
return
BaseObjectPtr
(
new
PIVOTFRT9
(
*
this
));
}
// PIVOTFRT9 = QsiSXTag [DBQUERYEXT] [PIVOTVIEWEX] SXViewEx9
const
bool
PIVOTFRT9
::
loadContent
(
BinProcessor
&
proc
)
{
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEW.cpp
View file @
53078551
...
...
@@ -31,29 +31,28 @@
*/
#include "PIVOTVIEW.h"
#include <Logic/Biff_unions/PIVOTCORE.h>
#include <Logic/Biff_unions/PIVOTFRT.h>
#include "PIVOTCORE.h"
#include "PIVOTFRT.h"
#include "../Biff_records/SxView.h"
namespace
XLS
{
PIVOTVIEW
::
PIVOTVIEW
()
{
indexCache
=
-
1
;
}
PIVOTVIEW
::~
PIVOTVIEW
()
{
}
BaseObjectPtr
PIVOTVIEW
::
clone
()
{
return
BaseObjectPtr
(
new
PIVOTVIEW
(
*
this
));
}
// PIVOTVIEW = PIVOTCORE [PIVOTFRT]
const
bool
PIVOTVIEW
::
loadContent
(
BinProcessor
&
proc
)
{
...
...
@@ -73,5 +72,97 @@ const bool PIVOTVIEW::loadContent(BinProcessor& proc)
return
true
;
}
int
PIVOTVIEW
::
serialize
(
std
::
wostream
&
strm
)
{
PIVOTCORE
*
core
=
dynamic_cast
<
PIVOTCORE
*>
(
m_PIVOTCORE
.
get
());
if
(
!
core
)
return
0
;
SxView
*
view
=
dynamic_cast
<
SxView
*>
(
core
->
m_SxView
.
get
());
if
(
!
view
)
return
0
;
PIVOTFRT
*
frt
=
dynamic_cast
<
PIVOTFRT
*>
(
m_PIVOTFRT
.
get
());
indexCache
=
view
->
iCache
;
CP_XML_WRITER
(
strm
)
{
CP_XML_NODE
(
L"pivotTableDefinition"
)
{
CP_XML_ATTR
(
L"xmlns"
,
L"http://schemas.openxmlformats.org/spreadsheetml/2006/main"
);
CP_XML_ATTR
(
L"cacheId"
,
view
->
iCache
);
CP_XML_ATTR
(
L"name"
,
view
->
stTable
.
value
());
CP_XML_ATTR
(
L"dataCaption"
,
view
->
stData
.
value
());
CP_XML_ATTR
(
L"useAutoFormatting"
,
view
->
fAutoFormat
);
CP_XML_ATTR
(
L"dataOnRows"
,
view
->
sxaxis4Data
.
bRw
);
CP_XML_ATTR
(
L"autoFormatId"
,
view
->
itblAutoFmt
);
CP_XML_ATTR
(
L"applyNumberFormats"
,
view
->
fAtrNum
);
CP_XML_ATTR
(
L"applyBorderFormats"
,
view
->
fAtrBdr
);
CP_XML_ATTR
(
L"applyFontFormats"
,
view
->
fAtrFnt
);
CP_XML_ATTR
(
L"applyPatternFormats"
,
view
->
fAtrPat
);
CP_XML_ATTR
(
L"applyAlignmentFormats"
,
view
->
fAtrAlc
);
CP_XML_ATTR
(
L"applyWidthHeightFormats"
,
view
->
fAtrProc
);
//updatedVersion="2"
//asteriskTotals="1"
//showMemberPropertyTips="0"
//itemPrintTitles="1"
//createdVersion="1"
//indent="0"
//compact="0"
//compactData="0"
//gridDropZones="1"
CP_XML_NODE
(
L"location"
)
{
CP_XML_ATTR
(
L"ref"
,
view
->
ref
.
toString
());
CP_XML_ATTR
(
L"firstHeaderRow"
,
view
->
rwFirstHead
-
view
->
ref
.
rowFirst
);
CP_XML_ATTR
(
L"firstDataRow"
,
view
->
rwFirstData
-
view
->
ref
.
rowFirst
);
CP_XML_ATTR
(
L"firstDataCol"
,
view
->
colFirstData
-
view
->
ref
.
columnFirst
);
CP_XML_ATTR
(
L"rowPageCount"
,
1
);
CP_XML_ATTR
(
L"colPageCount"
,
1
);
}
CP_XML_NODE
(
L"pivotFields"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cDim
);
}
CP_XML_NODE
(
L"rowFields"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cDimRw
);
}
CP_XML_NODE
(
L"rowItems"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cRw
);
}
CP_XML_NODE
(
L"colFields"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cDimCol
);
}
CP_XML_NODE
(
L"colItems"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cCol
);
}
CP_XML_NODE
(
L"pageFields"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cDimPg
);
}
CP_XML_NODE
(
L"dataFields"
)
{
CP_XML_ATTR
(
L"count"
,
view
->
cDimData
);
}
//CP_XML_NODE(L"pivotTableStyleInfo")
//{
// CP_XML_ATTR(L"showRowHeaders", 1);
// CP_XML_ATTR(L"showColHeaders", 1);
// CP_XML_ATTR(L"showRowStripes", 0);
// CP_XML_ATTR(L"showColStripes", 0);
// CP_XML_ATTR(L"showLastColumn", 1);
//}
}
}
return
0
;
}
}
// namespace XLS
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEW.h
View file @
53078551
...
...
@@ -47,10 +47,14 @@ public:
virtual
const
bool
loadContent
(
BinProcessor
&
proc
);
int
serialize
(
std
::
wostream
&
strm
);
static
const
ElementType
type
=
typePIVOTVIEW
;
BaseObjectPtr
m_PIVOTCORE
;
BaseObjectPtr
m_PIVOTFRT
;
//----------------------------------
int
indexCache
;
};
}
// namespace XLS
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/PIVOTVIEWEX.cpp
View file @
53078551
...
...
@@ -39,23 +39,19 @@
namespace
XLS
{
PIVOTVIEWEX
::
PIVOTVIEWEX
()
{
}
PIVOTVIEWEX
::~
PIVOTVIEWEX
()
{
}
BaseObjectPtr
PIVOTVIEWEX
::
clone
()
{
return
BaseObjectPtr
(
new
PIVOTVIEWEX
(
*
this
));
}
// PIVOTVIEWEX = SXViewEx *PIVOTTH *SXPIEx *PIVOTVDTEX
const
bool
PIVOTVIEWEX
::
loadContent
(
BinProcessor
&
proc
)
{
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h
View file @
53078551
...
...
@@ -100,6 +100,8 @@ public:
const
static
unsigned
int
initial_AXES_id
=
0x2000000
;
std
::
map
<
int
,
BaseObjectPtr
>
mapPivotCache
;
std
::
vector
<
bool
>
arCacheFieldShortSize
;
std
::
map
<
std
::
wstring
,
std
::
vector
<
std
::
wstring
>>
mapDefineNames
;
std
::
vector
<
std
::
wstring
>
arDefineNames
;
std
::
vector
<
std
::
wstring
>
arExternalNames
;
...
...
ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp
View file @
53078551
...
...
@@ -1916,6 +1916,11 @@ void XlsConverter::convert(XLS::PIVOTVIEW * pivot_view)
{
if
(
pivot_view
==
NULL
)
return
;
std
::
wstringstream
strm
;
pivot_view
->
serialize
(
strm
);
xlsx_context
->
get_pivots_context
().
add_view
(
strm
.
str
(),
pivot_view
->
indexCache
);
}
void
XlsConverter
::
convert
(
XLS
::
PIVOTCACHEDEFINITION
*
pivot_cached
)
...
...
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_conversion_context.cpp
View file @
53078551
...
...
@@ -272,14 +272,31 @@ void xlsx_conversion_context::end_document()
CP_XML_ATTR
(
L"r:id"
,
rId
);
}
xlsx_pivots_context_
.
dump_rels
(
i
,
content
->
get_rels
());
xlsx_pivots_context_
.
write_definitions_to
(
i
,
content
->
definitions
());
xlsx_pivots_context_
.
write_records_to
(
i
,
content
->
records
());
xlsx_pivots_context_
.
dump_rels
_cache
(
i
,
content
->
get_rels
());
xlsx_pivots_context_
.
write_
cache_
definitions_to
(
i
,
content
->
definitions
());
xlsx_pivots_context_
.
write_
cache_
records_to
(
i
,
content
->
records
());
output_document_
->
get_xl_files
().
add_pivot_cache
(
content
);
}
}
}
int
pivot_view_count
=
xlsx_pivots_context_
.
get_view_count
();
if
(
pivot_view_count
>
0
)
{
for
(
int
i
=
0
;
i
<
pivot_view_count
;
i
++
)
{
//std::wstring rId = L"pvId" + std::to_wstring(i+1);
//static const std::wstring sType = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable";
//const std::wstring sName = std::wstring(L"../pivotTables/pivotTable" + std::to_wstring(i + 1) + L".xml");
package
::
pivot_table_content_ptr
content
=
package
::
pivot_table_content
::
create
();
xlsx_pivots_context_
.
dump_rels_view
(
i
,
content
->
get_rels
());
xlsx_pivots_context_
.
write_table_view_to
(
i
,
content
->
content
());
output_document_
->
get_xl_files
().
add_pivot_table
(
content
);
}
}
}
output_document_
->
get_xl_files
().
set_workbook
(
package
::
simple_element
::
create
(
L"workbook.xml"
,
strm_workbook
.
str
())
);
...
...
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_package.cpp
View file @
53078551
...
...
@@ -89,13 +89,20 @@ _CP_PTR(pivot_cache_content) pivot_cache_content::create()
{
return
boost
::
make_shared
<
pivot_cache_content
>
();
}
//--------------------------------------------------------------------------------------------
pivot_table_content
::
pivot_table_content
()
:
rels_file_
(
rels_file
::
create
(
L""
))
{
}
_CP_PTR
(
pivot_table_content
)
pivot_table_content
::
create
()
{
return
boost
::
make_shared
<
pivot_table_content
>
();
}
//--------------------------------------------------------------------------------------------
sheet_content
::
sheet_content
()
:
rels_
(
rels_file
::
create
(
L""
))
{
}
//--------------------------------------------------------------------------------------------
_CP_PTR
(
sheet_content
)
sheet_content
::
create
()
{
return
boost
::
make_shared
<
sheet_content
>
();
...
...
@@ -206,7 +213,6 @@ void xl_files::write(const std::wstring & RootPath)
media_
->
set_main_document
(
get_main_document
());
media_
->
write
(
path
);
}
{
charts_files_
.
set_main_document
(
get_main_document
());
charts_files_
.
write
(
path
);
...
...
@@ -214,8 +220,12 @@ void xl_files::write(const std::wstring & RootPath)
{
pivot_cache_files_
.
set_rels
(
&
rels_files_
);
pivot_cache_files_
.
set_main_document
(
get_main_document
());
pivot_cache_files_
.
write
(
path
);
pivot_cache_files_
.
write
(
path
);
}
{
pivot_table_files_
.
set_main_document
(
get_main_document
());
pivot_table_files_
.
write
(
path
);
}
if
(
drawings_
)
{
drawings_
->
set_main_document
(
get_main_document
());
...
...
@@ -281,6 +291,10 @@ void xl_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{
pivot_cache_files_
.
add_pivot_cache
(
pivot_cache
);
}
void
xl_files
::
add_pivot_table
(
pivot_table_content_ptr
pivot_table
)
{
pivot_table_files_
.
add_pivot_table
(
pivot_table
);
}
//----------------------------------------------------------------------------------------
void
xl_pivot_cache_files
::
add_pivot_cache
(
pivot_cache_content_ptr
pivot_cache
)
{
...
...
@@ -334,6 +348,41 @@ void xl_pivot_cache_files::write(const std::wstring & RootPath)
}
}
//----------------------------------------------------------------------------------------
void
xl_pivot_table_files
::
add_pivot_table
(
pivot_table_content_ptr
pivot_table
)
{
pivot_tables_
.
push_back
(
pivot_table
);
}
void
xl_pivot_table_files
::
write
(
const
std
::
wstring
&
RootPath
)
{
std
::
wstring
path
=
RootPath
+
FILE_SEPARATOR_STR
+
L"pivotTables"
;
NSDirectory
::
CreateDirectory
(
path
.
c_str
());
content_type
&
contentTypes
=
this
->
get_main_document
()
->
content_type
().
get_content_type
();
static
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
;
for
(
size_t
i
=
0
;
i
<
pivot_tables_
.
size
();
i
++
)
{
if
(
pivot_tables_
[
i
])
{
const
std
::
wstring
fileName
=
std
::
wstring
(
L"pivotTable"
)
+
std
::
to_wstring
(
i
+
1
)
+
L".xml"
;
contentTypes
.
add_override
(
std
::
wstring
(
L"/xl/pivotTables/"
)
+
fileName
,
kWSConType
);
package
::
simple_element
(
fileName
,
pivot_tables_
[
i
]
->
str
()).
write
(
path
);
if
(
pivot_tables_
[
i
]
->
get_rels
().
empty
()
==
false
)
{
rels_files
relFiles
;
pivot_tables_
[
i
]
->
rels_file_
->
set_file_name
(
fileName
+
L".rels"
);
relFiles
.
add_rel_file
(
pivot_tables_
[
i
]
->
rels_file_
);
relFiles
.
write
(
path
);
}
}
}
}
//----------------------------------------------------------------------------------------
void
xl_charts_files
::
add_chart
(
chart_content_ptr
chart
)
{
charts_
.
push_back
(
chart
);
...
...
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_package.h
View file @
53078551
...
...
@@ -89,6 +89,26 @@ private:
rels_file_ptr
definitions_rels_file_
;
};
//------------------------------------------------------------------------
class
pivot_table_content
;
typedef
_CP_PTR
(
pivot_table_content
)
pivot_table_content_ptr
;
class
pivot_table_content
:
boost
::
noncopyable
{
public:
pivot_table_content
();
static
_CP_PTR
(
pivot_table_content
)
create
();
std
::
wostream
&
content
()
{
return
content_
;
}
rels
&
get_rels
()
{
return
rels_file_
->
get_rels
();
}
std
::
wstring
str
()
{
return
content_
.
str
();
}
friend
class
xl_pivot_table_files
;
private:
std
::
wstringstream
content_
;
rels_file_ptr
rels_file_
;
};
//------------------------------------------------------------------------
class
sheets_files
:
public
element
{
public:
...
...
@@ -119,7 +139,16 @@ public:
std
::
vector
<
chart_content_ptr
>
charts_
;
};
class
xl_pivot_table_files
:
public
element
{
public:
xl_pivot_table_files
(){}
void
add_pivot_table
(
pivot_table_content_ptr
pivot_table
);
virtual
void
write
(
const
std
::
wstring
&
RootPath
);
std
::
vector
<
pivot_table_content_ptr
>
pivot_tables_
;
};
class
xl_pivot_cache_files
:
public
element
{
public:
...
...
@@ -200,13 +229,14 @@ public:
void
set_vml_drawings
(
element_ptr
Element
);
void
set_comments
(
element_ptr
Element
);
void
add_charts
(
chart_content_ptr
chart
);
void
add_pivot_cache
(
pivot_cache_content_ptr
pivot
);
void
add_pivot_cache
(
pivot_cache_content_ptr
cache
);
void
add_pivot_table
(
pivot_table_content_ptr
table
);
private:
rels_files
rels_files_
;
sheets_files
sheets_files_
;
xl_charts_files
charts_files_
;
xl_pivot_cache_files
pivot_cache_files_
;
xl_pivot_table_files
pivot_table_files_
;
element_ptr
theme_
;
element_ptr
workbook_
;
...
...
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_pivots_context.cpp
View file @
53078551
...
...
@@ -47,10 +47,16 @@ public:
std
::
wstring
definitionsData_
;
std
::
wstring
recordsData_
;
};
struct
_pivot_view
{
std
::
wstring
data_
;
int
indexCache_
;
};
Impl
()
{}
std
::
vector
<
_pivot_cache
>
caches_
;
std
::
vector
<
_pivot_cache
>
caches_
;
std
::
vector
<
_pivot_view
>
views_
;
};
xlsx_pivots_context
::
xlsx_pivots_context
()
:
impl_
(
new
xlsx_pivots_context
::
Impl
())
...
...
@@ -67,24 +73,47 @@ int xlsx_pivots_context::get_cache_count()
{
return
(
int
)
impl_
->
caches_
.
size
();
}
void
xlsx_pivots_context
::
dump_rels
(
int
index
,
rels
&
Rels
)
void
xlsx_pivots_context
::
dump_rels
_cache
(
int
index
,
rels
&
Rels
)
{
if
(
!
impl_
->
caches_
[
index
].
recordsData_
.
empty
())
if
(
impl_
->
caches_
[
index
].
recordsData_
.
empty
())
{
Rels
.
add
(
relationship
(
L"rId1"
,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords"
,
L"pivotCacheRecords"
+
std
::
to_wstring
(
index
)
+
L".xml"
,
L""
));
}
}
void
xlsx_pivots_context
::
write_definitions_to
(
int
index
,
std
::
wostream
&
strm
)
void
xlsx_pivots_context
::
dump_rels_view
(
int
index
,
rels
&
Rels
)
{
if
(
impl_
->
views_
[
index
].
indexCache_
>=
0
)
{
Rels
.
add
(
relationship
(
L"rId1"
,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
,
L"../pivotCache/pivotCacheDefinition"
+
std
::
to_wstring
(
impl_
->
views_
[
index
].
indexCache_
+
1
)
+
L".xml"
,
L""
));
}
}
void
xlsx_pivots_context
::
write_cache_definitions_to
(
int
index
,
std
::
wostream
&
strm
)
{
strm
<<
impl_
->
caches_
[
index
].
definitionsData_
;
}
void
xlsx_pivots_context
::
write_records_to
(
int
index
,
std
::
wostream
&
strm
)
void
xlsx_pivots_context
::
write_
cache_
records_to
(
int
index
,
std
::
wostream
&
strm
)
{
strm
<<
impl_
->
caches_
[
index
].
recordsData_
;
}
void
xlsx_pivots_context
::
write_table_view_to
(
int
index
,
std
::
wostream
&
strm
)
{
strm
<<
impl_
->
views_
[
index
].
data_
;
}
void
xlsx_pivots_context
::
add_view
(
std
::
wstring
table_view
,
int
indexCache
)
{
Impl
::
_pivot_view
v
=
{
table_view
,
indexCache
};
impl_
->
views_
.
push_back
(
v
);
}
int
xlsx_pivots_context
::
get_view_count
()
{
return
(
int
)
impl_
->
views_
.
size
();
}
xlsx_pivots_context
::~
xlsx_pivots_context
()
{
...
...
ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_pivots_context.h
View file @
53078551
...
...
@@ -43,13 +43,19 @@ public:
xlsx_pivots_context
();
~
xlsx_pivots_context
();
void
add_view
(
std
::
wstring
table_view
,
int
indexCache
);
int
get_view_count
();
void
add_cache
(
std
::
wstring
definitions
,
std
::
wstring
records
);
int
get_cache_count
();
void
write_definitions_to
(
int
index
,
std
::
wostream
&
strm
);
void
write_records_to
(
int
index
,
std
::
wostream
&
strm
);
void
write_cache_definitions_to
(
int
index
,
std
::
wostream
&
strm
);
void
write_cache_records_to
(
int
index
,
std
::
wostream
&
strm
);
void
write_table_view_to
(
int
index
,
std
::
wostream
&
strm
);
void
dump_rels
(
int
index
,
rels
&
Rels
);
void
dump_rels_cache
(
int
index
,
rels
&
Rels
);
void
dump_rels_view
(
int
index
,
rels
&
Rels
);
private:
class
Impl
;
_CP_PTR
(
Impl
)
impl_
;
...
...
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