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
e12281c6
Commit
e12281c6
authored
Apr 06, 2016
by
ElenaSubbotina
Committed by
Alexander Trofimov
May 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XlsFormat - улучшение работы со стилями
parent
bb85d380
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
179 additions
and
175 deletions
+179
-175
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Blank.cpp
...iceXlsFile2/source/XlsFormat/Logic/Biff_records/Blank.cpp
+9
-11
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.cpp
...fficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.cpp
+53
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h
+4
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BorderFillInfo.cpp
...source/XlsFormat/Logic/Biff_structures/BorderFillInfo.cpp
+16
-17
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BorderFillInfo.h
...2/source/XlsFormat/Logic/Biff_structures/BorderFillInfo.h
+1
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp
...XlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp
+88
-145
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp
+3
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp
...iceXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp
+4
-0
ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h
...fficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h
+1
-0
No files found.
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Blank.cpp
View file @
e12281c6
...
...
@@ -39,18 +39,16 @@ const CellRef Blank::getLocation() const
int
Blank
::
serialize
(
std
::
wostream
&
stream
)
{
CP_XML_WRITER
(
stream
)
{
int
row
=
cell
.
rw
;
std
::
wstring
ref
=
cell
.
getLocation
().
toString
();
// getColRowRef(i, row);
CP_XML_NODE
(
L"c"
)
{
CP_XML_ATTR
(
L"r"
,
ref
);
int
st
=
(
int
)
cell
.
ixfe
-
global_info_
->
cellStyleXfs_count
;
if
(
cell
.
ixfe
>
global_info_
->
cellStyleXfs_count
)
{
CP_XML_WRITER
(
stream
)
{
CP_XML_NODE
(
L"c"
)
{
CP_XML_ATTR
(
L"r"
,
cell
.
getLocation
().
toString
());
CP_XML_ATTR
(
L"s"
,
cell
.
ixfe
-
global_info_
->
cellStyleXfs_count
);
}
}
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.cpp
View file @
e12281c6
...
...
@@ -53,6 +53,7 @@ void Row::writeFields(CFRecord& record)
void
Row
::
readFields
(
CFRecord
&
record
)
{
global_info_
=
record
.
getGlobalWorkbookInfo
();
record
>>
rw
>>
colMic
>>
colMac
>>
miyRw
;
record
.
skipNunBytes
(
4
);
// reserved / unused
...
...
@@ -74,5 +75,57 @@ void Row::readFields(CFRecord& record)
fPhonetic
=
GETBIT
(
flags
,
14
);
}
int
Row
::
serialize
(
std
::
wostream
&
stream
)
{
CP_XML_WRITER
(
stream
)
{
CP_XML_NODE
(
L"row"
)
{
CP_XML_ATTR
(
L"r"
,
rw
+
1
);
bool
xf_set
=
true
;
if
(
fGhostDirty
==
false
)
xf_set
=
false
;
if
(
ixfe_val
&&
xf_set
)
{
int
xf
=
ixfe_val
>
global_info_
->
cellStyleXfs_count
?
ixfe_val
-
global_info_
->
cellStyleXfs_count
:
ixfe_val
;
if
(
xf
<
global_info_
->
cellXfs_count
)
{
CP_XML_ATTR
(
L"s"
,
xf
);
CP_XML_ATTR
(
L"customFormat"
,
true
);
}
}
if
(
miyRw
>
0
/* && std::abs(miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/
)
{
CP_XML_ATTR
(
L"ht"
,
miyRw
/
20.
);
CP_XML_ATTR
(
L"customHeight"
,
true
);
}
if
(
iOutLevel
>
0
)
{
CP_XML_ATTR
(
L"outlineLevel"
,
iOutLevel
);
}
if
(
fCollapsed
)
{
CP_XML_ATTR
(
L"collapsed"
,
fCollapsed
);
}
if
(
fExAsc
)
{
CP_XML_ATTR
(
L"thickTop"
,
true
);
}
if
(
fExDes
)
{
CP_XML_ATTR
(
L"thickBot"
,
true
);
}
if
(
fDyZero
)
{
CP_XML_ATTR
(
L"hidden"
,
true
);
}
}
}
return
0
;
}
}
// namespace XLS
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h
View file @
e12281c6
...
...
@@ -20,8 +20,12 @@ public:
void
writeFields
(
CFRecord
&
record
);
void
readFields
(
CFRecord
&
record
);
int
serialize
(
std
::
wostream
&
stream
);
static
const
ElementType
type
=
typeRow
;
GlobalWorkbookInfoPtr
global_info_
;
//-----------------------------
Rw
rw
;
BackwardOnlyParam
<
unsigned
short
>
colMic
;
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BorderFillInfo.cpp
View file @
e12281c6
...
...
@@ -145,17 +145,16 @@ int FillInfo::serialize(std::wostream & stream)
bool
BorderInfo
::
operator
==
(
const
BorderInfo
&
rVal
)
const
{
const
bool
res
=
dgBottom
==
rVal
.
dgBottom
&&
dgDiag
==
rVal
.
dgDiag
&&
dgLeft
==
rVal
.
dgLeft
&&
dgRight
==
rVal
.
dgRight
&&
dgTop
==
rVal
.
dgTop
&&
grbitDiag
==
rVal
.
grbitDiag
&&
icvBottom
==
rVal
.
icvBottom
&&
icvDiag
==
rVal
.
icvDiag
&&
icvLeft
==
rVal
.
icvLeft
&&
icvRight
==
rVal
.
icvRight
&&
icvTop
==
rVal
.
icvTop
;
((
dgBottom
==
rVal
.
dgBottom
&&
icvBottom
==
rVal
.
icvBottom
)
||
(
dgBottom
==
0
&&
rVal
.
dgBottom
==
0
))
&&
((
dgLeft
==
rVal
.
dgLeft
&&
icvLeft
==
rVal
.
icvLeft
)
||
(
dgLeft
==
0
&&
rVal
.
dgLeft
==
0
))
&&
((
dgRight
==
rVal
.
dgRight
&&
icvRight
==
rVal
.
icvRight
)
||
(
dgRight
==
0
&&
rVal
.
dgRight
==
0
))
&&
((
dgTop
==
rVal
.
dgTop
&&
icvTop
==
rVal
.
icvTop
)
||
(
dgTop
==
0
&&
rVal
.
dgTop
==
0
))
&&
((
dgDiag
==
rVal
.
dgDiag
&&
grbitDiag
==
rVal
.
grbitDiag
&&
icvDiag
==
rVal
.
icvDiag
)
||
(
dgDiag
==
0
&&
rVal
.
dgDiag
==
0
&&
grbitDiag
==
0
&&
rVal
.
grbitDiag
==
0
))
;
return
res
;
}
...
...
@@ -184,15 +183,15 @@ static std::wstring border_type[]=
void
serialize1
(
std
::
wostream
&
_stream
,
unsigned
char
type
,
unsigned
color
,
const
std
::
wstring
&
name
)
{
if
(
type
<
1
||
type
>
13
)
return
;
if
(
type
<
0
||
type
>
13
)
return
;
CP_XML_WRITER
(
_stream
)
{
CP_XML_NODE
(
name
)
{
CP_XML_ATTR
(
L"style"
,
border_type
[
type
]);
if
(
type
>
0
)
CP_XML_ATTR
(
L"style"
,
border_type
[
type
]);
if
(
color
>
0
)
if
(
color
>
0
&&
type
>
0
)
{
CP_XML_NODE
(
L"color"
)
{
...
...
@@ -204,15 +203,15 @@ void serialize1(std::wostream & _stream, unsigned char type, unsigned color, con
}
void
serialize1
(
std
::
wostream
&
_stream
,
unsigned
char
type
,
FillInfoExt
&
color
,
const
std
::
wstring
&
name
)
{
if
(
type
<
1
||
type
>
13
)
return
;
if
(
type
<
0
||
type
>
13
)
return
;
CP_XML_WRITER
(
_stream
)
{
CP_XML_NODE
(
name
)
{
CP_XML_ATTR
(
L"style"
,
border_type
[
type
]);
if
(
type
>
0
)
CP_XML_ATTR
(
L"style"
,
border_type
[
type
]);
if
(
color
.
enabled
)
if
(
color
.
enabled
&&
type
>
0
)
{
CP_XML_NODE
(
L"color"
)
{
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BorderFillInfo.h
View file @
e12281c6
...
...
@@ -70,7 +70,7 @@ struct BorderInfo
FillInfoExt
topFillInfo_
;
FillInfoExt
bottomFillInfo_
;
BorderInfo
(){}
BorderInfo
()
:
dgLeft
(
0
),
dgRight
(
0
),
dgTop
(
0
),
dgBottom
(
0
),
dgDiag
(
0
),
grbitDiag
(
0
)
{}
BorderInfo
(
const
unsigned
char
dgLeft_set
,
const
unsigned
char
dgRight_set
,
const
unsigned
char
dgTop_set
,
const
unsigned
char
dgBottom_set
,
const
unsigned
char
dgDiag_set
,
const
unsigned
char
grbitDiag_set
,
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp
View file @
e12281c6
...
...
@@ -42,7 +42,7 @@ public:
while
(
count
>
0
)
{
Row
*
row
=
dynamic_cast
<
Row
*>
(
elements_
.
back
().
get
());
Row
*
row
=
dynamic_cast
<
Row
*>
(
elements_
.
front
().
get
());
if
(
row
)
{
if
(
row
->
miyRw
>
0
&&
std
::
abs
(
row
->
miyRw
/
20.
-
sheet_info
.
defaultRowHeight
)
>
0.001
)
...
...
@@ -50,8 +50,8 @@ public:
sheet_info
.
customRowsHeight
.
insert
(
std
::
pair
<
int
,
double
>
(
row
->
rw
,
row
->
miyRw
/
20.
));
}
}
m_rows
.
insert
(
m_rows
.
begin
(),
elements_
.
back
());
elements_
.
pop_
back
();
m_rows
.
push_back
(
elements_
.
front
());
elements_
.
pop_
front
();
count
--
;
}
}
...
...
@@ -59,10 +59,30 @@ public:
//------------------------------------------------------------------------------------------------------------------
CELL
cell
(
shared_formulas_locations_ref_
);
int
count_cells
=
proc
.
repeated
(
cell
,
0
,
0
);
int
count_cells
=
count
=
proc
.
repeated
(
cell
,
0
,
0
);
count
=
proc
.
repeated
<
DBCell
>
(
0
,
0
);
// OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS])
while
(
count
>
0
)
{
CELL
*
cell
=
dynamic_cast
<
CELL
*>
(
elements_
.
front
().
get
());
if
(
cell
)
{
std
::
map
<
int
,
std
::
list
<
BaseObjectPtr
>>::
iterator
it
=
m_cells
.
find
(
cell
->
RowNumber
);
if
(
it
==
m_cells
.
end
())
{
std
::
list
<
BaseObjectPtr
>
c
;
c
.
push_back
(
elements_
.
front
());
m_cells
.
insert
(
std
::
pair
<
int
,
std
::
list
<
BaseObjectPtr
>>
(
cell
->
RowNumber
,
c
));
}
else
{
it
->
second
.
push_back
(
elements_
.
front
());
}
}
elements_
.
pop_front
();
count
--
;
}
count
=
proc
.
repeated
<
DBCell
>
(
0
,
0
);
// OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS])
while
(
count
>
0
)
{
m_DBCells
.
insert
(
m_DBCells
.
begin
(),
elements_
.
back
());
...
...
@@ -71,10 +91,13 @@ public:
}
if
(
count_cells
>
0
||
count_row
>
0
)
return
true
;
else
return
false
;
};
}
int
serialize
(
std
::
wostream
&
stream
);
static
const
ElementType
type
=
typeCELL_GROUP
;
//---------------------------------------------------------------------------
std
::
map
<
int
,
std
::
list
<
BaseObjectPtr
>>
m_cells
;
std
::
list
<
BaseObjectPtr
>
m_rows
;
std
::
list
<
BaseObjectPtr
>
m_DBCells
;
...
...
@@ -125,71 +148,44 @@ int CELL_GROUP::serialize(std::wostream & stream)
XLS
::
GlobalWorkbookInfo
::
_sheet_size_info
&
sheet_info
=
global_info_
->
current_sheet
>=
0
?
global_info_
->
sheet_size_info
[
global_info_
->
current_sheet
-
1
]
:
zero
;
elements_
.
sort
(
CompareRowCell
);
// .. todooo (rownumb, list<cells> - )
CP_XML_WRITER
(
stream
)
{
std
::
list
<
XLS
::
BaseObjectPtr
>::
iterator
current_cell_start
=
elements_
.
begin
();
std
::
list
<
XLS
::
BaseObjectPtr
>::
iterator
current_row
=
m_rows
.
begin
();
int
current_row_number
=
0
;
while
(
current_row_number
==
0
)
for
(
std
::
map
<
int
,
std
::
list
<
BaseObjectPtr
>>::
iterator
it_row
=
m_cells
.
begin
();
it_row
!=
m_cells
.
end
();
it_row
++
)
{
CP_XML_NODE
(
L"row"
)
{
std
::
list
<
XLS
::
BaseObjectPtr
>::
iterator
it_cell
=
current_cell_start
;
while
(
true
)
{
if
(
it_cell
==
elements_
.
end
())
{
current_cell_start
=
it_cell
;
current_row_number
=
-
1
;
break
;
}
CELL
*
cell
=
dynamic_cast
<
CELL
*>
(
it_cell
->
get
());
if
(
cell
==
NULL
)
{
it_cell
++
;
continue
;
}
if
(
current_row_number
<
1
)
//
{
current_row_number
=
cell
->
RowNumber
+
1
;
//
bool
skip_cells
=
false
;
it_row
->
second
.
sort
(
CompareColumCell
);
Row
*
row
=
NULL
;
if
(
current_row
!=
m_rows
.
end
())
{
Row
*
row
=
dynamic_cast
<
Row
*>
(
current_row
->
get
());
row
=
dynamic_cast
<
Row
*>
(
current_row
->
get
());
int
row_n
=
row
->
rw
;
if
(
row
->
rw
+
1
<
current_row_number
)
{
current_row_number
=
row
->
rw
+
1
;
skip_cells
=
true
;
while
((
row
)
&&
(
row
->
rw
<
it_row
->
first
))
{
//skip cells
row
->
serialize
(
stream
);
current_row
++
;
row
=
dynamic_cast
<
Row
*>
(
current_row
->
get
())
;
}
CP_XML_ATTR
(
L"r"
,
current_row_number
);
if
(
row
->
rw
+
1
==
current_row_number
)
}
CP_XML_NODE
(
L"row"
)
{
CP_XML_ATTR
(
L"r"
,
it_row
->
first
+
1
);
if
((
row
)
&&
(
row
->
rw
==
it_row
->
first
))
{
bool
xf_set
=
true
;
if
(
row
->
fGhostDirty
==
false
)
xf_set
=
false
;
if
(
row
->
ixfe_val
&&
xf_set
)
{
if
(
row
->
ixfe_val
>
global_info_
->
cellStyleXfs_count
)
{
CP_XML_ATTR
(
L"s"
,
row
->
ixfe_val
-
global_info_
->
cellStyleXfs_count
);
}
else
int
xf
=
ixfe_val
>
global_info_
->
cellStyleXfs_count
?
row
->
ixfe_val
-
global_info_
->
cellStyleXfs_count
:
row
->
ixfe_val
;
if
(
xf
<
global_info_
->
cellXfs_count
)
{
CP_XML_ATTR
(
L"s"
,
row
->
ixfe_val
);
}
CP_XML_ATTR
(
L"s"
,
xf
);
CP_XML_ATTR
(
L"customFormat"
,
true
);
}
}
if
(
row
->
miyRw
>
0
/* && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/
)
{
CP_XML_ATTR
(
L"ht"
,
row
->
miyRw
/
20.
);
...
...
@@ -215,80 +211,27 @@ int CELL_GROUP::serialize(std::wostream & stream)
{
CP_XML_ATTR
(
L"hidden"
,
true
);
}
}
if
(
row
->
rw
+
1
<=
current_row_number
)
{
current_row
++
;
}
}
else
{
CP_XML_ATTR
(
L"r"
,
current_row_number
);
}
if
(
skip_cells
)
{
current_row_number
=
0
;
break
;
}
}
if
(
cell
->
RowNumber
+
1
>
current_row_number
)
{
current_cell_start
=
it_cell
;
current_row_number
=
0
;
break
;
}
cell
->
serialize
(
CP_XML_STREAM
());
it_cell
++
;
}
}
}
if
(
current_row
!=
m_rows
.
end
())
{
for
(
std
::
list
<
XLS
::
BaseObjectPtr
>::
iterator
it_row
=
current_row
;
it_row
!=
m_rows
.
end
();
it_row
++
)
{
Row
*
row
=
dynamic_cast
<
Row
*>
(
it_row
->
get
());
if
(
row
==
NULL
)
continue
;
CP_XML_NODE
(
L"row"
)
{
current_row_number
=
row
->
rw
+
1
;
CP_XML_ATTR
(
L"r"
,
current_row_number
);
bool
xf_set
=
true
;
if
(
row
->
fGhostDirty
==
false
)
xf_set
=
false
;
row
=
NULL
;
current_row
++
;
if
(
current_row
!=
m_rows
.
end
())
row
=
dynamic_cast
<
Row
*>
(
current_row
->
get
());
if
(
xf_set
)
{
if
(
row
->
ixfe_val
>
global_info_
->
cellStyleXfs_count
)
{
CP_XML_ATTR
(
L"s"
,
row
->
ixfe_val
-
global_info_
->
cellStyleXfs_count
);
}
else
for
(
std
::
list
<
BaseObjectPtr
>::
iterator
it_cell
=
it_row
->
second
.
begin
();
it_cell
!=
it_row
->
second
.
end
();
it_cell
++
)
{
CP_XML_ATTR
(
L"s"
,
row
->
ixfe_val
);
(
*
it_cell
)
->
serialize
(
CP_XML_STREAM
()
);
}
CP_XML_ATTR
(
L"customFormat"
,
true
);
}
if
(
row
->
miyRw
>
0
/*&& std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/
)
{
CP_XML_ATTR
(
L"ht"
,
row
->
miyRw
/
20.
);
CP_XML_ATTR
(
L"customHeight"
,
true
);
}
if
(
row
->
iOutLevel
>
0
)
{
CP_XML_ATTR
(
L"outlineLevel"
,
row
->
iOutLevel
);
}
if
(
row
->
fCollapsed
)
{
CP_XML_ATTR
(
L"collapsed"
,
row
->
fCollapsed
);
}
}
}
while
(
current_row
!=
m_rows
.
end
())
{
//skip cells ... last rows
(
*
current_row
)
->
serialize
(
stream
);
current_row
++
;
}
}
return
0
;
}
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp
View file @
e12281c6
...
...
@@ -33,6 +33,7 @@ const bool XFS::loadContent(BinProcessor& proc)
GlobalWorkbookInfoPtr
global_info
=
proc
.
getGlobalWorkbookInfo
();
global_info
->
cellStyleXfs_count
=
0
;
global_info
->
cellXfs_count
=
0
;
XF
xf
(
cell_xf_current_id
,
style_xf_current_id
);
int
count
=
proc
.
repeated
(
xf
,
16
,
0
);
...
...
@@ -53,6 +54,7 @@ const bool XFS::loadContent(BinProcessor& proc)
else
{
m_arCellXFs
.
push_back
(
elements_
.
front
());
global_info
->
cellXfs_count
++
;
}
elements_
.
pop_front
();
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp
View file @
e12281c6
...
...
@@ -18,6 +18,10 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
startAddedSharedStrings
=
0
;
current_sheet
=
0
;
cmt_rules
=
0
;
cellXfs_count
=
0
;
cellStyleXfs_count
=
0
;
cellStyleDxfs_count
=
0
;
}
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h
View file @
e12281c6
...
...
@@ -85,6 +85,7 @@ public:
int
Version
;
int
cmt_rules
;
int
cellXfs_count
;
int
cellStyleXfs_count
;
int
cellStyleDxfs_count
;
...
...
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