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
1fc824db
Commit
1fc824db
authored
Aug 28, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatReader - fix custom oox shape
parent
c18d5a82
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
306 additions
and
245 deletions
+306
-245
ASCOfficeOdfFile/include/cpdoccore/xml/attributes.h
ASCOfficeOdfFile/include/cpdoccore/xml/attributes.h
+8
-8
ASCOfficeOdfFile/src/docx/docx_drawing.cpp
ASCOfficeOdfFile/src/docx/docx_drawing.cpp
+4
-4
ASCOfficeOdfFile/src/docx/oox_drawing.cpp
ASCOfficeOdfFile/src/docx/oox_drawing.cpp
+21
-12
ASCOfficeOdfFile/src/odf/draw_common.cpp
ASCOfficeOdfFile/src/odf/draw_common.cpp
+13
-12
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
+181
-166
ASCOfficeOdfFile/src/odf/draw_shapes.cpp
ASCOfficeOdfFile/src/odf/draw_shapes.cpp
+31
-18
ASCOfficeOdfFile/src/odf/draw_shapes.h
ASCOfficeOdfFile/src/odf/draw_shapes.h
+6
-4
ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp
ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp
+33
-6
ASCOfficeOdfFile/src/odf/svg_parser.cpp
ASCOfficeOdfFile/src/odf/svg_parser.cpp
+9
-15
No files found.
ASCOfficeOdfFile/include/cpdoccore/xml/attributes.h
View file @
1fc824db
...
...
@@ -51,28 +51,28 @@ namespace cpdoccore
{
struct
_property
{
_property
(
std
::
wstring
n
,
std
::
wstring
s
)
{
name_
=
n
;
val_
=
s
;}
_property
(
std
::
wstring
n
,
bool
b
)
{
name_
=
n
;
val_
=
b
;}
_property
(
std
::
wstring
n
,
int
i
)
{
name_
=
n
;
val_
=
i
;}
_property
(
std
::
wstring
n
,
double
d
){
name_
=
n
;
val_
=
d
;}
_property
(
std
::
wstring
n
,
std
::
wstring
s
)
{
name_
=
n
;
val_
=
s
;}
_property
(
std
::
wstring
n
,
bool
b
)
{
name_
=
n
;
val_
=
b
;}
_property
(
std
::
wstring
n
,
int
i
)
{
name_
=
n
;
val_
=
i
;}
_property
(
std
::
wstring
n
,
double
d
)
{
name_
=
n
;
val_
=
d
;}
std
::
wstring
name_
;
boost
::
variant
<
bool
,
std
::
wstring
,
double
,
int
>
val_
;
};
template
<
class
T
>
bool
GetProperty
(
std
::
vector
<
_property
>
Heap
,
const
std
::
wstring
Name
,
T
&
Val
)
bool
GetProperty
(
const
std
::
vector
<
_property
>
&
Heap
,
const
std
::
wstring
Name
,
T
&
Val
)
{
typedef
typename
T
::
value_type
T_value_type
;
Val
.
reset
();
BOOST_FOREACH
(
_property
const
&
p
,
Heap
)
for
(
int
i
=
0
;
i
<
Heap
.
size
();
i
++
)
{
if
(
p
.
name_
==
Name
)
if
(
Heap
[
i
]
.
name_
==
Name
)
{
try
{
Val
=
boost
::
get
<
T_value_type
>
(
p
.
val_
);
Val
=
boost
::
get
<
T_value_type
>
(
Heap
[
i
]
.
val_
);
}
catch
(...)
{
...
...
ASCOfficeOdfFile/src/docx/docx_drawing.cpp
View file @
1fc824db
...
...
@@ -439,20 +439,20 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE
(
L"wp:positionH"
)
{
std
::
wstring
relativeFrom
=
L"margin"
;
if
(
val
.
styleHorizontalRel
)
relativeFrom
=
val
.
styleHorizontalRel
->
get_type_str
();
if
(
val
.
styleHorizontalRel
)
relativeFrom
=
val
.
styleHorizontalRel
->
get_type_str
();
CP_XML_ATTR
(
L"relativeFrom"
,
relativeFrom
);
CP_XML_ATTR
(
L"relativeFrom"
,
relativeFrom
);
if
(
val
.
styleHorizontalPos
&&
val
.
styleHorizontalPos
->
get_type
()
!=
odf_types
::
horizontal_pos
::
FromLeft
&&
val
.
styleHorizontalPos
->
get_type
()
!=
odf_types
::
horizontal_pos
::
Outside
)
{
CP_XML_NODE
(
L"wp:align"
){
CP_XML_STREAM
()
<<
boost
::
lexical_cast
<
std
::
wstring
>
(
*
val
.
styleHorizontalPos
);}
CP_XML_NODE
(
L"wp:align"
)
{
CP_XML_STREAM
()
<<
boost
::
lexical_cast
<
std
::
wstring
>
(
*
val
.
styleHorizontalPos
);}
}
else
{
CP_XML_NODE
(
L"wp:posOffset"
){
CP_XML_STREAM
()
<<
val
.
posOffsetH
;}
CP_XML_NODE
(
L"wp:posOffset"
)
{
CP_XML_STREAM
()
<<
val
.
posOffsetH
;}
}
}
...
...
ASCOfficeOdfFile/src/docx/oox_drawing.cpp
View file @
1fc824db
...
...
@@ -320,7 +320,7 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
void
oox_serialize_shape
(
std
::
wostream
&
strm
,
_oox_drawing
&
val
)
{
_CP_OPT
(
std
::
wstring
)
strVal
;
_CP_OPT
(
std
::
wstring
)
strVal
;
_CP_OPT
(
double
)
dVal
;
std
::
wstring
shapeType
;
...
...
@@ -332,7 +332,11 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
{
_CP_OPT
(
int
)
iVal
;
odf_reader
::
GetProperty
(
val
.
additional
,
L"odf-custom-draw-index"
,
iVal
);
if
(
iVal
)
shapeType
=
_OO_OOX_custom_shapes
[
*
iVal
].
oox
;
if
(
iVal
)
shapeType
=
_OO_OOX_custom_shapes
[
*
iVal
].
oox
;
else
val
.
sub_type
=
6
;
//path
if
(
shapeType
==
L"textBox"
)
{
...
...
@@ -340,16 +344,11 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
shapeType
=
L"rect"
;
}
}
else
if
(
val
.
sub_type
<
9
&&
val
.
sub_type
>=
0
)
else
if
(
val
.
sub_type
<
9
&&
val
.
sub_type
>=
0
)
{
shapeType
=
_ooxShapeType
[
val
.
sub_type
];
}
if
(
shapeType
.
length
()
<
1
)
{
shapeType
=
L"rect"
;
val
.
sub_type
=
2
;
}
if
(
bWordArt
)
val
.
sub_type
=
1
;
CP_XML_WRITER
(
strm
)
...
...
@@ -358,7 +357,8 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
{
CP_XML_NODE
(
L"a:custGeom"
)
{
oox_serialize_aLst
(
CP_XML_STREAM
(),
val
.
additional
);
oox_serialize_aLst
(
CP_XML_STREAM
(),
val
.
additional
);
CP_XML_NODE
(
L"a:ahLst"
);
CP_XML_NODE
(
L"a:gdLst"
);
CP_XML_NODE
(
L"a:rect"
)
...
...
@@ -369,14 +369,18 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
CP_XML_ATTR
(
L"t"
,
0
);
}
//<a:rect b="b" l="0" r="r" t="0"/>
if
(
odf_reader
::
GetProperty
(
val
.
additional
,
L"custom_path"
,
strVal
))
if
(
odf_reader
::
GetProperty
(
val
.
additional
,
L"custom_path"
,
strVal
))
{
_CP_OPT
(
int
)
w
,
h
;
odf_reader
::
GetProperty
(
val
.
additional
,
L"custom_path_w"
,
w
);
odf_reader
::
GetProperty
(
val
.
additional
,
L"custom_path_h"
,
h
);
CP_XML_NODE
(
L"a:pathLst"
)
{
CP_XML_NODE
(
L"a:path"
)
{
CP_XML_ATTR
(
L"w"
,
val
.
cx
);
CP_XML_ATTR
(
L"h"
,
val
.
cy
);
CP_XML_ATTR
(
L"w"
,
w
?
*
w
:
val
.
cx
);
CP_XML_ATTR
(
L"h"
,
h
?
*
h
:
val
.
cy
);
CP_XML_STREAM
()
<<
strVal
.
get
();
}
}
...
...
@@ -385,6 +389,11 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
}
else
{
if
(
shapeType
.
length
()
<
1
)
{
shapeType
=
L"rect"
;
val
.
sub_type
=
2
;
}
CP_XML_NODE
(
L"a:prstGeom"
)
//автофигура
{
CP_XML_ATTR
(
L"prst"
,
shapeType
);
...
...
ASCOfficeOdfFile/src/odf/draw_common.cpp
View file @
1fc824db
...
...
@@ -519,10 +519,10 @@ void draw_a::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_xlink_attlist_
.
add_attributes
(
Attributes
);
CP_APPLY_ATTR
(
L"office:name"
,
office_name_
,
std
::
wstring
(
L""
));
CP_APPLY_ATTR
(
L"office:target-frame-name"
,
office_target_frame_name_
);
CP_APPLY_ATTR
(
L"text:style-name"
,
text_style_name_
,
style_ref
(
L""
));
CP_APPLY_ATTR
(
L"text:visited-style-name"
,
text_visited_style_name_
,
style_ref
(
L""
));
CP_APPLY_ATTR
(
L"office:name"
,
office_name_
,
std
::
wstring
(
L""
));
CP_APPLY_ATTR
(
L"office:target-frame-name"
,
office_target_frame_name_
);
CP_APPLY_ATTR
(
L"text:style-name"
,
text_style_name_
,
style_ref
(
L""
));
CP_APPLY_ATTR
(
L"text:visited-style-name"
,
text_visited_style_name_
,
style_ref
(
L""
));
}
...
...
@@ -582,10 +582,10 @@ void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_p
boost
::
algorithm
::
split
(
transform
,
t
,
boost
::
algorithm
::
is_any_of
(
L"("
),
boost
::
algorithm
::
token_compress_on
);
if
(
transform
.
size
()
>
1
)
//тока с аргументами
if
(
transform
.
size
()
>
1
)
//тока с аргументами
{
int
res
=
0
;
if
((
res
=
transform
[
0
].
find
(
L"translate"
))
>=
0
)
//перемещение
if
((
res
=
transform
[
0
].
find
(
L"translate"
))
>=
0
)
//перемещение
{
std
::
vector
<
length
>
Points
;
parse_string_to_points
(
transform
[
1
],
Points
);
...
...
@@ -594,11 +594,12 @@ void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_p
{
double
x_pt
=
Points
[
0
].
get_value_unit
(
length
::
pt
);
double
y_pt
=
0
;
if
(
Points
.
size
()
>
1
)
y_pt
=
Points
[
1
].
get_value_unit
(
length
::
pt
);
//ее может не быть
if
(
Points
.
size
()
>
1
)
y_pt
=
Points
[
1
].
get_value_unit
(
length
::
pt
);
//ее может не быть
//Context.get_drawing_context().set_translate(x_pt,y_pt);
additional
.
push_back
(
_property
(
L"svg:translate_x"
,
x_pt
));
additional
.
push_back
(
_property
(
L"svg:translate_y"
,
y_pt
));
additional
.
push_back
(
_property
(
L"svg:translate_x"
,
x_pt
));
additional
.
push_back
(
_property
(
L"svg:translate_y"
,
y_pt
));
}
}
else
if
((
res
=
transform
[
0
].
find
(
L"scale"
))
>=
0
)
//масштабирование
...
...
@@ -612,14 +613,14 @@ void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_p
if
(
Points
.
size
()
>
1
)
y_pt
=
Points
[
1
].
get_value_unit
(
length
::
pt
);
//ее может не быть
//Context.get_drawing_context().set_scale(x_pt,y_pt);
additional
.
push_back
(
_property
(
L"svg:scale_x"
,
x_pt
));
additional
.
push_back
(
_property
(
L"svg:scale_y"
,
y_pt
));
additional
.
push_back
(
_property
(
L"svg:scale_x"
,
x_pt
));
additional
.
push_back
(
_property
(
L"svg:scale_y"
,
y_pt
));
}
}
else
if
((
res
=
transform
[
0
].
find
(
L"rotate"
))
>=
0
)
//вращение
{
double
angle
=
boost
::
lexical_cast
<
double
>
(
transform
[
1
]);
additional
.
push_back
(
_property
(
L"svg:rotate"
,
angle
));
additional
.
push_back
(
_property
(
L"svg:rotate"
,
angle
));
}
}
}
...
...
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
View file @
1fc824db
...
...
@@ -99,14 +99,14 @@ _CP_OPT(length) GetOnlyLength(const _CP_OPT(length_or_percent) & Value)
length
ComputeContextWidth
(
const
style_page_layout_properties
*
pagePropertiesNode
,
const
style_page_layout_properties_attlist
&
pageProperties
,
const
union_common_draw_attlists
&
attlists_
,
const
_CP_OPT
(
horizontal_rel
)
&
horizontalRel
,
const
_CP_OPT
(
horizontal_pos
)
&
horizontalPos
,
const
_CP_OPT
(
length
)
&
pageWidth
,
const
_CP_OPT
(
length
)
&
pageMarginLeft
,
const
_CP_OPT
(
length
)
&
pageMarginRight
length
ComputeContextWidth
(
const
style_page_layout_properties
*
pagePropertiesNode
,
const
style_page_layout_properties_attlist
&
pageProperties
,
const
union_common_draw_attlists
&
attlists_
,
const
_CP_OPT
(
horizontal_rel
)
&
horizontalRel
,
const
_CP_OPT
(
horizontal_pos
)
&
horizontalPos
,
const
_CP_OPT
(
length
)
&
pageWidth
,
const
_CP_OPT
(
length
)
&
pageMarginLeft
,
const
_CP_OPT
(
length
)
&
pageMarginRight
)
{
if
(
!
horizontalRel
)
...
...
@@ -172,30 +172,34 @@ length ComputeContextWidth(const style_page_layout_properties * pagePropertiesNo
return
length
(
0
,
length
::
pt
);
}
int
ComputeMarginX
(
const
style_page_layout_properties
*
pagePropertiesNode
,
const
style_page_layout_properties_attlist
&
pageProperties
,
const
union_common_draw_attlists
&
attlists_
,
const
graphic_format_properties
&
graphicProperties
)
int
ComputeMarginX
(
const
style_page_layout_properties
*
pagePropertiesNode
,
const
style_page_layout_properties_attlist
&
pageProperties
,
const
union_common_draw_attlists
&
attlists_
,
const
graphic_format_properties
&
graphicProperties
,
const
std
::
vector
<
odf_reader
::
_property
>
&
additional
)
{
const
_CP_OPT
(
anchor_type
)
anchor
=
attlists_
.
shape_with_text_and_styles_
.
common_draw_shape_with_styles_attlist_
.
common_text_spreadsheet_shape_attlist_
.
common_text_anchor_attlist_
.
type_
;
const
_CP_OPT
(
anchor_type
)
anchor
=
attlists_
.
shape_with_text_and_styles_
.
common_draw_shape_with_styles_attlist_
.
common_text_spreadsheet_shape_attlist_
.
common_text_anchor_attlist_
.
type_
;
_CP_OPT
(
horizontal_rel
)
styleHorizontalRel
=
graphicProperties
.
common_horizontal_rel_attlist_
.
style_horizontal_rel_
;
_CP_OPT
(
horizontal_pos
)
styleHorizontalPos
=
graphicProperties
.
common_horizontal_pos_attlist_
.
style_horizontal_pos_
;
const
_CP_OPT
(
length
)
pageWidth
=
pageProperties
.
fo_page_width_
;
const
_CP_OPT
(
length
)
pageMarginLeft
=
CalcResultLength
(
pageProperties
.
common_horizontal_margin_attlist_
.
fo_margin_left_
,
pageWidth
);
const
_CP_OPT
(
length
)
pageMarginRight
=
CalcResultLength
(
pageProperties
.
common_horizontal_margin_attlist_
.
fo_margin_right_
,
pageWidth
);
_CP_OPT
(
double
)
dVal
;
if
(
GetProperty
(
additional
,
L"svg:translate_x"
,
dVal
));
const
_CP_OPT
(
length
)
translation
=
length
(
dVal
?
*
dVal
:
0
,
length
::
pt
);
const
_CP_OPT
(
length
)
pageWidth
=
pageProperties
.
fo_page_width_
;
const
_CP_OPT
(
length
)
pageMarginLeft
=
CalcResultLength
(
pageProperties
.
common_horizontal_margin_attlist_
.
fo_margin_left_
,
pageWidth
);
const
_CP_OPT
(
length
)
pageMarginRight
=
CalcResultLength
(
pageProperties
.
common_horizontal_margin_attlist_
.
fo_margin_right_
,
pageWidth
);
length
contextWidth
=
ComputeContextWidth
(
pagePropertiesNode
,
pageProperties
,
attlists_
,
styleHorizontalRel
,
styleHorizontalPos
,
pageWidth
,
pageMarginLeft
,
pageMarginRight
);
styleHorizontalRel
,
styleHorizontalPos
,
pageWidth
,
pageMarginLeft
,
pageMarginRight
);
_CP_OPT
(
length
)
contextSubstractedValue
(
0
,
length
::
pt
);
_CP_OPT
(
length
)
contextSubstractedValue
(
0
,
length
::
pt
);
_CP_OPT
(
style_wrap
)
styleWrap
=
graphicProperties
.
style_wrap_
;
if
(
!
styleWrap
||
...
...
@@ -205,14 +209,14 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
// TODO contextSubstractedValue
}
const
_CP_OPT
(
length
)
frameMarginLeft
=
GetOnlyLength
(
graphicProperties
.
common_horizontal_margin_attlist_
.
fo_margin_left_
);
const
_CP_OPT
(
length
)
frameMarginRight
=
GetOnlyLength
(
graphicProperties
.
common_horizontal_margin_attlist_
.
fo_margin_right_
);
const
_CP_OPT
(
length
)
frameMarginLeft
=
GetOnlyLength
(
graphicProperties
.
common_horizontal_margin_attlist_
.
fo_margin_left_
);
const
_CP_OPT
(
length
)
frameMarginRight
=
GetOnlyLength
(
graphicProperties
.
common_horizontal_margin_attlist_
.
fo_margin_right_
);
const
_CP_OPT
(
length
)
frameWidth
=
attlists_
.
rel_size_
.
common_draw_size_attlist_
.
svg_width_
;
const
_CP_OPT
(
length
)
frameHeight
=
attlists_
.
rel_size_
.
common_draw_size_attlist_
.
svg_height_
;
const
_CP_OPT
(
length
)
frameWidth
=
attlists_
.
rel_size_
.
common_draw_size_attlist_
.
svg_width_
;
const
_CP_OPT
(
length
)
frameHeight
=
attlists_
.
rel_size_
.
common_draw_size_attlist_
.
svg_height_
;
const
_CP_OPT
(
length
)
fromLeft
=
(
styleHorizontalPos
&&
styleHorizontalPos
->
get_type
()
==
horizontal_pos
::
FromLeft
)
?
attlists_
.
position_
.
svg_x_
:
length
(
0
,
length
::
pt
);
attlists_
.
position_
.
svg_x_
:
length
(
0
,
length
::
pt
);
_CP_OPT
(
length
)
svgX
;
...
...
@@ -232,48 +236,59 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
horRel
==
horizontal_rel
::
PageContent
||
horRel
==
horizontal_rel
::
PageStartMargin
)
{
svgX
=
fromLeft
;
// + translation
svgX
=
length
(
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
else
if
(
horRel
==
horizontal_rel
::
PageEndMargin
)
{
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
+
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
),
length
::
pt
);
// + translation
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
+
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
else
if
(
anchor
&&
anchor
->
get_type
()
==
anchor_type
::
Page
)
{
svgX
=
fromLeft
;
// + translation
svgX
=
length
(
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
else
if
(
horRel
==
horizontal_rel
::
Paragraph
||
horRel
==
horizontal_rel
::
ParagraphContent
||
horRel
==
horizontal_rel
::
ParagraphStartMargin
)
{
// TODO
double
paragraphLeftIndent
=
0
;
svgX
=
length
(
paragraphLeftIndent
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
svgX
=
length
(
paragraphLeftIndent
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
else
if
(
horRel
==
horizontal_rel
::
ParagraphEndMargin
)
{
// TODO
double
paragraphRightIndent
=
0
;
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
-
paragraphRightIndent
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
-
paragraphRightIndent
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
else
if
(
horRel
==
horizontal_rel
::
Frame
||
horRel
==
horizontal_rel
::
FrameContent
||
horRel
==
horizontal_rel
::
FrameStartMargin
||
horRel
==
horizontal_rel
::
FrameEndMargin
)
{
svgX
=
fromLeft
;
// + translation
svgX
=
length
(
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
else
if
(
horRel
==
horizontal_rel
::
Char
)
{
svgX
=
fromLeft
;
// + translation
svgX
=
length
(
fromLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
// + translation
}
}
return
get_value_emu
(
svgX
);
...
...
@@ -289,27 +304,26 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
horRel
==
horizontal_rel
::
PageContent
||
horRel
==
horizontal_rel
::
PageStartMargin
)
{
svgX
=
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
));
// + translation
svgX
=
length
(
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
PageEndMargin
)
{
if
(
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
<
pageMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
))
{
// TODO
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
// - contextSubstractedValue
+
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
// - contextSubstractedValue
+
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
{
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
//$pageWidth -$frameWidth - $frameMarginLeft + $translation
}
}
...
...
@@ -324,20 +338,19 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
// TODO paragraphLeftIndent
// TODO contextSubstractedValue
//$paragraphLeftIndent + $frameMarginLeft - $contextSubstractedValue + $translation"
svgX
=
length
(
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgX
=
length
(
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
ParagraphEndMargin
)
{
// TODO paragraphRightIndent
// TODO contextSubstractedValue
// select="$contextWidth - $paragraphRightIndent + $frameMarginLeft - $contextSubstractedValue + $translation"
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
+
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
+
frameMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
Frame
||
horRel
==
horizontal_rel
::
FrameContent
||
...
...
@@ -367,26 +380,21 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
horRel
==
horizontal_rel
::
PageEndMargin
)
{
// "$pageWidth - $frameWidth - $frameMarginRight + $translation
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
PageStartMargin
)
{
if
(
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
<
pageMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
)
pageMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
))
{
//
svgX
=
length
(
pageMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgX
=
length
(
pageMarginLeft
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
svgX
=
length
(
0
,
length
::
pt
);
...
...
@@ -394,50 +402,44 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
}
else
if
(
anchor
&&
anchor
->
get_type
()
==
anchor_type
::
Page
)
{
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
);
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
));
}
else
if
(
horRel
==
horizontal_rel
::
PageContent
)
{
// $contextWidth - $frameWidth - $frameMarginRight - $contextSubstractedValue + $translation
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
Paragraph
||
horRel
==
horizontal_rel
::
ParagraphContent
||
horRel
==
horizontal_rel
::
ParagraphEndMargin
)
{
// $contextWidth - $paragraphRightIndent -$frameWidth - $frameMarginRight - $contextSubstractedValue + $translation
// TODO
length
paragraphRightIndent
(
0
,
length
::
pt
);
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
-
paragraphRightIndent
.
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgX
=
length
(
contextWidth
.
get_value_unit
(
length
::
pt
)
-
paragraphRightIndent
.
get_value_unit
(
length
::
pt
)
-
frameWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
ParagraphStartMargin
)
{
// $paragraphLeftIndent - $frameMarginRight - $contextSubstractedValue + $translation
// TODO
length
paragraphLeftIndent
(
0
,
length
::
pt
);
svgX
=
length
(
paragraphLeftIndent
.
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgX
=
length
(
paragraphLeftIndent
.
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
contextSubstractedValue
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
Frame
||
horRel
==
horizontal_rel
::
FrameContent
||
...
...
@@ -446,20 +448,17 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
{
// $pageWidth - $frameMarginRight + $translation
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
if
(
horRel
==
horizontal_rel
::
Char
)
{
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgX
=
length
(
pageWidth
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
-
frameMarginRight
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
else
{
...
...
@@ -564,12 +563,13 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
svgX
=
*
attlists_
.
position_
.
svg_x_
;
}
}
return
get_value_emu
(
svgX
);
return
get_value_emu
(
svgX
);
}
int
ComputeMarginY
(
const
style_page_layout_properties_attlist
&
pageProperties
,
const
union_common_draw_attlists
&
attlists_
,
const
graphic_format_properties
&
graphicProperties
)
int
ComputeMarginY
(
const
style_page_layout_properties_attlist
&
pageProperties
,
const
union_common_draw_attlists
&
attlists_
,
const
graphic_format_properties
&
graphicProperties
,
const
std
::
vector
<
odf_reader
::
_property
>
&
additional
)
{
// TODO : recursive result!!!
const
_CP_OPT
(
anchor_type
)
anchor
=
...
...
@@ -590,10 +590,14 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
_CP_OPT
(
vertical_rel
)
styleVerticalRel
=
graphicProperties
.
common_vertical_rel_attlist_
.
style_vertical_rel_
;
_CP_OPT
(
vertical_pos
)
styleVerticallPos
=
graphicProperties
.
common_vertical_pos_attlist_
.
style_vertical_pos_
;
const
_CP_OPT
(
length
)
pageHeight
=
pageProperties
.
fo_page_height_
;
_CP_OPT
(
double
)
dVal
;
if
(
GetProperty
(
additional
,
L"svg:translate_y"
,
dVal
));
const
_CP_OPT
(
length
)
translation
=
length
(
dVal
?
*
dVal
:
0
,
length
::
pt
);
const
_CP_OPT
(
length
)
pageHeight
=
pageProperties
.
fo_page_height_
;
// TODO : проверить, значения в процентах что именно означают
const
_CP_OPT
(
length
)
pageMarginTop
=
CalcResultLength
(
pageProperties
.
common_vertical_margin_attlist_
.
fo_margin_top_
,
pageHeight
);
const
_CP_OPT
(
length
)
pageMarginBottom
=
CalcResultLength
(
pageProperties
.
common_vertical_margin_attlist_
.
fo_margin_bottom_
,
pageHeight
);
const
_CP_OPT
(
length
)
pageMarginTop
=
CalcResultLength
(
pageProperties
.
common_vertical_margin_attlist_
.
fo_margin_top_
,
pageHeight
);
const
_CP_OPT
(
length
)
pageMarginBottom
=
CalcResultLength
(
pageProperties
.
common_vertical_margin_attlist_
.
fo_margin_bottom_
,
pageHeight
);
const
_CP_OPT
(
length
)
frameMarginTop
=
GetOnlyLength
(
graphicProperties
.
common_vertical_margin_attlist_
.
fo_margin_top_
);
const
_CP_OPT
(
length
)
frameMarginBottom
=
GetOnlyLength
(
graphicProperties
.
common_vertical_margin_attlist_
.
fo_margin_bottom_
);
...
...
@@ -620,15 +624,22 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
case
vertical_rel
:
:
PageContent
:
case
vertical_rel
:
:
Paragraph
:
case
vertical_rel
:
:
Line
:
svgY
=
fromTop
;
svgY
=
length
(
fromTop
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
break
;
case
vertical_rel
:
:
ParagraphContent
:
// TODO: get spacing property of current paragraph
svgY
=
fromTop
/*+paragraphTopSpacing*/
;
svgY
=
length
(
fromTop
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
/*+paragraphTopSpacing*/
;
break
;
case
vertical_rel
:
:
Frame
:
case
vertical_rel
:
:
FrameContent
:
svgY
=
fromTop
;
svgY
=
length
(
fromTop
.
get_value_or
(
length
(
0
,
length
::
pt
)).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
break
;
default:
break
;
...
...
@@ -675,12 +686,10 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
{
if
(
pageHeight
)
{
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
}
break
;
...
...
@@ -688,12 +697,12 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
{
if
(
pageHeight
)
{
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
pageMarginTop
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
pageMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
pageMarginTop
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
pageMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
}
break
;
...
...
@@ -703,13 +712,13 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
double
paragraphBottomSpacing
=
0.0
;
// TODO
if
(
pageHeight
)
{
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
pageMarginTop
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
pageMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
paragraphBottomSpacing
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
pageMarginTop
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
pageMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
paragraphBottomSpacing
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
}
break
;
...
...
@@ -719,10 +728,11 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
// $pageHeight - $frameHeight - $frameMarginBottom + $translation"
if
(
pageHeight
)
{
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
),
length
::
pt
);
svgY
=
length
(
pageHeight
->
get_value_unit
(
length
::
pt
)
-
frameHeight
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
-
frameMarginBottom
.
get_value_or
(
length
(
0
,
length
::
pt
)
).
get_value_unit
(
length
::
pt
)
+
translation
->
get_value_unit
(
length
::
pt
)
,
length
::
pt
);
}
}
break
;
...
...
@@ -741,8 +751,13 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
//{
// svgY = length(svgY->get_value_unit(length::pt) + pageHeight->get_value_unit(length::pt) * (*anchor_page_number - 1), length::pt );
//}
return
get_value_emu
(
svgY
);
//_CP_OPT(double) dVal;
//if (GetProperty(additional, L"svg:translate_y", dVal))
//{
// if (svgY) svgY = *svgY + *dVal;
// else svgY = length(*dVal, length::pt);
//}
return
get_value_emu
(
svgY
);
}
}
...
...
@@ -810,7 +825,11 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
{
drawing
.
isInline
=
true
;
}
if
(
attlists_
.
shape_with_text_and_styles_
.
common_draw_shape_with_styles_attlist_
.
common_draw_transform_attlist_
.
draw_transform_
)
{
std
::
wstring
transformStr
=
attlists_
.
shape_with_text_and_styles_
.
common_draw_shape_with_styles_attlist_
.
common_draw_transform_attlist_
.
draw_transform_
.
get
();
oox_convert_transforms
(
transformStr
,
drawing
.
additional
);
}
if
(
!
drawing
.
isInline
)
{
if
(
!
drawing
.
styleWrap
)
...
...
@@ -842,8 +861,8 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
drawing
.
margin_rect
[
2
]
=
GetMargin
(
graphicProperties
,
sideRight
);
drawing
.
margin_rect
[
3
]
=
GetMargin
(
graphicProperties
,
sideBottom
);
drawing
.
posOffsetH
=
ComputeMarginX
(
pagePropertiesNode
,
pageProperties
,
attlists_
,
graphicProperties
);
drawing
.
posOffsetV
=
ComputeMarginY
(
pageProperties
,
attlists_
,
graphicProperties
);
drawing
.
posOffsetH
=
ComputeMarginX
(
pagePropertiesNode
,
pageProperties
,
attlists_
,
graphicProperties
,
drawing
.
additional
);
drawing
.
posOffsetV
=
ComputeMarginY
(
pageProperties
,
attlists_
,
graphicProperties
,
drawing
.
additional
);
}
drawing
.
number_wrapped_paragraphs
=
graphicProperties
.
style_number_wrapped_paragraphs_
.
...
...
@@ -881,11 +900,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
}
}
///////////////////////////
if
(
attlists_
.
shape_with_text_and_styles_
.
common_draw_shape_with_styles_attlist_
.
common_draw_transform_attlist_
.
draw_transform_
)
{
std
::
wstring
transformStr
=
attlists_
.
shape_with_text_and_styles_
.
common_draw_shape_with_styles_attlist_
.
common_draw_transform_attlist_
.
draw_transform_
.
get
();
oox_convert_transforms
(
transformStr
,
drawing
.
additional
);
}
drawing
.
x
=
get_value_emu
(
attlists_
.
position_
.
svg_x_
);
drawing
.
y
=
get_value_emu
(
attlists_
.
position_
.
svg_y_
);
...
...
@@ -947,24 +962,24 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
////////////////////////////////////////////////////////////////////////////////////////////////////
_CP_OPT
(
double
)
dVal
;
GetProperty
(
drawing
.
additional
,
L"svg:scale_x"
,
dVal
);
GetProperty
(
drawing
.
additional
,
L"svg:scale_x"
,
dVal
);
if
(
dVal
)
drawing
.
cx
=
(
int
)(
0.5
+
drawing
.
cx
*
dVal
.
get
());
GetProperty
(
drawing
.
additional
,
L"svg:scale_y"
,
dVal
);
GetProperty
(
drawing
.
additional
,
L"svg:scale_y"
,
dVal
);
if
(
dVal
)
drawing
.
cy
=
(
int
)(
0.5
+
drawing
.
cy
*
dVal
.
get
());
GetProperty
(
drawing
.
additional
,
L"svg:translate_x"
,
dVal
);
GetProperty
(
drawing
.
additional
,
L"svg:translate_x"
,
dVal
);
if
(
dVal
)
{
int
val
=
get_value_emu
(
dVal
.
get
());
drawing
.
x
=
val
>=
0
?
val
:
0
;
//??? todooo отрицательные величины ...
drawing
.
x
=
val
>=
0
?
val
:
0
;
//??? todooo отрицательные величины ...
}
GetProperty
(
drawing
.
additional
,
L"svg:translate_y"
,
dVal
);
GetProperty
(
drawing
.
additional
,
L"svg:translate_y"
,
dVal
);
if
(
dVal
)
{
int
val
=
get_value_emu
(
dVal
.
get
());
drawing
.
y
=
val
>=
0
?
val
:
0
;
//??? todooo отрицательные величины ...
drawing
.
y
=
val
>=
0
?
val
:
0
;
//??? todooo отрицательные величины ...
}
if
(
drawing
.
inGroup
&&
drawing
.
type
!=
oox
::
typeGroupShape
)
...
...
ASCOfficeOdfFile/src/odf/draw_shapes.cpp
View file @
1fc824db
...
...
@@ -431,9 +431,11 @@ int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val)
/// draw-enhanced_geometry_attlist
void
draw_enhanced_geometry_attlist
::
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
)
{
CP_APPLY_ATTR
(
L"draw:type"
,
draw_type_
);
CP_APPLY_ATTR
(
L"draw:modifiers"
,
draw_modifiers_
);
CP_APPLY_ATTR
(
L"draw:text-path"
,
draw_text_path_
);
CP_APPLY_ATTR
(
L"draw:type"
,
draw_type_
);
CP_APPLY_ATTR
(
L"draw:modifiers"
,
draw_modifiers_
);
CP_APPLY_ATTR
(
L"draw:text-path"
,
draw_text_path_
);
CP_APPLY_ATTR
(
L"draw:enhanced-path"
,
draw_enhanced_path_
);
CP_APPLY_ATTR
(
L"drawooo:sub-view-size"
,
drawooo_sub_view_size_
);
}
// draw:enhanced_geometry
const
wchar_t
*
draw_enhanced_geometry
::
ns
=
L"draw"
;
...
...
@@ -490,31 +492,42 @@ void draw_enhanced_geometry::find_draw_type_oox()
draw_type_oox_index_
=
i
;
break
;
}
}
}
else
{
int
count
=
sizeof
(
_OO_OOX_custom_shapes
)
/
sizeof
(
_shape_converter
);
int
pos
=
odf_type
.
find
(
L"ooxml-"
);
for
(
long
i
=
0
;
i
<
count
;
i
++
)
if
(
pos
<
0
)
{
if
(
_OO_OOX_custom_shapes
[
i
].
odf_reader
==
odf_type
)
for
(
long
i
=
0
;
i
<
count
;
i
++
)
{
draw_type_oox_index_
=
i
;
break
;
if
(
_OO_OOX_custom_shapes
[
i
].
odf_reader
==
odf_type
)
{
draw_type_oox_index_
=
i
;
break
;
}
}
}
else
{
std
::
wstring
oox_type
=
odf_type
.
substr
(
pos
+
6
);
for
(
long
i
=
0
;
i
<
count
;
i
++
)
{
if
(
_OO_OOX_custom_shapes
[
i
].
oox
==
oox_type
)
{
draw_type_oox_index_
=
i
;
break
;
}
}
}
if
((
draw_type_oox_index_
)
&&
(
*
draw_type_oox_index_
==
179
))
//L"textBox"
{
sub_type_
=
1
;
//textBox
}
}
}
std
::
wstringstream
str
;
BOOST_FOREACH
(
const
office_element_ptr
&
parElement
,
draw_handle_
)
...
...
@@ -527,19 +540,19 @@ void draw_enhanced_geometry::find_draw_type_oox()
try
{
min
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_range_y_minimum_
);
//пока статик .. и выдается только цыфровое значение
if
(
min
<
0
)
min
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_range_x_minimum_
);
if
(
min
<
0
)
min
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_range_x_minimum_
);
if
(
min
<
0
)
min
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_radius_range_minimum_
);
}
catch
(...)
{
}
if
(
min
<
0
)
min
=
0
;
if
(
min
<
0
)
min
=
0
;
try
{
max
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_range_y_maximum_
);
if
(
max
<
0
)
max
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_range_x_maximum_
);
if
(
max
<
0
)
max
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_radius_range_maximum_
);
if
(
max
<
0
)
max
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_range_x_maximum_
);
if
(
max
<
0
)
max
=
parsing
(
handle
->
draw_handle_attlist_
.
draw_handle_radius_range_maximum_
);
}
catch
(...)
{
...
...
@@ -605,11 +618,11 @@ void draw_connector::reset_svg_path()
{
if
(
poly
.
points
[
i
].
x
)
{
poly
.
points
[
i
].
x
=
length
(
poly
.
points
[
i
].
x
.
get
()
/
1000.
,
length
::
cm
).
get_value_unit
(
length
::
emu
)
-
x1
;
poly
.
points
[
i
].
x
=
length
(
poly
.
points
[
i
].
x
.
get
()
/
1000.
,
length
::
cm
).
get_value_unit
(
length
::
emu
)
-
x1
;
}
if
(
poly
.
points
[
i
].
y
)
{
poly
.
points
[
i
].
y
=
length
(
poly
.
points
[
i
].
y
.
get
()
/
1000.
,
length
::
cm
).
get_value_unit
(
length
::
emu
)
-
y1
;
poly
.
points
[
i
].
y
=
length
(
poly
.
points
[
i
].
y
.
get
()
/
1000.
,
length
::
cm
).
get_value_unit
(
length
::
emu
)
-
y1
;
}
}
o_Polyline_pt
.
push_back
(
poly
);
...
...
ASCOfficeOdfFile/src/odf/draw_shapes.h
View file @
1fc824db
...
...
@@ -436,6 +436,8 @@ public:
_CP_OPT
(
std
::
wstring
)
draw_type_
;
_CP_OPT
(
std
::
wstring
)
draw_modifiers_
;
_CP_OPT
(
bool
)
draw_text_path_
;
_CP_OPT
(
std
::
wstring
)
draw_enhanced_path_
;
_CP_OPT
(
std
::
wstring
)
drawooo_sub_view_size_
;
};
/////////////////////////////////////////////////////////////////////////
class
draw_enhanced_geometry
:
public
office_element_impl
<
draw_enhanced_geometry
>
...
...
@@ -466,11 +468,11 @@ public:
typedef
std
::
pair
<
std
::
wstring
,
std
::
wstring
>
pair_string_value
;
std
::
vector
<
draw_handle_geometry
>
draw_handle_geometry_
;
//параметры в удобноваримом виде
std
::
vector
<
pair_string_value
>
draw_equation_array_
;
std
::
vector
<
draw_handle_geometry
>
draw_handle_geometry_
;
std
::
vector
<
pair_string_value
>
draw_equation_array_
;
office_element_ptr_array
draw_handle_
;
office_element_ptr_array
draw_equation_
;
//некоторые заданные параметры отрисовки которые используются в draw_handle - автозамена общих частей
office_element_ptr_array
draw_handle_
;
office_element_ptr_array
draw_equation_
;
static
int
parsing
(
_CP_OPT
(
std
::
wstring
)
val
);
...
...
ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp
View file @
1fc824db
...
...
@@ -245,10 +245,6 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape
->
word_art_
=
word_art_
;
if
(
sub_type_
)
{
shape
->
sub_type_
=
sub_type_
.
get
();
}
if
(
draw_type_oox_index_
)
{
shape
->
additional_
.
push_back
(
_property
(
L"odf-custom-draw-index"
,
draw_type_oox_index_
.
get
()));
...
...
@@ -257,7 +253,39 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape
->
additional_
.
push_back
(
_property
(
L"wordArt"
,
true
));
}
if
(
draw_enhanced_geometry_attlist_
.
draw_modifiers_
)
if
(
sub_type_
)
{
shape
->
sub_type_
=
sub_type_
.
get
();
}
if
(
draw_enhanced_geometry_attlist_
.
draw_enhanced_path_
)
{
std
::
vector
<
svg_path
::
_polyline
>
o_Polyline
;
bool
res
=
svg_path
::
parseSvgD
(
o_Polyline
,
draw_enhanced_geometry_attlist_
.
draw_enhanced_path_
.
get
(),
true
);
if
(
o_Polyline
.
size
()
>
0
)
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std
::
wstringstream
output_
;
svg_path
::
oox_serialize
(
output_
,
o_Polyline
);
shape
->
additional_
.
push_back
(
odf_reader
::
_property
(
L"custom_path"
,
output_
.
str
()));
if
(
draw_enhanced_geometry_attlist_
.
drawooo_sub_view_size_
)
{
int
pos
=
draw_enhanced_geometry_attlist_
.
drawooo_sub_view_size_
->
find
(
L" "
);
if
(
pos
>=
0
)
{
int
w
=
boost
::
lexical_cast
<
int
>
(
draw_enhanced_geometry_attlist_
.
drawooo_sub_view_size_
->
substr
(
0
,
pos
));
int
h
=
boost
::
lexical_cast
<
int
>
(
draw_enhanced_geometry_attlist_
.
drawooo_sub_view_size_
->
substr
(
pos
+
1
));
shape
->
additional_
.
push_back
(
odf_reader
::
_property
(
L"custom_path_w"
,
w
));
shape
->
additional_
.
push_back
(
odf_reader
::
_property
(
L"custom_path_h"
,
h
));
}
}
}
}
else
if
(
draw_enhanced_geometry_attlist_
.
draw_modifiers_
)
{
shape
->
additional_
.
push_back
(
_property
(
L"draw-modifiers"
,
draw_enhanced_geometry_attlist_
.
draw_modifiers_
.
get
()));
if
(
draw_handle_geometry_
.
size
()
>
0
)
...
...
@@ -268,7 +296,6 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape
->
additional_
.
push_back
(
_property
(
L"draw-modifiers-max"
,
draw_handle_geometry_
[
0
].
max
));
}
}
}
}
}
...
...
ASCOfficeOdfFile/src/odf/svg_parser.cpp
View file @
1fc824db
...
...
@@ -224,9 +224,8 @@ namespace svg_path
nLastX
=
aFirst
.
x
.
get
();
nLastY
=
aFirst
.
y
.
get
();
}
break
;
}
aCurrPoly
.
command
=
L"a:close"
;
}
break
;
case
'm'
:
case
'M'
:
{
...
...
@@ -260,7 +259,6 @@ namespace svg_path
aCurrPoly
.
points
.
clear
();
}
}
nPos
++
;
skipSpaces
(
nPos
,
rSvgDStatement
,
nLen
);
...
...
@@ -285,10 +283,8 @@ namespace svg_path
aCurrPoly
.
points
.
push_back
(
_point
(
nX
,
nY
));
Polyline
.
push_back
(
aCurrPoly
);
aCurrPoly
.
points
.
clear
();
}
break
;
}
}
}
break
;
case
'h'
:
{
bRelative
=
true
;
...
...
@@ -404,9 +400,8 @@ namespace svg_path
//keep control point
nLastControlX
=
nX2
;
nLastControlY
=
nY2
;
}
break
;
}
}
}
break
;
case
'c'
:
{
...
...
@@ -457,9 +452,8 @@ namespace svg_path
//keep control point
nLastControlX
=
nX2
;
nLastControlY
=
nY2
;
}
break
;
}
}
}
break
;
// #100617# quadratic beziers are imported as cubic ones
//case 'q' :
...
...
@@ -760,7 +754,7 @@ namespace svg_path
}
}
if
(
aCurrPoly
.
points
.
size
()
>
0
)
if
(
aCurrPoly
.
points
.
size
()
>
0
||
bIsClosed
)
{
// end-process last poly
if
(
bIsClosed
)
...
...
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