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
71aabb5f
Commit
71aabb5f
authored
Nov 28, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatReader - fix bugs in track changes
parent
18a96323
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
185 additions
and
189 deletions
+185
-189
ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp
ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp
+76
-67
ASCOfficeOdfFile/src/docx/docx_conversion_context.h
ASCOfficeOdfFile/src/docx/docx_conversion_context.h
+26
-38
ASCOfficeOdfFile/src/odf/paragraph_elements.cpp
ASCOfficeOdfFile/src/odf/paragraph_elements.cpp
+12
-12
ASCOfficeOdfFile/src/odf/paragraph_elements.h
ASCOfficeOdfFile/src/odf/paragraph_elements.h
+2
-2
ASCOfficeOdfFile/src/odf/ruby.cpp
ASCOfficeOdfFile/src/odf/ruby.cpp
+3
-3
ASCOfficeOdfFile/src/odf/ruby.h
ASCOfficeOdfFile/src/odf/ruby.h
+3
-3
ASCOfficeOdfFile/src/odf/styles.cpp
ASCOfficeOdfFile/src/odf/styles.cpp
+0
-7
ASCOfficeOdfFile/src/odf/table_docx.cpp
ASCOfficeOdfFile/src/odf/table_docx.cpp
+0
-12
ASCOfficeOdfFile/src/odf/text_elements.cpp
ASCOfficeOdfFile/src/odf/text_elements.cpp
+52
-33
ASCOfficeOdfFile/src/odf/text_elements.h
ASCOfficeOdfFile/src/odf/text_elements.h
+11
-12
No files found.
ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp
View file @
71aabb5f
...
...
@@ -82,12 +82,13 @@ void text_tracked_context::start_changes_content()
void
text_tracked_context
::
end_changes_content
()
{
current_state_
.
content
.
push_back
(
changes_stream_
.
str
());
docx_context_
.
set_delete_text_state
(
false
);
docx_context_
.
set_paragraph_state
(
bParaStateDocx_
);
docx_context_
.
set_run_state
(
bRunStateDocx_
);
docx_context_
.
set_delete_text_state
(
false
);
current_state_
.
content
=
changes_stream_
.
str
();
docx_context_
.
set_stream_man
(
docx_stream_
);
docx_context_
.
set_stream_man
(
docx_stream_
);
}
void
text_tracked_context
::
start_change
(
std
::
wstring
id
)
{
...
...
@@ -130,28 +131,27 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
docx_conversion_context
::
docx_conversion_context
(
odf_reader
::
odf_document
*
OdfDocument
)
:
mediaitems_
(
OdfDocument
->
get_folder
()
),
next_dump_page_properties_
(
false
),
page_break_after_
(
false
),
page_break_before_
(
false
),
in_run_
(
false
),
in_automatic_style_
(
false
),
in_paragraph_
(
false
),
in_header_
(
false
),
in_drawing_content_
(
false
),
text_tracked_context_
(
*
this
),
table_context_
(
*
this
),
output_document_
(
NULL
),
section_properties_in_table_
(
NULL
),
process_note_
(
noNote
),
new_list_style_number_
(
0
),
is_rtl_
(
false
),
is_paragraph_keep_
(
false
),
is_delete_text_
(
false
),
delayed_converting_
(
false
),
process_headers_footers_
(
false
),
process_comment_
(
false
),
math_context_
(
false
),
odf_document_
(
OdfDocument
)
next_dump_page_properties_
(
false
),
page_break_after_
(
false
),
page_break_before_
(
false
),
in_run_
(
false
),
in_automatic_style_
(
false
),
in_paragraph_
(
false
),
in_header_
(
false
),
in_drawing_content_
(
false
),
text_tracked_context_
(
*
this
),
table_context_
(
*
this
),
output_document_
(
NULL
),
process_note_
(
noNote
),
new_list_style_number_
(
0
),
is_rtl_
(
false
),
is_paragraph_keep_
(
false
),
is_delete_text_
(
false
),
delayed_converting_
(
false
),
process_headers_footers_
(
false
),
process_comment_
(
false
),
math_context_
(
false
),
odf_document_
(
OdfDocument
)
{
streams_man_
=
streams_man
::
create
(
temp_stream_
);
applicationFonts_
=
new
CApplicationFonts
();
...
...
@@ -1128,19 +1128,6 @@ void section_context::add_section(const std::wstring & SectionName, const std::w
sections_
.
push_back
(
newSec
);
}
void
docx_conversion_context
::
section_properties_in_table
(
odf_reader
::
office_element
*
Elm
)
{
section_properties_in_table_
=
Elm
;
}
odf_reader
::
office_element
*
docx_conversion_context
::
get_section_properties_in_table
()
{
odf_reader
::
office_element
*
elm
=
section_properties_in_table_
;
section_properties_in_table_
=
NULL
;
return
elm
;
}
namespace
{
// обработка Header/Footer
...
...
@@ -1273,31 +1260,47 @@ typedef std::map<std::wstring, text_tracked_context::_state>::iterator map_chang
void
docx_conversion_context
::
start_text_changes
(
std
::
wstring
id
)
{
text_tracked_context
::
_state
&
state
=
text_tracked_context_
.
get_tracked_change
(
id
);
if
(
state
.
id
!=
id
)
return
;
text_tracked_context
::
_state
&
state
_add
=
text_tracked_context_
.
get_tracked_change
(
id
);
if
(
state
_add
.
id
!=
id
)
return
;
map_current_changes_
.
insert
(
std
::
pair
<
std
::
wstring
,
text_tracked_context
::
_state
>
(
id
,
state
));
map_current_changes_
.
insert
(
std
::
pair
<
std
::
wstring
,
text_tracked_context
::
_state
>
(
id
,
state
_add
));
if
(
in_paragraph_
&&
(
state
.
type
==
1
||
state
.
type
==
2
))
if
(
in_paragraph_
&&
(
state_add
.
type
==
1
||
state_add
.
type
==
2
))
{
finish_run
();
map_changes_iterator
it
=
map_current_changes_
.
find
(
id
);
text_tracked_context
::
_state
&
state
=
it
->
second
;
std
::
wstring
format_change
=
L" w:date=
\"
"
+
state
.
date
+
L"
\"
"
+
L" w:author=
\"
"
+
state
.
author
+
L"
\"
"
;
if
(
state
.
type
==
1
)
output_stream
()
<<
L"<w:ins"
;
if
(
state
.
type
==
2
)
output_stream
()
<<
L"<w:del"
;
finish_run
();
state
.
active
=
true
;
if
(
state
.
type
==
1
)
{
output_stream
()
<<
L" w:date=
\"
"
<<
state
.
date
<<
L"
\"
"
;
output_stream
()
<<
L" w:author=
\"
"
<<
state
.
author
<<
L"
\"
"
;
output_stream
()
<<
L" w:id=
\"
"
<<
std
::
to_wstring
(
current_id_changes
++
)
<<
L"
\"
"
;
output_stream
()
<<
L">"
;
output_stream
()
<<
L"<w:ins"
<<
format_change
<<
L" w:id=
\"
"
<<
std
::
to_wstring
(
current_id_changes
++
)
<<
L"
\"
>"
;
}
if
(
state
.
type
==
2
)
output_stream
()
<<
state
.
content
;
if
(
state
.
type
==
2
)
{
for
(
int
i
=
0
;
i
<
state
.
content
.
size
();
i
++
)
{
output_stream
()
<<
L"<w:del"
<<
format_change
<<
L" w:id=
\"
"
<<
std
::
to_wstring
(
current_id_changes
++
)
<<
L"
\"
>"
;
output_stream
()
<<
state
.
content
[
i
];
output_stream
()
<<
L"</w:del>"
;
}
map_current_changes_
.
erase
(
it
);
}
}
}
void
docx_conversion_context
::
start_changes
()
{
if
(
map_current_changes_
.
empty
())
return
;
if
(
process_comment_
)
return
;
text_tracked_context_
.
dumpPPr_
.
clear
();
text_tracked_context_
.
dumpRPr_
.
clear
();
...
...
@@ -1309,8 +1312,8 @@ void docx_conversion_context::start_changes()
{
text_tracked_context
::
_state
&
state
=
it
->
second
;
if
(
state
.
type
==
0
)
continue
;
//unknown change ... todooo
if
(
state
.
type
==
0
)
continue
;
//unknown change ... todooo
if
(
state
.
active
)
continue
;
std
::
wstring
change_attr
;
change_attr
+=
L" w:date=
\"
"
+
state
.
date
+
L"
\"
"
;
...
...
@@ -1396,16 +1399,21 @@ void docx_conversion_context::start_changes()
void
docx_conversion_context
::
end_changes
()
{
//for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
//{
// text_tracked_context::_state &state = it->second;
if
(
process_comment_
)
return
;
// if (state.type == 0) continue; //unknown change ... libra format change skip
// if (state.type == 3) continue;
for
(
map_changes_iterator
it
=
map_current_changes_
.
begin
();
it
!=
map_current_changes_
.
end
();
it
++
)
{
text_tracked_context
::
_state
&
state
=
it
->
second
;
// if (state.type == 1) output_stream() << L"</w:ins>";
// if (state.type == 2) output_stream() << L"</w:del>";
//}
if
(
state
.
type
==
0
)
continue
;
//unknown change ... libra format change skip
if
(
state
.
type
==
3
)
continue
;
if
(
!
state
.
active
)
continue
;
if
(
state
.
type
==
1
)
output_stream
()
<<
L"</w:ins>"
;
if
(
state
.
type
==
2
)
output_stream
()
<<
L"</w:del>"
;
state
.
active
=
false
;
}
text_tracked_context_
.
dumpTcPr_
.
clear
();
text_tracked_context_
.
dumpTblPr_
.
clear
();
...
...
@@ -1421,14 +1429,15 @@ void docx_conversion_context::end_text_changes (std::wstring id)
if
(
it
==
map_current_changes_
.
end
())
return
;
if
(
in_paragraph_
)
text_tracked_context
::
_state
&
state
=
it
->
second
;
if
(
state
.
active
)
{
finish_run
();
text_tracked_context
::
_state
&
state
=
it
->
second
;
if
(
in_paragraph_
)
finish_run
();
if
(
state
.
type
==
1
)
output_stream
()
<<
L"</w:ins>"
;
if
(
state
.
type
==
2
)
output_stream
()
<<
L"</w:del>"
;
if
(
state
.
type
==
1
)
output_stream
()
<<
L"</w:ins>"
;
if
(
state
.
type
==
2
)
output_stream
()
<<
L"</w:del>"
;
}
map_current_changes_
.
erase
(
it
);
...
...
ASCOfficeOdfFile/src/docx/docx_conversion_context.h
View file @
71aabb5f
...
...
@@ -490,13 +490,14 @@ class text_tracked_context
public:
struct
_state
{
std
::
wstring
id
;
std
::
wstring
author
;
std
::
wstring
date
;
int
type
;
std
::
wstring
content
;
//delete elements
std
::
wstring
style_name
;
std
::
wstring
id
;
std
::
wstring
author
;
std
::
wstring
date
;
int
type
;
std
::
wstring
style_name
;
std
::
vector
<
std
::
wstring
>
content
;
//delete elements
bool
active
;
void
clear
()
{
type
=
0
;
...
...
@@ -504,6 +505,7 @@ public:
author
.
clear
();
date
.
clear
();
content
.
clear
();
active
=
false
;
}
};
std
::
wstring
dumpPPr_
;
...
...
@@ -683,9 +685,6 @@ public:
docx_table_context
&
get_table_context
()
{
return
table_context_
;
}
odf_reader
::
office_element
*
get_section_properties_in_table
();
void
section_properties_in_table
(
odf_reader
::
office_element
*
Elm
);
StreamsManPtr
get_stream_man
()
const
{
return
streams_man_
;
}
void
set_stream_man
(
StreamsManPtr
Sm
)
{
streams_man_
=
Sm
;
}
...
...
@@ -752,23 +751,23 @@ private:
odf_reader
::
odf_document
*
odf_document_
;
CApplicationFonts
*
applicationFonts_
;
std
::
vector
<
odf_reader
::
_property
>
settings_properties_
;
std
::
vector
<
odf_reader
::
_property
>
settings_properties_
;
hyperlinks
hyperlinks_
;
mediaitems
mediaitems_
;
hyperlinks
hyperlinks_
;
mediaitems
mediaitems_
;
std
::
vector
<
oox_chart_context_ptr
>
charts_
;
headers_footers
headers_footers_
;
std
::
wstring
automatic_parent_style_
;
std
::
list
<
const
odf_reader
::
style_text_properties
*
>
text_properties_stack_
;
std
::
wstring
automatic_parent_style_
;
std
::
wstring
current_master_page_name_
;
std
::
wstring
text_list_style_name_
;
std
::
list
<
std
::
wstring
>
list_style_stack_
;
bool
first_element_list_item_
;
bool
page_break_after_
;
bool
page_break_before_
;
bool
page_break_
;
std
::
wstring
text_list_style_name_
;
std
::
list
<
std
::
wstring
>
list_style_stack_
;
bool
first_element_list_item_
;
bool
in_automatic_style_
;
bool
in_drawing_content_
;
bool
in_paragraph_
;
...
...
@@ -777,25 +776,14 @@ private:
bool
is_delete_text_
;
bool
is_rtl_
;
// right-to-left
bool
is_paragraph_keep_
;
NoteType
process_note_
;
int
new_list_style_number_
;
// счетчик для нумерации имен созданных в процессе конвертации стилей
NoteType
process_note_
;
std
::
list
<
odf_reader
::
office_element
*>
delayed_elements_
;
std
::
vector
<
oox_chart_context_ptr
>
charts_
;
odf_reader
::
office_element
*
section_properties_in_table_
;
headers_footers
headers_footers_
;
std
::
wstring
current_master_page_name_
;
// счетчик для нумерации имен созданных в процессе конвертации стилей
int
new_list_style_number_
;
std
::
map
<
std
::
wstring
,
text_tracked_context
::
_state
>
map_current_changes_
;
// цепочки переименований нумераций
boost
::
unordered_map
<
std
::
wstring
,
std
::
wstring
>
list_style_renames_
;
std
::
list
<
const
odf_reader
::
style_text_properties
*
>
text_properties_stack_
;
std
::
map
<
std
::
wstring
,
text_tracked_context
::
_state
>
map_current_changes_
;
boost
::
unordered_map
<
std
::
wstring
,
std
::
wstring
>
list_style_renames_
;
// цепочки переименований нумераций
};
}
...
...
ASCOfficeOdfFile/src/odf/paragraph_elements.cpp
View file @
71aabb5f
...
...
@@ -332,7 +332,7 @@ const wchar_t * span::name = L"span";
std
::
wostream
&
span
::
text_to_stream
(
std
::
wostream
&
_Wostream
)
const
{
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
content_
)
{
parElement
->
text_to_stream
(
_Wostream
);
}
...
...
@@ -359,13 +359,13 @@ void span::add_attributes( const xml::attributes_wc_ptr & Attributes )
void
span
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
)
{
CP_CREATE_ELEMENT
(
paragraph_
content_
);
CP_CREATE_ELEMENT
(
content_
);
}
void
span
::
add_text
(
const
std
::
wstring
&
Text
)
{
office_element_ptr
elm
=
text
::
create
(
Text
);
paragraph_
content_
.
push_back
(
elm
);
content_
.
push_back
(
elm
);
}
void
span
::
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
...
...
@@ -406,7 +406,7 @@ void span::docx_convert(oox::docx_conversion_context & Context)
if
(
!
addNewRun
)
Context
.
add_new_run
();
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
content_
)
{
parElement
->
docx_convert
(
Context
);
}
...
...
@@ -420,7 +420,7 @@ void span::docx_convert(oox::docx_conversion_context & Context)
void
span
::
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
{
Context
.
start_span
(
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
elm
->
xlsx_convert
(
Context
);
}
...
...
@@ -432,7 +432,7 @@ void span::pptx_convert(oox::pptx_conversion_context & Context)
Context
.
get_text_context
().
get_styles_context
().
start_process_style
(
styleInst
);
Context
.
get_text_context
().
start_span
(
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
elm
->
pptx_convert
(
Context
);
}
...
...
@@ -446,7 +446,7 @@ const wchar_t * a::name = L"a";
std
::
wostream
&
a
::
text_to_stream
(
std
::
wostream
&
_Wostream
)
const
{
BOOST_FOREACH
(
const
office_element_ptr
&
element
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
element
,
content_
)
{
element
->
text_to_stream
(
_Wostream
);
}
...
...
@@ -465,13 +465,13 @@ void a::add_attributes( const xml::attributes_wc_ptr & Attributes )
void
a
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
)
{
CP_CREATE_ELEMENT
(
paragraph_
content_
);
CP_CREATE_ELEMENT
(
content_
);
}
void
a
::
add_text
(
const
std
::
wstring
&
Text
)
{
office_element_ptr
elm
=
text
::
create
(
Text
)
;
paragraph_
content_
.
push_back
(
elm
);
content_
.
push_back
(
elm
);
}
void
a
::
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
...
...
@@ -527,7 +527,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
if
(
!
addNewRun
)
Context
.
add_new_run
();
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
content_
)
{
parElement
->
docx_convert
(
Context
);
}
...
...
@@ -542,7 +542,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
void
a
::
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
{
Context
.
start_hyperlink
(
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
elm
->
xlsx_convert
(
Context
);
}
...
...
@@ -551,7 +551,7 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context)
void
a
::
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
)
{
Context
.
get_text_context
().
start_hyperlink
();
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
elm
->
pptx_convert
(
Context
);
}
...
...
ASCOfficeOdfFile/src/odf/paragraph_elements.h
View file @
71aabb5f
...
...
@@ -378,7 +378,7 @@ public:
span
()
{}
office_element_ptr_array
paragraph_
content_
;
office_element_ptr_array
content_
;
odf_types
::
style_ref
text_style_name_
;
odf_types
::
style_ref_array
text_class_names_
;
...
...
@@ -424,7 +424,7 @@ private:
odf_types
::
style_ref
text_style_name_
;
odf_types
::
style_ref
text_visited_style_name_
;
office_element_ptr_array
paragraph_
content_
;
office_element_ptr_array
content_
;
};
CP_REGISTER_OFFICE_ELEMENT2
(
a
);
...
...
ASCOfficeOdfFile/src/odf/ruby.cpp
View file @
71aabb5f
...
...
@@ -55,7 +55,7 @@ const wchar_t * ruby_base::name = L"ruby-base";
std
::
wostream
&
ruby_base
::
text_to_stream
(
std
::
wostream
&
_Wostream
)
const
{
serialize_elements_text
(
_Wostream
,
paragraph_
content_
);
serialize_elements_text
(
_Wostream
,
content_
);
return
_Wostream
;
}
...
...
@@ -65,13 +65,13 @@ void ruby_base::add_attributes( const xml::attributes_wc_ptr & Attributes )
void
ruby_base
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
)
{
CP_CREATE_ELEMENT
(
paragraph_
content_
);
CP_CREATE_ELEMENT
(
content_
);
}
void
ruby_base
::
add_text
(
const
std
::
wstring
&
Text
)
{
office_element_ptr
elm
=
text
::
create
(
Text
)
;
paragraph_
content_
.
push_back
(
elm
);
content_
.
push_back
(
elm
);
}
// text:ruby-text
...
...
ASCOfficeOdfFile/src/odf/ruby.h
View file @
71aabb5f
...
...
@@ -64,7 +64,7 @@ private:
virtual
void
add_text
(
const
std
::
wstring
&
Text
);
private:
office_element_ptr_array
paragraph_
content_
;
office_element_ptr_array
content_
;
};
...
...
@@ -94,8 +94,8 @@ private:
virtual
void
add_text
(
const
std
::
wstring
&
Text
);
private:
odf_types
::
style_ref
text_style_name_
;
office_element_ptr_array
content_
;
odf_types
::
style_ref
text_style_name_
;
office_element_ptr_array
content_
;
};
...
...
ASCOfficeOdfFile/src/odf/styles.cpp
View file @
71aabb5f
...
...
@@ -1275,13 +1275,6 @@ bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox
}
void
style_page_layout_properties
::
docx_convert_serialize
(
std
::
wostream
&
strm
,
oox
::
docx_conversion_context
&
Context
)
{
if
(
Context
.
get_table_context
().
in_table
())
{
// мы находимся внутри таблицы, устанавливаем специальное значение
Context
.
section_properties_in_table
(
this
);
return
;
}
style_columns
*
columns
=
dynamic_cast
<
style_columns
*>
(
style_page_layout_properties_elements_
.
style_columns_
.
get
());
CP_XML_WRITER
(
strm
)
...
...
ASCOfficeOdfFile/src/odf/table_docx.cpp
View file @
71aabb5f
...
...
@@ -175,18 +175,6 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
Context
.
get_table_context
().
end_table
();
_Wostream
<<
L"</w:tbl>"
;
if
(
office_element
*
elm
=
Context
.
get_section_properties_in_table
())
{
if
(
Context
.
get_table_context
().
in_table
())
Context
.
section_properties_in_table
(
elm
);
else
{
_Wostream
<<
L"<w:p><w:pPr>"
;
elm
->
docx_convert
(
Context
);
_Wostream
<<
L"</w:pPr></w:p>"
;
}
}
}
void
table_columns
::
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
...
...
ASCOfficeOdfFile/src/odf/text_elements.cpp
View file @
71aabb5f
...
...
@@ -249,25 +249,25 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
std
::
wostream
&
paragraph
::
text_to_stream
(
std
::
wostream
&
_Wostream
)
const
{
// TODO!!!!
CP_SERIALIZE_TEXT
(
paragraph_
content_
);
CP_SERIALIZE_TEXT
(
content_
);
_Wostream
<<
L"
\n
"
;
return
_Wostream
;
}
void
paragraph
::
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
)
{
paragraph_
attrs_
.
add_attributes
(
Attributes
);
attrs_
.
add_attributes
(
Attributes
);
}
void
paragraph
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
,
document_context
*
Context
)
{
CP_CREATE_ELEMENT_SIMPLE
(
paragraph_
content_
);
CP_CREATE_ELEMENT_SIMPLE
(
content_
);
}
void
paragraph
::
add_text
(
const
std
::
wstring
&
Text
)
{
office_element_ptr
elm
=
text
::
create
(
Text
)
;
paragraph_
content_
.
push_back
(
elm
);
content_
.
push_back
(
elm
);
}
void
paragraph
::
afterCreate
(
document_context
*
Context
)
...
...
@@ -301,7 +301,7 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
str
=
store_str
.
substr
(
0
,
Context
.
get_drop_cap_context
().
Length
);
int
textStyle
=
process_paragraph_attr
(
paragraph_
attrs_
,
Context
);
int
textStyle
=
process_paragraph_attr
(
attrs_
,
Context
);
first_text_paragraph
->
docx_convert
(
Context
);
int
str_start
=
Context
.
get_drop_cap_context
().
Length
;
...
...
@@ -314,16 +314,16 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
}
void
paragraph
::
drop_cap_docx_convert
(
oox
::
docx_conversion_context
&
Context
)
{
if
(
paragraph_
content_
.
empty
())
return
;
if
(
content_
.
empty
())
return
;
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!- todooo сделать возможным множественным span
if
(
paragraph_
content_
[
0
]
->
get_type
()
==
typeTextText
)
if
(
content_
[
0
]
->
get_type
()
==
typeTextText
)
{
drop_cap_text_docx_convert
(
paragraph_
content_
[
0
],
Context
);
drop_cap_text_docx_convert
(
content_
[
0
],
Context
);
}
else
if
(
paragraph_
content_
[
0
]
->
get_type
()
==
typeTextSpan
)
else
if
(
content_
[
0
]
->
get_type
()
==
typeTextSpan
)
{
span
*
first_span_in_paragraph
=
dynamic_cast
<
span
*>
(
paragraph_
content_
[
0
].
get
());
span
*
first_span_in_paragraph
=
dynamic_cast
<
span
*>
(
content_
[
0
].
get
());
if
(
Context
.
get_drop_cap_context
().
FontSize
<
1
)
{
style_instance
*
styleInst
=
Context
.
root
()
->
odf_context
().
styleContainer
().
style_by_name
(
first_span_in_paragraph
->
text_style_name_
.
style_name
(),
style_family
::
Text
,
Context
.
process_headers_footers_
);
...
...
@@ -343,10 +343,10 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
}
}
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!
if
((
first_span_in_paragraph
->
paragraph_
content_
.
size
()
>
0
)
&&
(
first_span_in_paragraph
->
paragraph_
content_
[
0
]
->
get_type
()
==
typeTextText
))
if
((
first_span_in_paragraph
->
content_
.
size
()
>
0
)
&&
(
first_span_in_paragraph
->
content_
[
0
]
->
get_type
()
==
typeTextText
))
{
drop_cap_text_docx_convert
(
first_span_in_paragraph
->
paragraph_
content_
[
0
],
Context
);
drop_cap_text_docx_convert
(
first_span_in_paragraph
->
content_
[
0
],
Context
);
}
}
}
...
...
@@ -361,9 +361,9 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
bool
bIsNewParagraph
=
true
;
if
(
Context
.
get_paragraph_state
()
&&
(
Context
.
get_process_note
()
==
oox
::
docx_conversion_context
::
noNote
)
&&
!
drawing
)
if
(
Context
.
get_paragraph_state
()
&&
(
Context
.
get_process_note
()
==
oox
::
docx_conversion_context
::
noNote
)
&&
!
drawing
&&
!
Context
.
get_delete_text_state
()
)
{
//вложеннные элементы
if
(
paragraph_
content_
.
empty
())
//??
if
(
content_
.
empty
())
//??
{
Context
.
output_stream
()
<<
L"<w:p>"
;
Context
.
output_stream
()
<<
emptyParagraphContent
;
...
...
@@ -377,15 +377,15 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
if
(
!
Context
.
get_paragraph_keep
())
{
for
(
int
i
=
0
;
i
<
paragraph_
content_
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
content_
.
size
();
i
++
)
{
paragraph_
content_
[
i
]
->
docx_convert
(
Context
);
content_
[
i
]
->
docx_convert
(
Context
);
}
return
;
}
}
}
bool
is_empty
=
paragraph_
content_
.
empty
();
bool
is_empty
=
content_
.
empty
();
if
(
bIsNewParagraph
)
Context
.
start_paragraph
(
is_header_
);
...
...
@@ -398,7 +398,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
// если да — устанавливаем контексту флаг на то что необходимо в конце текущего параграфа
// распечатать свойства секции
//проверить ... не она ли основная - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const
std
::
wstring
&
next_styleName
=
next_par_
->
paragraph_
attrs_
.
text_style_name_
.
style_name
();
const
std
::
wstring
&
next_styleName
=
next_par_
->
attrs_
.
text_style_name_
.
style_name
();
const
_CP_OPT
(
std
::
wstring
)
next_masterPageName
=
Context
.
root
()
->
odf_context
().
styleContainer
().
master_page_name_by_name
(
next_styleName
);
if
((
next_masterPageName
)
&&
(
Context
.
get_master_page_name
()
!=
*
next_masterPageName
))
...
...
@@ -413,7 +413,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty
=
false
;
}
const
std
::
wstring
&
styleName
=
paragraph_
attrs_
.
text_style_name_
.
style_name
();
const
std
::
wstring
&
styleName
=
attrs_
.
text_style_name_
.
style_name
();
const
_CP_OPT
(
std
::
wstring
)
masterPageName
=
Context
.
root
()
->
odf_context
().
styleContainer
().
master_page_name_by_name
(
styleName
);
if
(
masterPageName
)
...
...
@@ -430,7 +430,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty
=
false
;
}
process_paragraph_drop_cap_attr
(
paragraph_
attrs_
,
Context
);
process_paragraph_drop_cap_attr
(
attrs_
,
Context
);
if
(
Context
.
get_drop_cap_context
().
state
()
==
2
)
//active
{
...
...
@@ -444,11 +444,11 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
}
int
textStyle
=
process_paragraph_attr
(
paragraph_
attrs_
,
Context
);
int
textStyle
=
process_paragraph_attr
(
attrs_
,
Context
);
Context
.
add_note_reference
();
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_
content_
)
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
if
(
Context
.
get_page_break
())
{
...
...
@@ -501,8 +501,8 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
void
paragraph
::
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
{
Context
.
start_paragraph
(
paragraph_
attrs_
.
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_
content_
)
Context
.
start_paragraph
(
attrs_
.
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
elm
->
xlsx_convert
(
Context
);
}
...
...
@@ -510,12 +510,14 @@ void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
}
void
paragraph
::
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
)
{
Context
.
get_text_context
().
start_paragraph
(
paragraph_attrs_
.
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
paragraph_content_
)
Context
.
get_text_context
().
start_paragraph
(
attrs_
.
text_style_name_
.
style_name
());
BOOST_FOREACH
(
const
office_element_ptr
&
elm
,
content_
)
{
elm
->
pptx_convert
(
Context
);
}
Context
.
get_text_context
().
end_paragraph
();
Context
.
get_text_context
().
end_paragraph
();
}
///////////////////////////////////////////
void
soft_page_break
::
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
...
...
@@ -546,7 +548,7 @@ void h::add_attributes( const xml::attributes_wc_ptr & Attributes )
paragraph_
.
add_attributes
(
Attributes
);
paragraph_
.
is_header_
=
true
;
paragraph_
.
paragraph_
attrs_
.
outline_level_
=
text_outline_level_
;
paragraph_
.
attrs_
.
outline_level_
=
text_outline_level_
;
}
void
h
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
)
...
...
@@ -1071,12 +1073,29 @@ void text_unknown_base_change::docx_convert(oox::docx_conversion_context & Conte
if
(
content_
.
empty
())
return
;
//тут удаленный текст. не по стандарту сделать бы и форматы - стилями чтоли ....
Context
.
get_text_tracked_context
().
start_changes_content
();
for
(
int
i
=
0
;
i
<
content_
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
content_
.
size
();
i
++
)
{
Context
.
get_text_tracked_context
().
start_changes_content
();
{
content_
[
i
]
->
docx_convert
(
Context
);
h
*
h_
=
dynamic_cast
<
h
*>
(
content_
[
i
].
get
());
p
*
p_
=
dynamic_cast
<
p
*>
(
content_
[
i
].
get
());
paragraph
*
para
=
NULL
;
if
(
h_
)
para
=
&
h_
->
paragraph_
;
if
(
p_
)
para
=
&
p_
->
paragraph_
;
if
(
para
)
{
for
(
int
j
=
0
;
j
<
para
->
content_
.
size
();
j
++
)
{
para
->
content_
[
j
]
->
docx_convert
(
Context
);
}
}
}
Context
.
get_text_tracked_context
().
end_changes_content
();
Context
.
get_text_tracked_context
().
end_changes_content
();
}
}
//---------------------------------------------------------------------------------------------------
const
wchar_t
*
text_insertion
::
ns
=
L"text"
;
...
...
ASCOfficeOdfFile/src/odf/text_elements.h
View file @
71aabb5f
...
...
@@ -56,12 +56,12 @@ public:
std
::
wostream
&
text_to_stream
(
std
::
wostream
&
_Wostream
)
const
;
void
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
);
void
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
,
document_context
*
Context
);
void
add_text
(
const
std
::
wstring
&
Text
);
void
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
);
void
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
,
document_context
*
Context
);
void
add_text
(
const
std
::
wstring
&
Text
);
paragraph
*
get_next
()
{
return
next_par_
;
}
void
set_next
(
paragraph
*
next
)
{
next_par_
=
next
;}
paragraph
*
get_next
()
{
return
next_par_
;
}
void
set_next
(
paragraph
*
next
)
{
next_par_
=
next
;}
void
set_next_section
(
bool
Val
)
{
...
...
@@ -75,17 +75,17 @@ public:
void
afterCreate
(
document_context
*
ctx
);
void
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
;
void
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
;
void
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
)
;
void
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
;
void
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
;
void
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
)
;
void
drop_cap_docx_convert
(
oox
::
docx_conversion_context
&
Context
);
office_element_ptr_array
content_
;
private:
void
drop_cap_text_docx_convert
(
office_element_ptr
first_text_paragraph
,
oox
::
docx_conversion_context
&
Context
);
paragraph_attrs
paragraph_attrs_
;
office_element_ptr_array
paragraph_content_
;
paragraph_attrs
attrs_
;
paragraph
*
next_par_
;
...
...
@@ -117,6 +117,7 @@ public:
virtual
void
afterCreate
();
virtual
std
::
wostream
&
text_to_stream
(
std
::
wostream
&
_Wostream
)
const
;
paragraph
paragraph_
;
private:
virtual
void
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
);
...
...
@@ -130,8 +131,6 @@ private:
_CP_OPT
(
bool
)
text_is_list_header_
;
_CP_OPT
(
std
::
wstring
)
text_number_
;
paragraph
paragraph_
;
friend
class
par_docx_convert_class
;
};
...
...
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