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
d6907bd9
Commit
d6907bd9
authored
May 25, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatReader- Список.ods, Book 50.ods - именованые формулы, поправлен crop image файлов
parent
6370c8c2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
91 additions
and
78 deletions
+91
-78
ASCOfficeOdfFile/formulasconvert/formulasconvert.h
ASCOfficeOdfFile/formulasconvert/formulasconvert.h
+3
-0
ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp
ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp
+21
-0
ASCOfficeOdfFile/src/docx/pptx_slide_context.cpp
ASCOfficeOdfFile/src/docx/pptx_slide_context.cpp
+1
-1
ASCOfficeOdfFile/src/docx/xlsx_defined_names.cpp
ASCOfficeOdfFile/src/docx/xlsx_defined_names.cpp
+14
-5
ASCOfficeOdfFile/src/docx/xlsx_defined_names.h
ASCOfficeOdfFile/src/docx/xlsx_defined_names.h
+1
-1
ASCOfficeOdfFile/src/docx/xlsx_drawing.cpp
ASCOfficeOdfFile/src/docx/xlsx_drawing.cpp
+1
-1
ASCOfficeOdfFile/src/docx/xlsx_drawing_context.cpp
ASCOfficeOdfFile/src/docx/xlsx_drawing_context.cpp
+1
-1
ASCOfficeOdfFile/src/odf/draw_common.cpp
ASCOfficeOdfFile/src/odf/draw_common.cpp
+33
-39
ASCOfficeOdfFile/src/odf/draw_common.h
ASCOfficeOdfFile/src/odf/draw_common.h
+4
-2
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
+1
-1
ASCOfficeOdfFile/src/odf/table_named_expressions.cpp
ASCOfficeOdfFile/src/odf/table_named_expressions.cpp
+7
-13
ASCOfficeOdfFile/src/odf/table_named_expressions.h
ASCOfficeOdfFile/src/odf/table_named_expressions.h
+4
-14
No files found.
ASCOfficeOdfFile/formulasconvert/formulasconvert.h
View file @
d6907bd9
...
...
@@ -21,6 +21,9 @@ public:
// $1.$A$1 -> 1!$A$1
std
::
wstring
convert_named_ref
(
std
::
wstring
const
&
expr
);
//a-la convert without check formula
std
::
wstring
convert_named_expr
(
std
::
wstring
const
&
expr
);
//Sheet2.C3:Sheet2.C19 -> Sheet2!C3:C19
std
::
wstring
convert_chart_distance
(
std
::
wstring
const
&
expr
);
...
...
ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp
View file @
d6907bd9
...
...
@@ -429,7 +429,28 @@ std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr)
impl_
->
replace_named_ref
(
workstr
);
return
workstr
;
}
std
::
wstring
odf2oox_converter
::
convert_named_expr
(
const
std
::
wstring
&
expr
)
{
std
::
wstring
workstr
=
expr
;
boost
::
algorithm
::
replace_all
(
workstr
,
L" "
,
L"PROBEL"
);
boost
::
algorithm
::
replace_all
(
workstr
,
L"'"
,
L"APOSTROF"
);
impl_
->
replace_cells_range
(
workstr
);
impl_
->
replace_semicolons
(
workstr
);
impl_
->
replace_vertical
(
workstr
);
int
res_find
=
0
;
if
((
res_find
=
workstr
.
find
(
L"CONCATINATE"
))
>
0
)
{
//ìîãóò áûòü ÷àñòè÷íî çàäàíû äèàïàçîíû
//todooo
}
boost
::
algorithm
::
replace_all
(
workstr
,
L"PROBEL"
,
L" "
);
boost
::
algorithm
::
replace_all
(
workstr
,
L"APOSTROF"
,
L"'"
);
return
workstr
;
}
std
::
wstring
odf2oox_converter
::
convert_ref
(
std
::
wstring
const
&
expr
)
{
...
...
ASCOfficeOdfFile/src/docx/pptx_slide_context.cpp
View file @
d6907bd9
...
...
@@ -406,7 +406,7 @@ void pptx_slide_context::process_images()
std
::
wstring
fileName
=
impl_
->
odfPacket_
+
FILE_SEPARATOR_STR
+
pic
.
xlink_href_
;
drawing
.
fill
.
bitmap
->
bCrop
=
odf_reader
::
parse_clipping
(
pic
.
clipping_string_
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
);
drawing
.
fill
.
bitmap
->
bCrop
=
odf_reader
::
parse_clipping
(
pic
.
clipping_string_
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
,
NULL
);
drawing
.
fill
.
bitmap
->
bStretch
=
true
;
///////////////////////////////////////////////////////////////////////////////////////////////////
...
...
ASCOfficeOdfFile/src/docx/xlsx_defined_names.cpp
View file @
d6907bd9
...
...
@@ -15,7 +15,7 @@ namespace oox {
class
xlsx_defined_names
::
Impl
{
public:
void
add
(
std
::
wstring
const
&
name
,
std
::
wstring
const
&
ref
)
void
add
(
std
::
wstring
const
&
name
,
std
::
wstring
const
&
ref
,
bool
formula
)
{
int
is_file_link
=
0
;
...
...
@@ -23,8 +23,17 @@ public:
if
((
is_file_link
=
ref
.
find
(
L"/"
))
>=
0
)
return
;
formulasconvert
::
odf2oox_converter
converter
;
std
::
wstring
const
f
=
converter
.
convert_named_ref
(
ref
);
name_and_ref_
.
push_back
(
name_and_ref
(
name
,
f
));
std
::
wstring
res
;
if
(
formula
)
{
res
=
converter
.
convert_named_expr
(
ref
);
}
else
{
res
=
converter
.
convert_named_ref
(
ref
);
}
name_and_ref_
.
push_back
(
name_and_ref
(
name
,
res
));
}
void
xlsx_serialize
(
std
::
wostream
&
_Wostream
)
...
...
@@ -61,9 +70,9 @@ xlsx_defined_names::~xlsx_defined_names()
{
}
void
xlsx_defined_names
::
add
(
std
::
wstring
const
&
name
,
std
::
wstring
const
&
ref
)
void
xlsx_defined_names
::
add
(
std
::
wstring
const
&
name
,
std
::
wstring
const
&
ref
,
bool
formula
)
{
return
impl_
->
add
(
name
,
ref
);
return
impl_
->
add
(
name
,
ref
,
formula
);
}
void
xlsx_defined_names
::
xlsx_serialize
(
std
::
wostream
&
_Wostream
)
...
...
ASCOfficeOdfFile/src/docx/xlsx_defined_names.h
View file @
d6907bd9
...
...
@@ -16,7 +16,7 @@ namespace oox {
~
xlsx_defined_names
();
public:
void
add
(
std
::
wstring
const
&
name
,
std
::
wstring
const
&
ref
);
void
add
(
std
::
wstring
const
&
name
,
std
::
wstring
const
&
ref
,
bool
formula
=
false
);
void
xlsx_serialize
(
std
::
wostream
&
_Wostream
);
private:
...
...
ASCOfficeOdfFile/src/docx/xlsx_drawing.cpp
View file @
d6907bd9
...
...
@@ -247,7 +247,7 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_NODE
(
L"xdr:twoCellAnchor"
)
{
//CP_XML_ATTR(L"editAs", L"absolute
");//"absolute");oneCell
CP_XML_ATTR
(
L"editAs"
,
L"oneCell
"
);
//"absolute");oneCell
xlsx_serialize
(
CP_XML_STREAM
(),
val
.
from_
);
xlsx_serialize
(
CP_XML_STREAM
(),
val
.
to_
);
...
...
ASCOfficeOdfFile/src/docx/xlsx_drawing_context.cpp
View file @
d6907bd9
...
...
@@ -467,7 +467,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj,_xlsx_
}
std
::
wstring
fileName
=
odf_packet_path_
+
FILE_SEPARATOR_STR
+
obj
.
xlink_href_
;
drawing
.
fill
.
bitmap
->
bCrop
=
odf_reader
::
parse_clipping
(
obj
.
clipping_string_
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
);
drawing
.
fill
.
bitmap
->
bCrop
=
odf_reader
::
parse_clipping
(
obj
.
clipping_string_
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
,
NULL
/*applicationFonts_*/
);
drawing
.
fill
.
bitmap
->
bStretch
=
true
;
std
::
wstring
ref
;
///
...
...
ASCOfficeOdfFile/src/odf/draw_common.cpp
View file @
d6907bd9
...
...
@@ -21,49 +21,35 @@
/////////////////////////////////////////////////////////////////////////////////
#include "../../../DesktopEditor/raster/BgraFrame.h"
#if defined(_WIN32) || defined(_WIN64)
#include <Windows.h>
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
#endif
#include "../../../DesktopEditor/raster/MetaFile/MetaFile.h"
extern
double
getSystemDPI
();
namespace
_image_file_
{
bool
GetResolution
(
const
wchar_t
*
fileName
,
int
&
Width
,
int
&
Height
)
bool
GetResolution
(
const
wchar_t
*
fileName
,
int
&
Width
,
int
&
Height
,
CApplicationFonts
*
appFonts
)
{
bool
result
=
false
;
CBgraFrame
image
;
if
(
result
=
image
.
OpenFile
(
fileName
,
0
))
MetaFile
::
CMetaFile
meta_file
(
appFonts
);
if
(
meta_file
.
LoadFromFile
(
fileName
))
{
double
dX
=
0
,
dY
=
0
,
dW
=
0
,
dH
=
0
;
meta_file
.
GetBounds
(
&
dX
,
&
dY
,
&
dW
,
&
dH
);
Width
=
dW
;
Height
=
dH
;
}
else
if
(
image
.
OpenFile
(
fileName
,
0
))
{
Width
=
image
.
get_Width
();
Height
=
image
.
get_Height
();
re
sult
=
true
;
re
turn
true
;
}
else
{
#if defined(_WIN32) || defined(_WIN64)
Gdiplus
::
GdiplusStartupInput
gdiplusStartupInput
;
ULONG_PTR
gdiplusToken
=
0
;
Gdiplus
::
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
);
Gdiplus
::
Bitmap
*
file
=
new
Gdiplus
::
Bitmap
(
fileName
,
false
);
if
((
file
)
&&
(
file
->
GetLastStatus
()
==
Gdiplus
::
Ok
))
{
Height
=
file
->
GetHeight
();
Width
=
file
->
GetWidth
();
result
=
true
;
delete
file
;
}
Gdiplus
::
GdiplusShutdown
(
gdiplusToken
);
#endif
}
return
result
;
return
false
;
}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -83,28 +69,36 @@ int get_value_emu(double pt)
{
return
static_cast
<
int
>
((
pt
*
360000
*
2.54
)
/
72
);
}
bool
parse_clipping
(
std
::
wstring
strClipping
,
std
::
wstring
fileName
,
double_4
&
clip_rect
)
bool
parse_clipping
(
std
::
wstring
strClipping
,
std
::
wstring
fileName
,
double_4
&
clip_rect
,
CApplicationFonts
*
appFonts
)
{
memset
(
clip_rect
,
0
,
4
*
sizeof
(
double
));
if
(
strClipping
.
length
()
<
1
||
fileName
.
length
()
<
1
)
return
false
;
int
fileWidth
=
0
,
fileHeight
=
0
;
if
(
!
_image_file_
::
GetResolution
(
fileName
.
data
(),
fileWidth
,
fileHeight
)
||
fileWidth
<
1
||
fileHeight
<
1
)
return
false
;
//<top>, <right>, <bottom>, <left> - http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html#clip
bool
bEnableCrop
=
false
;
std
::
vector
<
std
::
wstring
>
Points
;
std
::
vector
<
length
>
Points_pt
;
std
::
vector
<
std
::
wstring
>
Points
;
std
::
vector
<
length
>
Points_pt
;
boost
::
algorithm
::
split
(
Points
,
strClipping
,
boost
::
algorithm
::
is_any_of
(
L" ,"
),
boost
::
algorithm
::
token_compress_on
);
//<top>, <right>, <bottom>, <left> - http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html#clip
BOOST_FOREACH
(
std
::
wstring
const
&
p
,
Points
)
{
Points_pt
.
push_back
(
length
::
parse
(
p
)
);
if
(
Points_pt
.
back
().
get_value
()
>
0.00001
)
bEnableCrop
=
true
;
}
if
(
Points_pt
.
size
()
>
3
)
// ..
if
(
!
bEnableCrop
)
return
false
;
int
fileWidth
=
0
,
fileHeight
=
0
;
if
(
!
_image_file_
::
GetResolution
(
fileName
.
data
(),
fileWidth
,
fileHeight
,
appFonts
)
||
fileWidth
<
1
||
fileHeight
<
1
)
return
false
;
if
(
Points_pt
.
size
()
>
3
)
// ..
{
float
dpi_
=
96.
;
///getSystemDPI();
clip_rect
[
0
]
=
dpi_
*
Points_pt
[
3
].
get_value_unit
(
length
::
inch
);
...
...
ASCOfficeOdfFile/src/odf/draw_common.h
View file @
d6907bd9
...
...
@@ -19,9 +19,11 @@
#include "datatypes/targetframename.h"
#include "datatypes/common_attlists.h"
//class CApplicationFonts;
namespace
_image_file_
{
bool
GetResolution
(
const
wchar_t
*
fileName
,
int
&
Width
,
int
&
Height
);
bool
GetResolution
(
const
wchar_t
*
fileName
,
int
&
Width
,
int
&
Height
,
CApplicationFonts
*
appFonts
);
}
namespace
cpdoccore
{
...
...
@@ -43,7 +45,7 @@ void Compute_GraphicFill(const odf_types::common_draw_fill_attlist & props,
const
office_element_ptr
&
style_image
,
styles_lite_container
&
styles
,
oox
::
_oox_fill
&
fill
);
typedef
double
double_4
[
4
];
bool
parse_clipping
(
std
::
wstring
strClipping
,
std
::
wstring
fileName
,
double_4
&
clip_rect
);
bool
parse_clipping
(
std
::
wstring
strClipping
,
std
::
wstring
fileName
,
double_4
&
clip_rect
,
CApplicationFonts
*
appFonts
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class
draw_a
:
public
office_element_impl
<
draw_a
>
{
...
...
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
View file @
d6907bd9
...
...
@@ -1091,7 +1091,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
std
::
wstring
fileName
=
Context
.
root
()
->
get_folder
()
+
FILE_SEPARATOR_STR
+
href
;
drawing
.
fill
.
bitmap
->
bCrop
=
parse_clipping
(
strRectClip
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
);
drawing
.
fill
.
bitmap
->
bCrop
=
parse_clipping
(
strRectClip
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
,
NULL
/*Context.applicationFonts_*/
);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
ASCOfficeOdfFile/src/odf/table_named_expressions.cpp
View file @
d6907bd9
...
...
@@ -30,18 +30,7 @@ void table_named_expressions::add_child_element(xml::sax * Reader,
const
::
std
::
wstring
&
Ns
,
const
::
std
::
wstring
&
Name
)
{
if
CP_CHECK_NAME
(
L"table"
,
L"named-range"
)
{
CP_CREATE_ELEMENT
(
named_range_
);
}
else
if
CP_CHECK_NAME
(
L"table"
,
L"named-expression"
)
{
CP_CREATE_ELEMENT
(
named_expression_
);
}
else
{
CP_NOT_APPLICABLE_ELM
();
}
CP_CREATE_ELEMENT
(
content_
);
}
void
table_named_expressions
::
docx_convert
(
oox
::
docx_conversion_context
&
Context
)
...
...
@@ -50,7 +39,7 @@ void table_named_expressions::docx_convert(oox::docx_conversion_context & Contex
void
table_named_expressions
::
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
{
BOOST_FOREACH
(
office_element_ptr
const
&
elm
,
named_range
_
)
BOOST_FOREACH
(
office_element_ptr
const
&
elm
,
content
_
)
{
elm
->
xlsx_convert
(
Context
);
}
...
...
@@ -99,6 +88,11 @@ void table_named_expression::docx_convert(oox::docx_conversion_context & Context
void
table_named_expression
::
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
)
{
if
(
table_expression_
&&
table_name_
)
{
oox
::
xlsx_defined_names
&
ctx
=
Context
.
get_xlsx_defined_names
();
ctx
.
add
(
table_name_
.
get
(),
table_expression_
.
get
(),
true
);
}
}
void
table_named_expression
::
add_attributes
(
xml
::
attributes_wc_ptr
const
&
Attributes
)
...
...
ASCOfficeOdfFile/src/odf/table_named_expressions.h
View file @
d6907bd9
...
...
@@ -13,9 +13,7 @@
namespace
cpdoccore
{
namespace
odf_reader
{
/// \class table_named_expressions
/// \brief table:named-expressions
/// table-named-expressions
// table:named-expressions
class
table_named_expressions
:
public
office_element_impl
<
table_named_expressions
>
{
public:
...
...
@@ -34,16 +32,13 @@ private:
virtual
void
add_child_element
(
xml
::
sax
*
Reader
,
const
::
std
::
wstring
&
Ns
,
const
::
std
::
wstring
&
Name
);
private:
office_element_ptr_array
named_range_
;
office_element_ptr_array
named_expression_
;
office_element_ptr_array
content_
;
};
CP_REGISTER_OFFICE_ELEMENT2
(
table_named_expressions
);
/// \class table_named_range
/// \brief table:named-range
/// table-named-range
// table:named-range
class
table_named_range
:
public
office_element_impl
<
table_named_range
>
{
public:
...
...
@@ -71,9 +66,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2
(
table_named_range
);
/// \class table_named_expression
/// \brief table:named-expression
/// table-named-expression
// table:named-expression
class
table_named_expression
:
public
office_element_impl
<
table_named_expression
>
{
public:
...
...
@@ -97,11 +90,8 @@ private:
_CP_OPT
(
std
::
wstring
)
table_base_cell_address_
;
};
CP_REGISTER_OFFICE_ELEMENT2
(
table_named_expression
);
}
}
...
...
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