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
326c8f5d
Commit
326c8f5d
authored
May 20, 2016
by
ElenaSubbotina
Committed by
Alexander Trofimov
May 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatReader - поправлена конвертация формул в Vehicle log book.ods
parent
15cf0894
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
107 deletions
+126
-107
ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp
ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp
+124
-107
ASCOfficeOdfFile/src/docx/oox_types_chart.cpp
ASCOfficeOdfFile/src/docx/oox_types_chart.cpp
+2
-0
No files found.
ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp
View file @
326c8f5d
...
...
@@ -7,95 +7,129 @@
namespace
cpdoccore
{
namespace
formulasconvert
{
class
odf2oox_converter
::
Impl
{
public:
std
::
wstring
convert
(
const
std
::
wstring
&
expr
);
std
::
wstring
convert_chart_distance
(
const
std
::
wstring
&
expr
);
void
replace_cells_range
(
std
::
wstring
&
expr
);
bool
check_formula
(
std
::
wstring
&
expr
);
void
replace_semicolons
(
std
::
wstring
&
expr
);
void
replace_vertical
(
std
::
wstring
&
expr
);
void
replace_space
(
std
::
wstring
&
expr
);
void
replace_named_ref
(
std
::
wstring
&
expr
);
bool
find_first_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref
);
bool
find_first_last_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref_first
,
std
::
wstring
&
ref_last
);
};
bool
odf2oox_converter
::
Impl
::
find_first_last_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref_first
,
std
::
wstring
&
ref_last
)
{
std
::
vector
<
std
::
wstring
>
splitted
;
boost
::
algorithm
::
split
(
splitted
,
expr
,
boost
::
algorithm
::
is_any_of
(
L".:"
),
boost
::
algorithm
::
token_compress_on
);
if
(
splitted
.
size
()
==
3
)
class
odf2oox_converter
::
Impl
{
table
=
splitted
[
0
];
ref_first
=
splitted
[
1
];
ref_last
=
splitted
[
2
];
return
true
;
public:
std
::
wstring
convert
(
const
std
::
wstring
&
expr
);
std
::
wstring
convert_chart_distance
(
const
std
::
wstring
&
expr
);
void
replace_cells_range
(
std
::
wstring
&
expr
);
bool
check_formula
(
std
::
wstring
&
expr
);
void
replace_semicolons
(
std
::
wstring
&
expr
);
void
replace_vertical
(
std
::
wstring
&
expr
);
void
replace_space
(
std
::
wstring
&
expr
);
void
replace_named_ref
(
std
::
wstring
&
expr
);
bool
find_first_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref
);
bool
find_first_last_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref_first
,
std
::
wstring
&
ref_last
);
};
bool
odf2oox_converter
::
Impl
::
find_first_last_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref_first
,
std
::
wstring
&
ref_last
)
{
std
::
vector
<
std
::
wstring
>
splitted
;
boost
::
algorithm
::
split
(
splitted
,
expr
,
boost
::
algorithm
::
is_any_of
(
L".:"
),
boost
::
algorithm
::
token_compress_on
);
if
(
splitted
.
size
()
==
3
)
{
table
=
splitted
[
0
];
ref_first
=
splitted
[
1
];
ref_last
=
splitted
[
2
];
return
true
;
}
if
(
splitted
.
size
()
==
4
)
{
table
=
splitted
[
0
];
ref_first
=
splitted
[
1
];
ref_last
=
splitted
[
3
];
return
true
;
}
return
false
;
}
if
(
splitted
.
size
()
==
4
)
bool
odf2oox_converter
::
Impl
::
find_first_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref
)
{
table
=
splitted
[
0
];
ref_first
=
splitted
[
1
];
ref_last
=
splitted
[
3
];
return
true
;
boost
::
wregex
re
(
L"
\\
[(?:
\\
$)?([^
\\
.]+?){0,1}
\\
.([a-zA-Z
\\
$]+
\\
d+)(?::
\\
.([a-zA-Z]+
\\
d+)){0,1}
\\
]"
);
boost
::
wsmatch
result
;
bool
b
=
boost
::
regex_search
(
expr
,
result
,
re
);
size_t
sz
=
result
.
size
();
if
(
sz
==
4
&&
!
result
[
1
].
matched
)
{
table
=
L""
;
ref
=
result
[
2
].
str
();
return
true
;
}
else
if
(
sz
==
4
&&
result
[
1
].
matched
)
{
table
=
result
[
1
].
str
();
boost
::
algorithm
::
replace_all
(
table
,
L"$"
,
L""
);
boost
::
algorithm
::
replace_all
(
table
,
L"'"
,
L""
);
ref
=
result
[
2
].
str
();
return
true
;
}
return
false
;
}
return
false
;
}
bool
odf2oox_converter
::
Impl
::
find_first_ref
(
std
::
wstring
const
&
expr
,
std
::
wstring
&
table
,
std
::
wstring
&
ref
)
{
boost
::
wregex
re
(
L"
\\
[(?:
\\
$)?([^
\\
.]+?){0,1}
\\
.([a-zA-Z
\\
$]+
\\
d+)(?::
\\
.([a-zA-Z]+
\\
d+)){0,1}
\\
]"
);
boost
::
wsmatch
result
;
bool
b
=
boost
::
regex_search
(
expr
,
result
,
re
);
std
::
wstring
replace_cell_range_formater
(
boost
::
wsmatch
const
&
what
)
{
const
size_t
sz
=
what
.
size
();
if
(
sz
==
4
&&
!
what
[
1
].
matched
)
{
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
else
if
(
sz
==
4
&&
what
[
1
].
matched
)
{
std
::
wstring
sheet1
=
what
[
1
].
str
();
boost
::
algorithm
::
replace_all
(
sheet1
,
L"$"
,
L""
);
const
std
::
wstring
c1
=
what
[
2
].
str
();
std
::
wstring
c2
=
what
[
3
].
str
();
if
(
c2
.
empty
())
c2
=
what
[
4
].
str
();
const
std
::
wstring
s
=
sheet1
+
L"!"
+
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
return
L""
;
}
size_t
sz
=
result
.
size
();
if
(
sz
==
4
&&
!
result
[
1
].
matched
)
{
table
=
L""
;
ref
=
result
[
2
].
str
();
return
true
;
}
else
if
(
sz
==
4
&&
result
[
1
].
matched
)
{
table
=
result
[
1
].
str
();
boost
::
algorithm
::
replace_all
(
table
,
L"$"
,
L""
);
boost
::
algorithm
::
replace_all
(
table
,
L"'"
,
L""
);
ref
=
result
[
2
].
str
();
return
true
;
}
return
false
;
}
std
::
wstring
replace_named_ref_formater
(
boost
::
wsmatch
const
&
what
)
{
const
size_t
sz
=
what
.
size
();
namespace
{
if
(
sz
==
4
&&
!
what
[
1
].
matched
)
{
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
else
if
(
sz
==
4
&&
what
[
1
].
matched
)
{
std
::
wstring
sheet1
=
what
[
1
].
str
();
boost
::
algorithm
::
replace_all
(
sheet1
,
L"$"
,
L""
);
std
::
wstring
replace_cell_range_formater
(
boost
::
wsmatch
const
&
what
)
{
const
size_t
sz
=
what
.
size
();
if
(
sz
==
4
&&
!
what
[
1
].
matched
)
{
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
else
if
(
sz
==
4
&&
what
[
1
].
matched
)
{
std
::
wstring
sheet1
=
what
[
1
].
str
();
boost
::
algorithm
::
replace_all
(
sheet1
,
L"$"
,
L""
);
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
sheet1
+
L"!"
+
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
return
L""
;
}
std
::
wstring
replace_named_ref_formater1
(
boost
::
wsmatch
const
&
what
)
{
boost
::
wregex
complexRef
(
L"
\\
$([^
\\
.]+?){0,1}
\\
.(
\\
$[a-zA-Z]+
\\
$
\\
d+)(?::
\\
.(
\\
$[a-zA-Z]+
\\
$
\\
d+)){0,1}"
);
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
sheet1
+
L"!"
+
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
return
L""
;
}
std
::
wstring
expr
=
what
[
1
].
str
();
const
std
::
wstring
res
=
boost
::
regex_replace
(
expr
,
complexRef
,
&
replace_named_ref_formater
,
boost
::
match_default
|
boost
::
format_all
)
;
expr
=
res
;
}
return
expr
;
}
// çàìåíÿåì ôîðìàò àäðåñàöèè ÿ÷ååê
...
...
@@ -107,7 +141,8 @@ std::wstring replace_cell_range_formater(boost::wsmatch const & what)
void
odf2oox_converter
::
Impl
::
replace_cells_range
(
std
::
wstring
&
expr
)
{
//boost::wregex simpleRef(L"\\[\\.([a-zA-Z]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost
::
wregex
complexRef
(
L"
\\
[(?:
\\
$)?([^
\\
.]+?){0,1}
\\
.([a-zA-Z
\\
$]+
\\
d+)(?::
\\
.([a-zA-Z]+
\\
d+)){0,1}
\\
]"
);
//boost::wregex complexRef(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost
::
wregex
complexRef
(
L"
\\
[(.*?)
\\
]"
);
/*
[ $ Sheet2 . A1 : . B5 ]
...
...
@@ -116,38 +151,13 @@ void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr)
const
std
::
wstring
res
=
boost
::
regex_replace
(
expr
,
complexRef
,
&
replace_
cell_range_formater
,
&
replace_
named_ref_formater1
,
boost
::
match_default
|
boost
::
format_all
);
expr
=
res
;
}
namespace
{
std
::
wstring
replace_named_ref_formater
(
boost
::
wsmatch
const
&
what
)
{
const
size_t
sz
=
what
.
size
();
if
(
sz
==
4
&&
!
what
[
1
].
matched
)
{
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
else
if
(
sz
==
4
&&
what
[
1
].
matched
)
{
std
::
wstring
sheet1
=
what
[
1
].
str
();
boost
::
algorithm
::
replace_all
(
sheet1
,
L"$"
,
L""
);
const
std
::
wstring
c1
=
what
[
2
].
str
();
const
std
::
wstring
c2
=
what
[
3
].
str
();
const
std
::
wstring
s
=
sheet1
+
L"!"
+
c1
+
(
c2
.
empty
()
?
L""
:
(
L":"
+
c2
)
);
return
s
;
}
return
L""
;
}
}
void
odf2oox_converter
::
Impl
::
replace_named_ref
(
std
::
wstring
&
expr
)
{
boost
::
wregex
complexRef
(
L"
\\
$([^
\\
.]+?){0,1}
\\
.(
\\
$[a-zA-Z]+
\\
$
\\
d+)(?::
\\
.(
\\
$[a-zA-Z]+
\\
$
\\
d+)){0,1}"
);
...
...
@@ -289,9 +299,14 @@ std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
{
if
(
is_forbidden
(
expr
))
return
L"NULLFORMULA()"
;
std
::
wstring
workstr
=
expr
;
check_formula
(
workstr
);
boost
::
algorithm
::
replace_all
(
workstr
,
L" "
,
L"PROBEL"
);
boost
::
algorithm
::
replace_all
(
workstr
,
L"'"
,
L"APOSTROF"
);
check_formula
(
workstr
);
replace_cells_range
(
workstr
);
replace_semicolons
(
workstr
);
replace_vertical
(
workstr
);
...
...
@@ -303,6 +318,8 @@ std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
//todooo
}
boost
::
algorithm
::
replace_all
(
workstr
,
L"PROBEL"
,
L" "
);
boost
::
algorithm
::
replace_all
(
workstr
,
L"APOSTROF"
,
L"'"
);
return
workstr
;
}
...
...
ASCOfficeOdfFile/src/docx/oox_types_chart.cpp
View file @
326c8f5d
...
...
@@ -285,6 +285,8 @@ void oox_doughnut_chart::set_properties(std::vector<odf_reader::_property> g)
}
void
oox_doughnut_chart
::
oox_serialize
(
std
::
wostream
&
_Wostream
)
{
grouping_
.
clear
();
CP_XML_WRITER
(
_Wostream
)
{
CP_XML_NODE
(
L"c:doughnutChart"
)
...
...
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