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
e646e21e
Commit
e646e21e
authored
Oct 18, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatWriter - refactoring sections
parent
eb968120
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
338 additions
and
308 deletions
+338
-308
ASCOfficeOdfFile/src/odf/style_paragraph_properties_pptx.cpp
ASCOfficeOdfFile/src/odf/style_paragraph_properties_pptx.cpp
+20
-19
ASCOfficeOdfFile/src/odf/styles.cpp
ASCOfficeOdfFile/src/odf/styles.cpp
+89
-63
ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp
ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp
+11
-4
ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp
...ficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp
+14
-82
ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h
ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h
+3
-5
ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp
...fficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp
+1
-3
ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp
...fficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp
+31
-5
ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h
ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h
+3
-0
ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp
ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp
+126
-100
ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h
ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h
+12
-0
ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp
ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp
+28
-27
No files found.
ASCOfficeOdfFile/src/odf/style_paragraph_properties_pptx.cpp
View file @
e646e21e
...
...
@@ -49,8 +49,9 @@ namespace odf_reader {
namespace
{
std
::
wstring
process_border
(
border_style
&
borderStyle
,
const
_CP_OPT
(
border_widths
)
&
borderLineWidths
,
const
_CP_OPT
(
length
)
&
borderPadding
,
const
std
::
wstring
&
Shadow
=
L""
)
const
_CP_OPT
(
border_widths
)
&
borderLineWidths
,
const
_CP_OPT
(
length
)
&
borderPadding
,
const
std
::
wstring
&
Shadow
=
L""
)
{
std
::
wstring
w_sz
;
std
::
wstring
w_color
;
...
...
@@ -66,20 +67,20 @@ std::wstring process_border(border_style & borderStyle,
double
width
=
borderStyle
.
get_length
().
get_value_unit
(
length
::
pt
);
//borderLineWidths ? borderLineWidths->get_summ_unit(length::pt) : borderStyle.get_length().get_value_unit(length::pt);
int
szInt
=
(
int
)(
0.5
+
8.0
*
width
);
if
(
szInt
<=
0
)
szInt
=
1
;
if
(
szInt
<=
0
)
szInt
=
1
;
w_sz
=
boost
::
lexical_cast
<
std
::
wstring
>
(
szInt
);
w_color
=
boost
::
lexical_cast
<
std
::
wstring
>
(
borderStyle
.
get_color
().
get_hex_value
()
);
if
(
borderPadding
)
w_space
=
boost
::
lexical_cast
<
std
::
wstring
>
((
int
)(
borderPadding
->
get_value_unit
(
length
::
pt
)
+
0.5
)
);
w_space
=
boost
::
lexical_cast
<
std
::
wstring
>
((
int
)(
borderPadding
->
get_value_unit
(
length
::
pt
))
);
switch
(
borderStyle
.
get_style
())
{
case
border_style
:
:
none
:
w_val
=
L"none"
;
break
;
case
border_style
:
:
solid
:
case
border_style
:
:
single
:
w_val
=
L"single"
;
break
;
case
border_style
:
:
single
:
w_val
=
L"single"
;
break
;
case
border_style
:
:
double_
:
w_val
=
L"double"
;
break
;
case
border_style
:
:
dotted
:
w_val
=
L"dotted"
;
break
;
case
border_style
:
:
dashed
:
w_val
=
L"dashed"
;
break
;
...
...
ASCOfficeOdfFile/src/odf/styles.cpp
View file @
e646e21e
...
...
@@ -67,7 +67,9 @@ namespace odf_reader {
std
::
wstring
process_border
(
const
border_style
&
borderStyle
,
const
_CP_OPT
(
border_widths
)
&
borderLineWidths
,
const
_CP_OPT
(
length
)
&
borderPadding
,
const
std
::
wstring
&
Shadow
=
L""
)
_CP_OPT
(
length
)
&
borderPadding
,
_CP_OPT
(
length_or_percent
)
&
margin
,
const
std
::
wstring
&
Shadow
=
L""
)
{
std
::
wstring
w_sz
;
std
::
wstring
w_color
;
...
...
@@ -970,23 +972,18 @@ Choice [0..6]
namespace
{
std
::
wstring
process_page_margin
(
const
_CP_OPT
(
length_or_percent
)
&
Val
,
const
_CP_OPT
(
length_or_percent
)
&
Val2
,
const
_CP_OPT
(
length
)
&
AddVal
=
_CP_OPT
(
length
)())
{
if
(
!
Val
||
Val
->
get_type
()
==
length_or_percent
::
Percent
)
return
L"0"
;
//if ((!Val) || (Val->get_type() == length_or_percent::Percent))
// return L"0";
double
v
1
=
(
!
Val
||
Val
->
get_type
()
==
length_or_percent
::
Percent
)
?
0
:
double
v
=
(
!
Val
||
Val
->
get_type
()
==
length_or_percent
::
Percent
)
?
0
:
(
20.0
*
Val
->
get_length
().
get_value_unit
(
length
::
pt
));
double
v2
=
(
!
Val2
||
Val2
->
get_type
()
==
length_or_percent
::
Percent
)
?
0
:
(
20.0
*
Val2
->
get_length
().
get_value_unit
(
length
::
pt
));
double
dAddVal
=
20.0
*
AddVal
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
0.5
;
if
(
dAddVal
<
0
)
dAddVal
=
0
;
return
boost
::
lexical_cast
<
std
::
wstring
>
(
(
int
)(
(
!
Val
?
v2
:
v1
)
+
dAddVal
));
return
boost
::
lexical_cast
<
std
::
wstring
>
(
(
int
)(
v
+
dAddVal
));
}
}
...
...
@@ -1041,27 +1038,39 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
strm
<<
L"/>"
;
}
if
(
!
common_padding_attlist_
.
fo_padding_top_
)
common_padding_attlist_
.
fo_padding_top_
=
common_padding_attlist_
.
fo_padding_
;
if
(
!
common_padding_attlist_
.
fo_padding_bottom_
)
common_padding_attlist_
.
fo_padding_bottom_
=
common_padding_attlist_
.
fo_padding_
;
if
(
!
common_padding_attlist_
.
fo_padding_left_
)
common_padding_attlist_
.
fo_padding_left_
=
common_padding_attlist_
.
fo_padding_
;
if
(
!
common_padding_attlist_
.
fo_padding_right_
)
common_padding_attlist_
.
fo_padding_right_
=
common_padding_attlist_
.
fo_padding_
;
if
(
common_border_attlist_
.
fo_border_
)
{
std
::
wstring
w_border
,
w_shadow
;
if
(
common_shadow_attlist_
.
style_shadow_
)
w_shadow
=
common_shadow_attlist_
.
style_shadow_
->
get_type
()
!=
shadow_type
::
None
?
L"1"
:
L"0"
;
w_border
=
process_border
(
*
common_border_attlist_
.
fo_border_
,
common_border_line_width_attlist_
.
style_border_line_width_
,
common_padding_attlist_
.
fo_padding_
,
w_shadow
);
if
(
!
common_horizontal_margin_attlist_
.
fo_margin_left_
)
common_horizontal_margin_attlist_
.
fo_margin_left_
=
common_margin_attlist_
.
fo_margin_
;
if
(
!
common_horizontal_margin_attlist_
.
fo_margin_right_
)
common_horizontal_margin_attlist_
.
fo_margin_right_
=
common_margin_attlist_
.
fo_margin_
;
if
(
!
common_vertical_margin_attlist_
.
fo_margin_top_
)
common_vertical_margin_attlist_
.
fo_margin_top_
=
common_margin_attlist_
.
fo_margin_
;
if
(
!
common_vertical_margin_attlist_
.
fo_margin_bottom_
)
common_vertical_margin_attlist_
.
fo_margin_bottom_
=
common_margin_attlist_
.
fo_margin_
;
strm
<<
L"<w:pgBorders>"
;
strm
<<
L"<w:top "
<<
w_border
<<
L"/>"
;
strm
<<
L"<w:left "
<<
w_border
<<
L"/>"
;
strm
<<
L"<w:bottom "
<<
w_border
<<
L"/>"
;
strm
<<
L"<w:right "
<<
w_border
<<
L"/>"
;
strm
<<
L"</w:pgBorders>"
;
//hange offset border from text to from page
if
(
common_padding_attlist_
.
fo_padding_left_
&&
common_horizontal_margin_attlist_
.
fo_margin_left_
)
{
}
if
(
common_padding_attlist_
.
fo_padding_right_
&&
common_horizontal_margin_attlist_
.
fo_margin_right_
)
{
}
if
(
common_padding_attlist_
.
fo_padding_top_
&&
common_vertical_margin_attlist_
.
fo_margin_top_
)
{
}
else
if
(
common_border_attlist_
.
fo_border_top_
||
common_border_attlist_
.
fo_border_bottom_
||
if
(
common_padding_attlist_
.
fo_padding_bottom_
&&
common_vertical_margin_attlist_
.
fo_margin_bottom_
)
{
}
if
(
common_border_attlist_
.
fo_border_
||
common_border_attlist_
.
fo_border_top_
||
common_border_attlist_
.
fo_border_bottom_
||
common_border_attlist_
.
fo_border_left_
||
common_border_attlist_
.
fo_border_right_
)
{
std
::
wstring
w_top
,
w_left
,
w_right
,
w_bottom
,
w_shadow
;
...
...
@@ -1069,23 +1078,39 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
if
(
common_shadow_attlist_
.
style_shadow_
)
w_shadow
=
common_shadow_attlist_
.
style_shadow_
->
get_type
()
!=
shadow_type
::
None
?
L"1"
:
L"0"
;
if
(
common_border_attlist_
.
fo_border_top_
)
w_top
=
process_border
(
*
common_border_attlist_
.
fo_border_top_
,
common_border_line_width_attlist_
.
style_border_line_width_top_
,
common_padding_attlist_
.
fo_padding_top_
,
w_shadow
);
if
(
common_border_attlist_
.
fo_border_bottom_
)
w_bottom
=
process_border
(
*
common_border_attlist_
.
fo_border_bottom_
,
common_border_line_width_attlist_
.
style_border_line_width_bottom_
,
common_padding_attlist_
.
fo_padding_bottom_
,
w_shadow
);
if
(
common_border_attlist_
.
fo_border_left_
)
w_left
=
process_border
(
*
common_border_attlist_
.
fo_border_left_
,
common_border_line_width_attlist_
.
style_border_line_width_left_
,
common_padding_attlist_
.
fo_padding_left_
,
w_shadow
);
if
(
common_border_attlist_
.
fo_border_right_
)
w_right
=
process_border
(
*
common_border_attlist_
.
fo_border_right_
,
common_border_line_width_attlist_
.
style_border_line_width_right_
,
common_padding_attlist_
.
fo_padding_right_
,
w_shadow
);
strm
<<
L"<w:pgBorders>"
;
if
(
common_border_attlist_
.
fo_border_
||
common_border_attlist_
.
fo_border_top_
)
{
w_top
=
process_border
(
common_border_attlist_
.
fo_border_top_
?
*
common_border_attlist_
.
fo_border_top_
:
*
common_border_attlist_
.
fo_border_
,
common_border_line_width_attlist_
.
style_border_line_width_top_
,
common_padding_attlist_
.
fo_padding_top_
,
common_vertical_margin_attlist_
.
fo_margin_top_
,
w_shadow
);
}
if
(
common_border_attlist_
.
fo_border_
||
common_border_attlist_
.
fo_border_bottom_
)
{
w_bottom
=
process_border
(
common_border_attlist_
.
fo_border_bottom_
?
*
common_border_attlist_
.
fo_border_bottom_
:
*
common_border_attlist_
.
fo_border_
,
common_border_line_width_attlist_
.
style_border_line_width_bottom_
,
common_padding_attlist_
.
fo_padding_bottom_
,
common_vertical_margin_attlist_
.
fo_margin_bottom_
,
w_shadow
);
}
if
(
common_border_attlist_
.
fo_border_
||
common_border_attlist_
.
fo_border_left_
)
{
w_left
=
process_border
(
common_border_attlist_
.
fo_border_left_
?
*
common_border_attlist_
.
fo_border_left_
:
*
common_border_attlist_
.
fo_border_
,
common_border_line_width_attlist_
.
style_border_line_width_left_
,
common_padding_attlist_
.
fo_padding_left_
,
common_horizontal_margin_attlist_
.
fo_margin_left_
,
w_shadow
);
}
if
(
common_border_attlist_
.
fo_border_
||
common_border_attlist_
.
fo_border_right_
)
{
w_right
=
process_border
(
common_border_attlist_
.
fo_border_right_
?
*
common_border_attlist_
.
fo_border_right_
:
*
common_border_attlist_
.
fo_border_
,
common_border_line_width_attlist_
.
style_border_line_width_right_
,
common_padding_attlist_
.
fo_padding_right_
,
common_horizontal_margin_attlist_
.
fo_margin_right_
,
w_shadow
);
}
strm
<<
L"<w:pgBorders w:offsetFrom=
\"
text
\"
>"
;
if
(
!
w_top
.
empty
())
strm
<<
L"<w:top "
<<
w_top
<<
L" />"
;
if
(
!
w_left
.
empty
())
strm
<<
L"<w:left "
<<
w_left
<<
L" />"
;
if
(
!
w_right
.
empty
())
strm
<<
L"<w:right "
<<
w_right
<<
L" />"
;
...
...
@@ -1099,7 +1124,7 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
common_horizontal_margin_attlist_
.
fo_margin_right_
||
common_vertical_margin_attlist_
.
fo_margin_top_
||
common_vertical_margin_attlist_
.
fo_margin_bottom_
||
common_margin_attlist_
.
fo_margin_
||
margin_right
||
margin_left
margin_right
||
margin_left
)
{
_CP_OPT
(
odf_types
::
length
)
margin_left_length
,
margin_right_length
;
...
...
@@ -1109,13 +1134,14 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
CP_XML_NODE
(
L"w:pgMar"
)
{
CP_XML_ATTR
(
L"w:
bottom"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_bottom_
,
common_margin_attlist_
.
fo_margin_
,
Context
.
get_header_footer_context
().
footer
()
)
);
CP_XML_ATTR
(
L"w:footer"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_bottom_
,
common_margin_attlist_
.
fo_margin_
)
);
CP_XML_ATTR
(
L"w:
header"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_top_
)
);
CP_XML_ATTR
(
L"w:footer"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_bottom_
)
);
CP_XML_ATTR
(
L"w:gutter"
,
0
);
CP_XML_ATTR
(
L"w:header"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_top_
,
common_margin_attlist_
.
fo_margin_
)
);
CP_XML_ATTR
(
L"w:left"
,
process_page_margin
(
common_horizontal_margin_attlist_
.
fo_margin_left_
,
common_margin_attlist_
.
fo_margin_
,
margin_left_length
)
);
CP_XML_ATTR
(
L"w:right"
,
process_page_margin
(
common_horizontal_margin_attlist_
.
fo_margin_right_
,
common_margin_attlist_
.
fo_margin_
,
margin_right_length
)
);
CP_XML_ATTR
(
L"w:top"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_top_
,
common_margin_attlist_
.
fo_margin_
,
Context
.
get_header_footer_context
().
header
())
);
CP_XML_ATTR
(
L"w:left"
,
process_page_margin
(
common_horizontal_margin_attlist_
.
fo_margin_left_
,
margin_left_length
)
);
CP_XML_ATTR
(
L"w:right"
,
process_page_margin
(
common_horizontal_margin_attlist_
.
fo_margin_right_
,
margin_right_length
)
);
CP_XML_ATTR
(
L"w:top"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_top_
,
Context
.
get_header_footer_context
().
header
())
);
CP_XML_ATTR
(
L"w:bottom"
,
process_page_margin
(
common_vertical_margin_attlist_
.
fo_margin_bottom_
,
Context
.
get_header_footer_context
().
footer
())
);
}
}
...
...
ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp
View file @
e646e21e
...
...
@@ -1082,10 +1082,17 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
switch
(
impl_
->
current_drawing_part_
)
{
case
Area
:
impl_
->
current_graphic_properties
->
content
().
common_draw_fill_attlist_
.
draw_fill_
=
draw_fill
::
solid
;
impl_
->
current_graphic_properties
->
content
().
common_draw_fill_attlist_
.
draw_fill_color_
=
hexColor
;
impl_
->
current_graphic_properties
->
content
().
common_background_color_attlist_
.
fo_background_color_
=
color
(
hexColor
);
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
if
((
impl_
->
is_footer_
||
impl_
->
is_header_
)
&&
(
impl_
->
current_graphic_properties
->
content
().
common_draw_fill_attlist_
.
draw_fill_
)
&&
(
impl_
->
current_graphic_properties
->
content
().
common_draw_fill_attlist_
.
draw_fill_
->
get_type
()
==
draw_fill
::
bitmap
))
{
}
else
impl_
->
current_graphic_properties
->
content
().
common_draw_fill_attlist_
.
draw_fill_
=
draw_fill
::
solid
;
break
;
case
Line
:
impl_
->
current_graphic_properties
->
content
().
svg_stroke_color_
=
hexColor
;
...
...
@@ -1855,9 +1862,9 @@ void odf_drawing_context::start_image(std::wstring odf_path)
draw_image
*
image
=
dynamic_cast
<
draw_image
*>
(
image_elm
.
get
());
if
(
image
==
NULL
)
return
;
image
->
common_xlink_attlist_
.
type_
=
xlink_type
::
Simple
;
image
->
common_xlink_attlist_
.
type_
=
xlink_type
::
Simple
;
image
->
common_xlink_attlist_
.
show_
=
xlink_show
::
Embed
;
image
->
common_xlink_attlist_
.
actuate_
=
xlink_actuate
::
OnLoad
;
image
->
common_xlink_attlist_
.
actuate_
=
xlink_actuate
::
OnLoad
;
if
(
!
odf_path
.
empty
())
image
->
common_xlink_attlist_
.
href_
=
odf_path
;
//may be later set
...
...
ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp
View file @
e646e21e
...
...
@@ -71,21 +71,20 @@ odf_page_layout_context::~odf_page_layout_context()
odf_layout_state
*
odf_page_layout_context
::
last_layout
()
{
if
(
layout_state_list_
.
size
()
>
0
)
if
(
!
layout_state_list_
.
empty
())
return
&
layout_state_list_
.
back
();
else
return
NULL
;
}
odf_master_state
*
odf_page_layout_context
::
last_master
()
{
if
(
master_state_list_
.
size
()
>
0
)
if
(
!
master_state_list_
.
empty
()
)
return
&
master_state_list_
.
back
();
else
return
NULL
;
}
void
odf_page_layout_context
::
start
_master_page
(
std
::
wstring
page_name
)
void
odf_page_layout_context
::
add
_master_page
(
std
::
wstring
page_name
)
{
office_element_ptr
elm
;
create_element
(
L"style"
,
L"master-page"
,
elm
,
odf_context_
);
...
...
@@ -94,7 +93,9 @@ void odf_page_layout_context::start_master_page(std::wstring page_name)
master_state_list_
.
push_back
(
odf_master_state
(
elm
)
);
///////////////////////////////////////
if
(
page_name
.
length
()
<
1
)
page_name
=
L"MasterPage"
+
boost
::
lexical_cast
<
std
::
wstring
>
(
master_state_list_
.
size
());
if
(
page_name
.
empty
())
page_name
=
L"MasterPage"
+
boost
::
lexical_cast
<
std
::
wstring
>
(
master_state_list_
.
size
());
master_state_list_
.
back
().
set_name
(
page_name
);
/////////////////////////
...
...
@@ -102,68 +103,6 @@ void odf_page_layout_context::start_master_page(std::wstring page_name)
create_layout_page
();
master_state_list_
.
back
().
set_layout_name
(
layout_state_list_
.
back
().
get_name
());
}
void
odf_page_layout_context
::
end_master_page
()
{
if
(
master_state_list_
.
size
()
<
1
)
return
;
bool
header
=
false
,
f_header
=
false
,
l_header
=
false
;
bool
footer
=
false
,
f_footer
=
false
,
l_footer
=
false
;
for
(
long
i
=
0
;
i
<
master_state_list_
.
back
().
elements_
.
size
();
i
++
)
{
if
(
!
master_state_list_
.
back
().
elements_
[
i
].
elm
)
continue
;
if
(
master_state_list_
.
back
().
elements_
[
i
].
elm
->
get_type
()
==
typeStyleHeader
)
header
=
true
;
if
(
master_state_list_
.
back
().
elements_
[
i
].
elm
->
get_type
()
==
typeStyleFooter
)
footer
=
true
;
if
(
master_state_list_
.
back
().
elements_
[
i
].
elm
->
get_type
()
==
typeStyleHeaderFirst
)
f_header
=
true
;
if
(
master_state_list_
.
back
().
elements_
[
i
].
elm
->
get_type
()
==
typeStyleFooterFirst
)
f_footer
=
true
;
if
(
master_state_list_
.
back
().
elements_
[
i
].
elm
->
get_type
()
==
typeStyleHeaderLeft
)
l_header
=
true
;
if
(
master_state_list_
.
back
().
elements_
[
i
].
elm
->
get_type
()
==
typeStyleFooterLeft
)
l_footer
=
true
;
}
if
(
f_header
&&
!
f_footer
&&
footer
)
{
add_footer
(
2
);
office_element_ptr
blank_p_elm
;
create_element
(
L"text"
,
L"p"
,
blank_p_elm
,
odf_context_
);
master_state_list_
.
back
().
elements_
.
back
().
elm
->
add_child_element
(
blank_p_elm
);
f_footer
=
true
;
}
if
(
!
f_header
&&
f_footer
&&
header
)
{
add_header
(
2
);
office_element_ptr
blank_p_elm
;
create_element
(
L"text"
,
L"p"
,
blank_p_elm
,
odf_context_
);
master_state_list_
.
back
().
elements_
.
back
().
elm
->
add_child_element
(
blank_p_elm
);
f_header
=
true
;
}
//Так как лажовый Libra и Apach Оо не воспринимают бланковые колонтитулы только первых страниц - городим велосипед на остальные страницы
if
(
!
header
&&
(
f_header
||
l_header
))
{
add_header
(
0
);
office_element_ptr
blank_p_elm
;
create_element
(
L"text"
,
L"p"
,
blank_p_elm
,
odf_context_
);
master_state_list_
.
back
().
elements_
.
back
().
elm
->
add_child_element
(
blank_p_elm
);
header
=
true
;
}
if
(
!
footer
&&
(
f_footer
||
l_footer
))
{
add_footer
(
0
);
office_element_ptr
blank_p_elm
;
create_element
(
L"text"
,
L"p"
,
blank_p_elm
,
odf_context_
);
master_state_list_
.
back
().
elements_
.
back
().
elm
->
add_child_element
(
blank_p_elm
);
footer
=
true
;
}
}
void
odf_page_layout_context
::
process_master_styles
(
office_element_ptr
root
)
{
...
...
@@ -320,7 +259,8 @@ bool odf_page_layout_context::add_footer(int type)
if
(
type
==
1
)
{
if
(
even_and_left_headers_
)
create_element
(
L"style"
,
L"footer-left"
,
elm
,
odf_context_
);
if
(
even_and_left_headers_
)
create_element
(
L"style"
,
L"footer-left"
,
elm
,
odf_context_
);
}
else
if
(
type
==
2
)
create_element
(
L"style"
,
L"footer-first"
,
elm
,
odf_context_
);
...
...
@@ -330,7 +270,7 @@ bool odf_page_layout_context::add_footer(int type)
if
(
!
elm
)
return
false
;
if
(
master_state_list_
.
empty
())
start
_master_page
(
L""
);
add
_master_page
(
L""
);
master_state_list_
.
back
().
add_footer
(
elm
);
/////////////////////////////////////////////////////////////////////
...
...
@@ -377,17 +317,18 @@ bool odf_page_layout_context::add_header(int type)
if
(
type
==
1
)
{
if
(
even_and_left_headers_
)
create_element
(
L"style"
,
L"header-left"
,
elm
,
odf_context_
);
if
(
even_and_left_headers_
)
create_element
(
L"style"
,
L"header-left"
,
elm
,
odf_context_
);
}
else
if
(
type
==
2
)
create_element
(
L"style"
,
L"header-first"
,
elm
,
odf_context_
);
else
create_element
(
L"style"
,
L"header"
,
elm
,
odf_context_
);
if
(
!
elm
)
return
false
;
if
(
!
elm
)
return
false
;
if
(
master_state_list_
.
empty
())
start
_master_page
(
L""
);
add
_master_page
(
L""
);
master_state_list_
.
back
().
add_header
(
elm
);
////////////////////////////////////////////////////////////////////////
...
...
@@ -594,15 +535,6 @@ void odf_page_layout_context::set_pages_mirrored(bool val)
}
}
void
odf_page_layout_context
::
set_even_and_left_headers
(
bool
val
)
{
even_and_left_headers_
=
val
;
}
void
odf_page_layout_context
::
set_title_page_enable
(
bool
val
)
{
}
style_page_layout_properties
*
odf_page_layout_context
::
get_properties
()
{
if
(
layout_state_list_
.
size
()
<
1
)
return
NULL
;
...
...
ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h
View file @
e646e21e
...
...
@@ -60,9 +60,8 @@ public:
void
set_styles_context
(
odf_style_context
*
Context
);
void
start
_master_page
(
std
::
wstring
oox_name
);
void
add
_master_page
(
std
::
wstring
oox_name
);
void
create_layout_page
();
void
end_master_page
();
void
set_current_master_page_base
();
...
...
@@ -91,7 +90,6 @@ public:
void
set_title_page_enable
(
bool
val
);
void
set_pages_mirrored
(
bool
val
);
void
set_even_and_left_headers
(
bool
val
);
bool
add_footer
(
int
type
);
void
set_footer_size
(
_CP_OPT
(
odf_types
::
length
)
length_
);
...
...
@@ -104,9 +102,9 @@ public:
void
set_page_number_format
(
_CP_OPT
(
int
)
&
type
,
_CP_OPT
(
int
)
&
start
);
double
current_page_width_
;
bool
even_and_left_headers_
;
private:
bool
even_and_left_headers_
;
style_page_layout_properties
*
get_properties
();
style_header_footer_properties
*
get_header_properties
();
...
...
ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp
View file @
e646e21e
...
...
@@ -135,7 +135,7 @@ void ods_conversion_context::start_sheet()
drawing_context
()
->
set_styles_context
(
styles_context
());
page_layout_context
()
->
set_styles_context
(
styles_context
());
page_layout_context
()
->
start
_master_page
(
L""
);
page_layout_context
()
->
add
_master_page
(
L""
);
current_table
().
set_table_master_page
(
page_layout_context
()
->
last_master
()
?
page_layout_context
()
->
last_master
()
->
get_name
()
:
L""
);
...
...
@@ -173,8 +173,6 @@ void ods_conversion_context::end_sheet()
table_context_
.
end_table
();
styles_context
()
->
reset_defaults
();
page_layout_context
()
->
end_master_page
();
}
void
ods_conversion_context
::
start_row
(
int
_start_row
,
int
repeated
,
int
level
,
bool
_default
)
...
...
ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp
View file @
e646e21e
...
...
@@ -241,7 +241,7 @@ void odt_conversion_context::end_drawings()
anchor_type
::
type
anchor
=
drawing_context
()
->
get_anchor
();
bool
bSet
=
false
;
if
(
anchor
==
anchor_type
::
Page
||
anchor
==
anchor_type
::
Paragraph
)
if
(
(
anchor
==
anchor_type
::
Page
||
anchor
==
anchor_type
::
Paragraph
)
||
(
is_header_
||
is_footer_
)
)
{
for
(
long
i
=
text_context
()
->
current_level_
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -423,10 +423,16 @@ void odt_conversion_context::set_master_page_name(std::wstring master_name)
return
;
}
style
*
style_
=
dynamic_cast
<
style
*>
(
current_root_elements_
.
back
().
style_elm
.
get
());
if
(
!
style_
)
{
//генерация
}
if
(
style_
)
{
is_paragraph_in_current_section_
=
false
;
style
*
style_
=
dynamic_cast
<
style
*>
(
current_root_elements_
[
0
].
style_elm
.
get
());
if
(
style_
)
style_
->
style_master_page_name_
=
master_name
;
style_
->
style_master_page_name_
=
master_name
;
}
}
int
odt_conversion_context
::
get_current_section_columns
()
{
...
...
@@ -1005,6 +1011,26 @@ void odt_conversion_context::end_header_footer()
is_footer_
=
false
;
}
void
odt_conversion_context
::
add_empty_header
(
int
type
)
{
if
(
start_header
(
type
))
{
start_paragraph
(
false
);
end_paragraph
();
}
end_header_footer
();
}
void
odt_conversion_context
::
add_empty_footer
(
int
type
)
{
if
(
start_footer
(
type
))
{
start_paragraph
(
false
);
end_paragraph
();
}
end_header_footer
();
}
void
odt_conversion_context
::
set_background
(
_CP_OPT
(
color
)
&
color
,
int
type
)
{
if
(
!
color
)
return
;
...
...
ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h
View file @
e646e21e
...
...
@@ -147,6 +147,9 @@ public:
bool
start_footer
(
int
type
);
void
end_header_footer
();
void
add_empty_header
(
int
type
);
void
add_empty_footer
(
int
type
);
void
set_background
(
_CP_OPT
(
color
)
&
color
,
int
type
);
bool
is_paragraph_in_current_section_
;
...
...
ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp
View file @
e646e21e
...
...
@@ -72,6 +72,7 @@ DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback*
pCallBack
=
CallBack
;
//set flags to default
current_section_properties
=
NULL
;
last_section_properties
=
NULL
;
if
(
UpdateProgress
(
290000
))
return
;
...
...
@@ -198,14 +199,44 @@ void DocxConverter::convert_document()
const
OOX
::
CDocument
*
document
=
docx_document
->
GetDocument
();
if
(
!
document
)
return
;
odt_context
->
text_context
()
->
clear_params
();
std
::
vector
<
_section
>
sections
;
//----------------------------------------------------------------------------------------------------------
int
last_section_start
=
0
;
//считаем количесво секций и запоминаем их свойства ..
for
(
long
i
=
0
;
i
<
document
->
m_arrItems
.
size
();
i
++
)
{
if
(
document
->
m_arrItems
[
i
]
==
NULL
)
continue
;
for
(
unsigned
int
nIndex
=
0
;
nIndex
<
document
->
m_arrItems
.
size
();
nIndex
++
)
if
(
document
->
m_arrItems
[
i
]
->
getType
()
==
OOX
::
et_w_p
)
{
convert
(
document
->
m_arrItems
[
nIndex
]);
OOX
::
Logic
::
CParagraph
*
para
=
dynamic_cast
<
OOX
::
Logic
::
CParagraph
*>
(
document
->
m_arrItems
[
i
]);
if
((
para
)
&&
(
para
->
m_oParagraphProperty
))
{
if
(
para
->
m_oParagraphProperty
->
m_oSectPr
.
IsInit
()
)
{
sections
.
push_back
(
_section
(
para
->
m_oParagraphProperty
->
m_oSectPr
.
GetPointer
(),
last_section_start
,
i
+
1
));
last_section_start
=
i
+
1
;
}
}
}
}
sections
.
push_back
(
_section
(
document
->
m_oSectPr
.
GetPointer
(),
last_section_start
,
document
->
m_arrItems
.
size
(),
true
));
//----------------------------------------------------------------------------------------------------------
odt_context
->
text_context
()
->
clear_params
();
convert
(
document
->
m_oSectPr
.
GetPointer
(),
true
);
for
(
int
sect
=
0
;
sect
<
sections
.
size
();
sect
++
)
{
current_section_properties
=
&
sections
[
sect
];
//convert(sections[sect].props, sections[sect].root);
for
(
long
i
=
sections
[
sect
].
start_para
;
i
<
sections
[
sect
].
end_para
;
i
++
)
{
convert
(
document
->
m_arrItems
[
i
]);
}
}
}
void
DocxConverter
::
convert
(
OOX
::
WritingElement
*
oox_unknown
)
{
...
...
@@ -461,6 +492,8 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if
(
bStartNewParagraph
)
{
if
(
odt_context
->
is_paragraph_in_current_section_
)
bStyled
=
true
;
odt_context
->
start_paragraph
(
bStyled
);
if
(
odt_context
->
is_paragraph_in_current_section_
)
...
...
@@ -832,17 +865,18 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
convert
(
oox_paragraph_pr
->
m_oFramePr
.
GetPointer
(),
paragraph_properties
);
//буквица или фрейм
if
(
oox_paragraph_pr
->
m_oSectPr
.
IsInit
()
)
if
(
current_section_properties
)
{
if
(
oox_paragraph_pr
->
m_oSectPr
->
m_oPgNumType
.
IsInit
(
))
if
(
(
current_section_properties
->
props
->
m_oPgNumType
.
IsInit
())
&&
(
current_section_properties
->
props
->
m_oPgNumType
->
m_oStart
.
IsInit
()
))
{
if
(
oox_paragraph_pr
->
m_oSectPr
->
m_oPgNumType
->
m_oStart
.
IsInit
())
paragraph_properties
->
content
().
style_page_number_
=
oox_paragraph_pr
->
m_oSectPr
->
m_oPgNumType
->
m_oStart
->
GetValue
();
//paragraph//style:page-number=
paragraph_properties
->
content
().
style_page_number_
=
current_section_properties
->
props
->
m_oPgNumType
->
m_oStart
->
GetValue
();
}
convert
(
oox_paragraph_pr
->
m_oSectPr
.
GetPointer
()
);
convert
(
current_section_properties
->
props
,
current_section_properties
->
root
);
}
//if (oox_paragraph_pr->m_oSectPr.IsInit())
//{
// convert(oox_paragraph_pr->m_oSectPr.GetPointer()); перенесено выше
//}
if
(
oox_paragraph_pr
->
m_oTabs
.
IsInit
())
{
...
...
@@ -976,6 +1010,7 @@ void DocxConverter::apply_from(OOX::Logic::CSectionProperty *props, OOX::Logic::
void
DocxConverter
::
convert
(
OOX
::
Logic
::
CSectionProperty
*
oox_section_pr
,
bool
root
)
{
if
(
oox_section_pr
==
NULL
)
return
;
current_section_properties
=
NULL
;
odt_context
->
text_context
()
->
set_type_break
(
-
1
,
0
);
...
...
@@ -996,22 +1031,19 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
break
;
}
}
if
(
continuous
&&
last_section_properties
)
{
// нужно убрать автоматический разрыв.на следующую страницу
// +
//нужно текущие совйства накотить на предыдущие !! .. и так пока continues далее повторяется
apply_from
(
last_section_properties
,
oox_section_pr
);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if
(
!
last_section_properties
&&
(
root
||
continuous
==
false
))
{
last_section_properties
=
oox_section_pr
;
}
else
else
if
(
root
||
continuous
==
false
)
{
apply_from
(
last_section_properties
,
oox_section_pr
);
}
//oox_section_pr = last_section_properties;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if
(
!
continuous
||
(
root
&&
odt_context
->
page_layout_context
()
->
last_master
()
==
NULL
)
)
if
(
root
||
continuous
==
false
)
{
odt_context
->
page_layout_context
()
->
start
_master_page
(
root
?
L"Standard"
:
L""
);
odt_context
->
page_layout_context
()
->
add
_master_page
(
root
?
L"Standard"
:
L""
);
}
bool
present_header
=
false
;
...
...
@@ -1022,9 +1054,9 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
_CP_OPT
(
odf_types
::
length
)
top
,
left
,
right
,
bottom
,
other
;
convert
(
oox_section_pr
->
m_oPgMar
->
m_oBottom
.
GetPointer
(),
bottom
);
convert
(
oox_section_pr
->
m_oPgMar
->
m_oLeft
.
GetPointer
()
,
left
);
convert
(
oox_section_pr
->
m_oPgMar
->
m_oRight
.
GetPointer
()
,
right
);
convert
(
oox_section_pr
->
m_oPgMar
->
m_oTop
.
GetPointer
()
,
top
);
convert
(
oox_section_pr
->
m_oPgMar
->
m_oLeft
.
GetPointer
()
,
left
);
convert
(
oox_section_pr
->
m_oPgMar
->
m_oRight
.
GetPointer
()
,
right
);
convert
(
oox_section_pr
->
m_oPgMar
->
m_oTop
.
GetPointer
()
,
top
);
odt_context
->
page_layout_context
()
->
set_page_margin
(
top
,
left
,
bottom
,
right
);
...
...
@@ -1133,33 +1165,44 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oRtlGutter;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oTitlePg;
if
(
oox_section_pr
->
m_oPgNumType
.
IsInit
())
{
_CP_OPT
(
int
)
format
;
_CP_OPT
(
int
)
start
;
if
(
oox_section_pr
->
m_oPgNumType
->
m_oFmt
.
IsInit
())
format
=
oox_section_pr
->
m_oPgNumType
->
m_oFmt
->
GetValue
();
if
(
oox_section_pr
->
m_oPgNumType
->
m_oStart
.
IsInit
())
start
=
oox_section_pr
->
m_oPgNumType
->
m_oStart
->
GetValue
();
if
(
oox_section_pr
->
m_oPgNumType
->
m_oStart
.
IsInit
())
start
=
oox_section_pr
->
m_oPgNumType
->
m_oStart
->
GetValue
();
odt_context
->
page_layout_context
()
->
set_page_number_format
(
format
,
start
);
//nullable<SimpleTypes::CChapterSep<> > m_oChapSep;
//nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle;
}
OOX
::
Logic
::
CSectionProperty
*
s
=
oox_section_pr
;
if
(
present_header
&&
s
->
m_arrHeaderReference
.
size
()
<
1
&&
last_section_properties
)
s
=
last_section_properties
;
if
(
continuous
==
false
||
root
)
{
OOX
::
Logic
::
CSectionProperty
*
s
=
last_section_properties
;
bool
present_title_page
=
s
->
m_oTitlePg
.
IsInit
()
?
true
:
false
;
bool
present_odd_even_pages
=
odt_context
->
page_layout_context
()
->
even_and_left_headers_
;
bool
add_title_header
=
false
,
add_title_footer
=
false
;
bool
add_odd_even_pages_header
=
false
,
add_odd_even_pages_footer
=
false
;
bool
add_default_header
=
false
,
add_default_footer
=
false
;
std
::
vector
<
int
>
types
;
for
(
unsigned
int
i
=
0
;
i
<
s
->
m_arrHeaderReference
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
s
->
m_arrHeaderReference
.
size
();
i
++
)
{
if
(
s
->
m_arrHeaderReference
[
i
]
==
NULL
)
continue
;
int
type
=
s
->
m_arrHeaderReference
[
i
]
->
m_oType
.
IsInit
()
?
s
->
m_arrHeaderReference
[
i
]
->
m_oType
->
GetValue
()
:
0
;
int
type
=
s
->
m_arrHeaderReference
[
i
]
->
m_oType
.
IsInit
()
?
s
->
m_arrHeaderReference
[
i
]
->
m_oType
->
GetValue
()
:
0
;
if
(
type
==
2
)
add_title_header
=
true
;
if
(
type
==
2
&&
!
present_title_page
)
continue
;
if
(
type
==
1
&&
!
present_odd_even_pages
)
continue
;
if
(
type
==
2
&&
present_title_page
)
add_title_header
=
true
;
if
(
type
==
1
&&
present_odd_even_pages
)
add_odd_even_pages_header
=
true
;
//swap even & odd ?
if
(
type
==
0
)
add_default_header
=
true
;
if
(
odt_context
->
start_header
(
type
))
{
...
...
@@ -1172,18 +1215,9 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
odt_context
->
end_header_footer
();
}
}
if
(
present_title_page
&&
!
add_title_header
)
{
if
(
odt_context
->
start_header
(
2
))
{
odt_context
->
start_paragraph
(
false
);
odt_context
->
end_paragraph
();
}
odt_context
->
end_header_footer
();
}
s
=
oox_section_pr
;
if
(
present_footer
&&
s
->
m_arrFooterReference
.
size
()
<
1
&&
last_section_properties
)
s
=
last_section_properties
;
// нужно хранить ссылки на ВСЕ !!!
if
(
!
add_title_header
&&
present_title_page
)
odt_context
->
add_empty_header
(
2
);
if
(
!
add_odd_even_pages_header
&&
present_odd_even_pages
)
odt_context
->
add_empty_header
(
1
);
if
(
!
add_default_header
&&
(
present_odd_even_pages
||
present_title_page
))
odt_context
->
add_empty_header
(
0
);
for
(
unsigned
int
i
=
0
;
i
<
s
->
m_arrFooterReference
.
size
();
i
++
)
{
...
...
@@ -1191,7 +1225,12 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
int
type
=
s
->
m_arrFooterReference
[
i
]
->
m_oType
.
IsInit
()
?
s
->
m_arrFooterReference
[
i
]
->
m_oType
->
GetValue
()
:
0
;
if
(
type
==
2
)
add_title_footer
=
true
;
if
(
type
==
2
&&
!
present_title_page
)
continue
;
if
(
type
==
1
&&
!
present_odd_even_pages
)
continue
;
if
(
type
==
2
&&
present_title_page
)
add_title_footer
=
true
;
if
(
type
==
1
&&
present_odd_even_pages
)
add_odd_even_pages_footer
=
true
;
if
(
type
==
0
)
add_default_footer
=
true
;
if
(
odt_context
->
start_footer
(
type
))
{
...
...
@@ -1204,21 +1243,17 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
odt_context
->
end_header_footer
();
}
}
if
(
present_title_page
&&
!
add_title_footer
)
{
if
(
odt_context
->
start_footer
(
2
))
{
odt_context
->
start_paragraph
(
false
);
odt_context
->
end_paragraph
();
}
odt_context
->
end_header_footer
();
}
//--------------------------------------------------------------------------------------------------------------------------------------------
if
(
!
add_title_footer
&&
present_title_page
)
odt_context
->
add_empty_footer
(
2
);
if
(
!
add_odd_even_pages_footer
&&
present_odd_even_pages
)
odt_context
->
add_empty_footer
(
1
);
if
(
!
add_default_footer
&&
(
present_odd_even_pages
||
present_title_page
))
odt_context
->
add_empty_footer
(
0
);
if
(
!
continuous
)
odt_context
->
set_master_page_name
(
odt_context
->
page_layout_context
()
->
last_master
()
?
odt_context
->
page_layout_context
()
->
last_master
()
->
get_name
()
:
L""
);
odt_context
->
is_paragraph_in_current_section_
=
true
;
//odt_context->set_master_page_name(odt_context->page_layout_context()->last_master() ?
// odt_context->page_layout_context()->last_master()->get_name() : L"");
}
//--------------------------------------------------------------------------------------------------------------------------------------------
// то что относится собственно к секциям-разделам
//if (!root)odt_context->add_section(continuous);
...
...
@@ -1284,14 +1319,6 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if
(
root
)
odt_context
->
flush_section
();
}
if
(
!
continuous
)
odt_context
->
page_layout_context
()
->
end_master_page
();
// для добавления автогенераций
if
(
root
)
{
odt_context
->
page_layout_context
()
->
set_current_master_page_base
();
}
last_section_properties
=
oox_section_pr
;
}
void
DocxConverter
::
convert
(
OOX
::
Logic
::
CBackground
*
oox_background
,
int
type
)
{
...
...
@@ -2750,8 +2777,7 @@ void DocxConverter::convert_settings()
odt_context
->
page_layout_context
()
->
set_pages_mirrored
(
true
);
}
if
(
docx_settings
->
m_oEvenAndOddHeaders
.
IsInit
())
odt_context
->
page_layout_context
()
->
set_even_and_left_headers
(
true
);
else
odt_context
->
page_layout_context
()
->
set_even_and_left_headers
(
false
);
odt_context
->
page_layout_context
()
->
even_and_left_headers_
=
docx_settings
->
m_oEvenAndOddHeaders
.
IsInit
();
if
(
docx_settings
->
m_oPrintTwoOnOne
.
IsInit
())
{
...
...
ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h
View file @
e646e21e
...
...
@@ -140,6 +140,18 @@ namespace Oox2Odf
void
convert
(
OOX
::
WritingElement
*
oox_unknown
);
private:
struct
_section
{
_section
()
:
start_para
(
0
),
end_para
(
-
1
),
props
(
NULL
),
root
(
false
)
{}
_section
(
OOX
::
Logic
::
CSectionProperty
*
s
,
int
start
=
0
,
int
end
=
-
1
,
bool
r
=
false
)
:
props
(
s
),
start_para
(
start
),
end_para
(
end
),
root
(
r
)
{}
OOX
::
Logic
::
CSectionProperty
*
props
;
int
start_para
;
int
end_para
;
bool
root
;
}
*
current_section_properties
;
OOX
::
CDocx
*
docx_document
;
cpdoccore
::
odf_writer
::
package
::
odf_document
*
output_document
;
...
...
ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp
View file @
e646e21e
...
...
@@ -163,7 +163,7 @@ void XlsxConverter::convert_sheets()
const
OOX
::
Spreadsheet
::
CWorkbook
*
Workbook
=
xlsx_document
->
GetWorkbook
();
if
(
!
Workbook
)
return
;
std
::
map
<
CS
tring
,
OOX
::
Spreadsheet
::
CWorksheet
*>
&
arrWorksheets
=
xlsx_document
->
GetWorksheets
();
std
::
map
<
std
::
ws
tring
,
OOX
::
Spreadsheet
::
CWorksheet
*>
&
arrWorksheets
=
xlsx_document
->
GetWorksheets
();
if
(
Workbook
->
m_oBookViews
.
IsInit
())
{
...
...
@@ -181,12 +181,12 @@ void XlsxConverter::convert_sheets()
if
(
pSheet
->
m_oRid
.
IsInit
())
{
CString
sSheetRId
=
pSheet
->
m_oRid
.
get2
().
ToString
();
std
::
map
<
CString
,
OOX
::
Spreadsheet
::
CWorksheet
*>::
iterator
pItWorksheet
=
arrWorksheets
.
find
(
sSheetRId
);
std
::
map
<
std
::
wstring
,
OOX
::
Spreadsheet
::
CWorksheet
*>::
iterator
pItWorksheet
=
arrWorksheets
.
find
(
string2std_string
(
sSheetRId
)
);
if
(
pItWorksheet
->
second
)
{
ods_context
->
start_sheet
();
ods_context
->
current_table
().
set_table_name
(
string2std_string
(
pSheet
->
m_oName
.
get2
()));
ods_context
->
current_table
().
set_table_name
(
pSheet
->
m_oName
.
get2
());
if
(
pSheet
->
m_oState
.
IsInit
()
&&
(
pSheet
->
m_oState
->
GetValue
()
==
SimpleTypes
::
Spreadsheet
::
visibleHidden
||
pSheet
->
m_oState
->
GetValue
()
==
SimpleTypes
::
Spreadsheet
::
visibleVeryHidden
))
ods_context
->
current_table
().
set_table_hidden
(
true
);
...
...
@@ -215,15 +215,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined)
if
(
oox_defined
->
m_oName
.
IsInit
()
&&
oox_defined
->
m_oRef
.
IsInit
())
{
std
::
wstring
name
=
string2std_string
(
oox_defined
->
m_oName
.
get2
()
);
std
::
wstring
name
=
oox_defined
->
m_oName
.
get2
(
);
bool
printable
=
false
;
if
(
name
==
L"_xlnm.Print_Area"
)
printable
=
true
;
if
(
false
)
//если простой - range, составной - выражение
ods_context
->
add_defined_range
(
name
,
string2std_string
(
oox_defined
->
m_oRef
.
get2
()
),
sheet_id
,
printable
);
ods_context
->
add_defined_range
(
name
,
oox_defined
->
m_oRef
.
get2
(
),
sheet_id
,
printable
);
else
ods_context
->
add_defined_expression
(
name
,
string2std_string
(
oox_defined
->
m_oRef
.
get2
()
),
sheet_id
,
printable
);
ods_context
->
add_defined_expression
(
name
,
oox_defined
->
m_oRef
.
get2
(
),
sheet_id
,
printable
);
}
}
...
...
@@ -233,7 +233,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
if
(
oox_sheet
->
m_oDimension
.
IsInit
())
{
ods_context
->
set_sheet_dimension
(
string2std_string
(
oox_sheet
->
m_oDimension
->
m_oRef
.
get
()
));
ods_context
->
set_sheet_dimension
(
oox_sheet
->
m_oDimension
->
m_oRef
.
get
(
));
}
convert
(
oox_sheet
->
m_oSheetFormatPr
.
GetPointer
());
convert
(
oox_sheet
->
m_oSheetPr
.
GetPointer
());
...
...
@@ -245,7 +245,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert
(
oox_sheet
->
m_oHyperlinks
->
m_arrItems
[
hyp
],
oox_sheet
);
}
//комментарии
std
::
map
<
CS
tring
,
OOX
::
Spreadsheet
::
CCommentItem
*>::
iterator
pos
=
oox_sheet
->
m_mapComments
.
begin
();
std
::
map
<
std
::
ws
tring
,
OOX
::
Spreadsheet
::
CCommentItem
*>::
iterator
pos
=
oox_sheet
->
m_mapComments
.
begin
();
while
(
oox_sheet
->
m_mapComments
.
end
()
!=
pos
)
{
convert
(
pos
->
second
);
...
...
@@ -281,7 +281,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
for
(
unsigned
int
mrg
=
0
;
oox_sheet
->
m_oMergeCells
.
IsInit
()
&&
mrg
<
oox_sheet
->
m_oMergeCells
->
m_arrItems
.
size
();
mrg
++
)
{
if
(
oox_sheet
->
m_oMergeCells
->
m_arrItems
[
mrg
]
->
m_oRef
.
IsInit
())
ods_context
->
add_merge_cells
(
string2std_string
(
oox_sheet
->
m_oMergeCells
->
m_arrItems
[
mrg
]
->
m_oRef
.
get
()
));
ods_context
->
add_merge_cells
(
oox_sheet
->
m_oMergeCells
->
m_arrItems
[
mrg
]
->
m_oRef
.
get
(
));
}
if
(
oox_sheet
->
m_oDrawing
.
IsInit
()
&&
oox_sheet
->
m_oDrawing
->
m_oId
.
IsInit
())
{
...
...
@@ -373,7 +373,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCommentItem * oox_comment)
int
col
=
oox_comment
->
m_nCol
.
IsInit
()
?
oox_comment
->
m_nCol
.
get
()
+
1
:
-
1
;
int
row
=
oox_comment
->
m_nRow
.
IsInit
()
?
oox_comment
->
m_nRow
.
get
()
+
1
:
-
1
;
std
::
wstring
author
=
oox_comment
->
m_sAuthor
.
IsInit
()
?
string2std_string
(
oox_comment
->
m_sAuthor
.
get
()
)
:
L""
;
std
::
wstring
author
=
oox_comment
->
m_sAuthor
.
IsInit
()
?
oox_comment
->
m_sAuthor
.
get
(
)
:
L""
;
ods_context
->
start_comment
(
col
,
row
,
author
);
if
(
oox_comment
->
m_dLeftMM
.
IsInit
()
&&
oox_comment
->
m_dTopMM
.
IsInit
()
&&
oox_comment
->
m_dWidthMM
.
IsInit
()
&&
oox_comment
->
m_dHeightMM
.
IsInit
())
...
...
@@ -396,7 +396,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CHyperlink *oox_hyperlink,OOX::Spr
if
(
oox_hyperlink
==
NULL
)
return
;
if
(
oox_sheet
==
NULL
)
return
;
std
::
wstring
ref
=
oox_hyperlink
->
m_oRef
.
IsInit
()
?
string2std_string
(
oox_hyperlink
->
m_oRef
.
get
()
)
:
L""
;
std
::
wstring
ref
=
oox_hyperlink
->
m_oRef
.
IsInit
()
?
oox_hyperlink
->
m_oRef
.
get
(
)
:
L""
;
std
::
wstring
link
;
if
(
oox_hyperlink
->
m_oRid
.
IsInit
()
&&
oox_sheet
->
GetCurRls
())
{
...
...
@@ -408,7 +408,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CHyperlink *oox_hyperlink,OOX::Spr
link
=
oRels
->
Target
().
GetPath
();
}
}
std
::
wstring
display
=
oox_hyperlink
->
m_oDisplay
.
IsInit
()
?
string2std_string
(
oox_hyperlink
->
m_oDisplay
.
get
()
)
:
L""
;
std
::
wstring
display
=
oox_hyperlink
->
m_oDisplay
.
IsInit
()
?
oox_hyperlink
->
m_oDisplay
.
get
(
)
:
L""
;
ods_context
->
add_hyperlink
(
ref
,
link
,
display
);
}
...
...
@@ -476,7 +476,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
//nullable<SimpleTypes::COnOff<>> m_oShowPhonetic;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oValueMetadata;
std
::
wstring
ref
=
oox_cell
->
m_oRef
.
IsInit
()
?
string2std_string
(
oox_cell
->
m_oRef
.
get
()
)
:
L""
;
std
::
wstring
ref
=
oox_cell
->
isInitRef
()
?
oox_cell
->
getRef
(
)
:
L""
;
int
ifx_style
=
oox_cell
->
m_oStyle
.
IsInit
()
?
oox_cell
->
m_oStyle
->
GetValue
()
:
-
1
;
...
...
@@ -497,7 +497,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
{
if
(
value_type
==
SimpleTypes
::
Spreadsheet
::
celltypeSharedString
)
{
convert_sharing_string
(
_wtoi
(
oox_cell
->
m_oValue
->
m_sText
));
convert_sharing_string
(
_wtoi
(
oox_cell
->
m_oValue
->
m_sText
.
c_str
()
));
}
else
...
...
@@ -505,7 +505,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
if
(
value_type
>=
0
)
ods_context
->
current_table
().
set_cell_type
(
value_type
);
ods_context
->
current_table
().
set_cell_value
(
string2std_string
(
oox_cell
->
m_oValue
->
m_sText
)
);
ods_context
->
current_table
().
set_cell_value
(
oox_cell
->
m_oValue
->
m_sText
);
}
}
...
...
@@ -657,7 +657,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr)
if
(
oox_run_pr
->
m_oRFont
.
IsInit
())
{
//text_properties->content().style_font_name_ = string2std_string(oox_run_pr->m_oRFont->m_sVal.get());
text_properties
->
content
().
fo_font_family_
=
string2std_string
(
oox_run_pr
->
m_oRFont
->
m_sVal
.
get
()
);
text_properties
->
content
().
fo_font_family_
=
oox_run_pr
->
m_oRFont
->
m_sVal
.
get
(
);
}
if
(
oox_run_pr
->
m_oVertAlign
.
IsInit
()
&&
oox_run_pr
->
m_oVertAlign
->
m_oVerticalAlign
.
IsInit
())
...
...
@@ -701,19 +701,19 @@ void XlsxConverter::convert(OOX::Spreadsheet::CText *oox_text)
{
if
(
oox_text
==
NULL
)
return
;
ods_context
->
add_text_content
(
string2std_string
(
oox_text
->
m_sText
)
);
ods_context
->
add_text_content
(
oox_text
->
m_sText
);
}
void
XlsxConverter
::
convert
(
OOX
::
Spreadsheet
::
CFormula
*
oox_formula
)
{
if
(
oox_formula
==
NULL
)
return
;
std
::
wstring
formula
=
string2std_string
(
oox_formula
->
m_sText
)
;
std
::
wstring
formula
=
oox_formula
->
m_sText
;
std
::
wstring
ref
;
int
ind
=
-
1
;
if
(
oox_formula
->
m_oSi
.
IsInit
())
ind
=
oox_formula
->
m_oSi
->
GetValue
();
if
(
oox_formula
->
m_oRef
.
IsInit
())
ref
=
string2std_string
(
oox_formula
->
m_oRef
.
get2
()
);
if
(
oox_formula
->
m_oRef
.
IsInit
())
ref
=
oox_formula
->
m_oRef
.
get2
(
);
if
(
oox_formula
->
m_oT
.
IsInit
())
{
...
...
@@ -836,7 +836,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views)
if
(
pSheet
)
{
ods_context
->
settings_context
()
->
add_property
(
L"ActiveTable"
,
L"string"
,
string2std_string
(
pSheet
->
m_oName
.
get2
()
));
ods_context
->
settings_context
()
->
add_property
(
L"ActiveTable"
,
L"string"
,
pSheet
->
m_oName
.
get2
(
));
}
}
}
...
...
@@ -922,7 +922,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
if
(
selection
->
m_oActiveCell
.
IsInit
())
{
std
::
wstring
ref
(
selection
->
m_oActiveCell
->
GetBuffer
());
std
::
wstring
ref
(
selection
->
m_oActiveCell
.
get
());
odf_writer
::
utils
::
parsing_ref
(
ref
,
ActiveCellX
,
ActiveCellY
);
if
(
ActiveCellX
>=
0
&&
ActiveCellY
>=
0
)
...
...
@@ -1198,7 +1198,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf_writer::style_te
if
(
font
->
m_oRFont
.
IsInit
())
{
font_name
=
string2std_string
(
font
->
m_oRFont
->
m_sVal
.
get
()
);
font_name
=
font
->
m_oRFont
->
m_sVal
.
get
(
);
text_properties
->
content
().
fo_font_family_
=
font_name
;
text_properties
->
content
().
style_font_family_asian_
=
font_name
;
text_properties
->
content
().
style_font_family_complex_
=
font_name
;
...
...
@@ -1280,7 +1280,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CNumFmt *numFmt)
if
(
numFmt
->
m_oFormatCode
.
IsInit
()
&&
numFmt
->
m_oNumFmtId
.
IsInit
())
{
ods_context
->
numbers_styles_context
()
->
add_or_find
(
numFmt
->
m_oNumFmtId
->
GetValue
(),
string2std_string
(
numFmt
->
m_oFormatCode
.
get
()
));
ods_context
->
numbers_styles_context
()
->
add_or_find
(
numFmt
->
m_oNumFmtId
->
GetValue
(),
numFmt
->
m_oFormatCode
.
get
(
));
}
}
void
XlsxConverter
::
convert
(
OOX
::
Spreadsheet
::
CAligment
*
aligment
,
odf_writer
::
style_paragraph_properties
*
paragraph_properties
...
...
@@ -1553,7 +1553,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
SimpleTypes
::
Spreadsheet
::
CHexColor
*
oRgbColor
=
new
SimpleTypes
::
Spreadsheet
::
CHexColor
(
ucR
,
ucG
,
ucB
,
ucA
);
if
(
oRgbColor
)
{
odf_color
=
odf_types
::
color
(
std
::
wstring
(
L"#"
)
+
string2std_string
(
oRgbColor
->
ToString
().
Right
(
6
)));
std
::
wstring
sRgbColor
=
oRgbColor
->
ToString
();
odf_color
=
odf_types
::
color
(
std
::
wstring
(
L"#"
)
+
sRgbColor
.
substr
(
sRgbColor
.
length
()
-
6
,
6
));
delete
oRgbColor
;
}
}
...
...
@@ -1568,7 +1569,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style)
int
oox_id
=
parent_id
;
//
std
::
wstring
style_name
=
L""
;
if
(
cell_style
->
m_oName
.
IsInit
())
style_name
=
string2std_string
(
cell_style
->
m_oName
.
get
()
);
if
(
cell_style
->
m_oName
.
IsInit
())
style_name
=
cell_style
->
m_oName
.
get
(
);
ods_context
->
styles_context
()
->
create_style
(
style_name
,
odf_types
::
style_family
::
TableCell
,
automatic
,
root
,
oox_id
);
...
...
@@ -2160,7 +2161,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox
std
::
wstring
val
;
int
type
=
3
;
if
(
oox_cond_value
->
m_oVal
.
IsInit
())
val
=
string2std_string
(
oox_cond_value
->
m_oVal
.
get2
()
);
if
(
oox_cond_value
->
m_oVal
.
IsInit
())
val
=
oox_cond_value
->
m_oVal
.
get2
(
);
if
(
oox_cond_value
->
m_oType
.
IsInit
())
type
=
oox_cond_value
->
m_oType
->
GetValue
();
ods_context
->
current_table
().
set_conditional_value
(
type
,
val
);
...
...
@@ -2168,7 +2169,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox
void
XlsxConverter
::
convert
(
OOX
::
Spreadsheet
::
CFormulaCF
*
oox_cond_formula
)
{
if
(
!
oox_cond_formula
)
return
;
ods_context
->
current_table
().
set_conditional_formula
(
string2std_string
(
oox_cond_formula
->
m_sText
)
);
ods_context
->
current_table
().
set_conditional_formula
(
oox_cond_formula
->
m_sText
);
}
void
XlsxConverter
::
convert
(
OOX
::
Spreadsheet
::
CFilterColumn
*
oox_filter_column
)
{
...
...
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