Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
592fadbc
Commit
592fadbc
authored
Aug 17, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Form: implement ImageField.render_odt
parent
d5db204e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
product/ERP5Form/ImageField.py
product/ERP5Form/ImageField.py
+33
-1
No files found.
product/ERP5Form/ImageField.py
View file @
592fadbc
...
...
@@ -39,13 +39,15 @@ DRAW_URI = 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'
TEXT_URI
=
'urn:oasis:names:tc:opendocument:xmlns:text:1.0'
XLINK_URI
=
'http://www.w3.org/1999/xlink'
SVG_URI
=
'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'
OFFICE_URI
=
'urn:oasis:names:tc:opendocument:xmlns:office:1.0'
NSMAP
=
{
'draw'
:
DRAW_URI
,
'text'
:
TEXT_URI
,
'xlink'
:
XLINK_URI
,
'svg'
:
SVG_URI
'svg'
:
SVG_URI
,
'office'
:
OFFICE_URI
,
}
class
ImageFieldWidget
(
Widget
.
TextWidget
):
...
...
@@ -207,6 +209,36 @@ class ImageFieldWidget(Widget.TextWidget):
return
etree
.
tostring
(
draw_frame_node
)
return
draw_frame_node
def
render_odt_view
(
self
,
field
,
value
,
as_string
,
ooo_builder
,
REQUEST
,
render_prefix
,
attr_dict
,
local_name
,
escape
=
False
):
"""
Returns the field for inclusion in odt style, using `office:include_img`
"""
p_node
=
Element
(
'{%s}%s'
%
(
TEXT_URI
,
local_name
),
nsmap
=
NSMAP
)
if
attr_dict
is
None
:
attr_dict
=
{}
p_node
.
attrib
.
update
(
attr_dict
)
# <office:include_img> tags are substitued by OOoTemplate, by regexp, so
# we have to make sure serialisation uses `office` as namespace prefix
# here.
include_img_node
=
Element
(
'{%s}include_img'
%
NSMAP
[
'office'
],
nsmap
=
NSMAP
)
# preference return width unit in pixel, office:include_img expect cm.
preferred_width
=
field
.
getPortalObject
().
portal_preferences
.
getPreference
(
'preferred_%s_image_width'
%
(
field
.
get_value
(
'image_display'
)),
100
);
include_img_node
.
attrib
[
'width'
]
=
'%.2f'
%
max
(
preferred_width
/
20.
,
9
)
include_img_node
.
attrib
[
'{%s}style'
%
NSMAP
[
'draw'
]]
=
'inline-graphic'
field_value
=
field
.
get_value
(
'default'
)
if
field_value
:
include_img_node
.
attrib
[
'path'
]
=
'/'
.
join
(
REQUEST
.
physicalPathFromURL
(
field_value
));
p_node
.
append
(
include_img_node
)
if
as_string
:
return
etree
.
tostring
(
p_node
)
return
p_node
def
_getPictureSize
(
self
,
picture_width
,
picture_height
,
target_width
,
target_height
):
# if not match causes exception
...
...
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