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
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
Hardik Juneja
erp5
Commits
a42877cf
Commit
a42877cf
authored
Mar 13, 2013
by
Lingnan Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change the render of presentation
parent
9ee74bfa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
product/ERP5/mixin/extensible_traversable.py
product/ERP5/mixin/extensible_traversable.py
+2
-0
product/ERP5OOo/Document/OOoDocument.py
product/ERP5OOo/Document/OOoDocument.py
+16
-13
No files found.
product/ERP5/mixin/extensible_traversable.py
View file @
a42877cf
...
...
@@ -215,6 +215,8 @@ class OOoDocumentExtensibleTraversableMixin(BaseExtensibleTraversableMixin):
self
.
_convert
(
format
=
'html'
)
_setCacheHeaders
(
_ViewEmulator
().
__of__
(
self
),
web_cache_kw
)
mime
,
data
=
self
.
getConversion
(
format
=
EMBEDDED_FORMAT
,
filename
=
name
)
if
name
.
endswith
(
'.html'
)
and
self
.
getPortalType
()
==
'Presentation'
:
data
=
self
.
Presentation_renderWithNavigation
(
data
=
self
.
_stripHTML
(
html
=
data
)).
encode
(
'utf-8'
)
document
=
OFSFile
(
name
,
name
,
data
,
content_type
=
mime
).
__of__
(
self
.
aq_parent
)
except
(
NotConvertedError
,
ConversionError
,
KeyError
):
document
=
DocumentExtensibleTraversableMixin
.
getExtensibleContent
(
self
,
request
,
name
)
...
...
product/ERP5OOo/Document/OOoDocument.py
View file @
a42877cf
...
...
@@ -273,6 +273,15 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
# XXX: handle possible OOOd server failure
return response_dict['
mime
'], Pdata(dec(response_dict['
data
']))
def asPresentationHTML(self, **kw):
"""
The start presentation page is different from the html of
other iframe
"""
mime, data = self._convert('
html
',**kw)
data = self.Presentation_renderWithNavigation(data=self._stripHTML(html=data)).encode('
utf
-
8
')
return data
# Conversion API
def _convert(self, format, frame=0, **kw):
"""Convert the document to the given format.
...
...
@@ -353,21 +362,14 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
cs
=
cStringIO
.
StringIO
()
cs
.
write
(
str
(
data
))
z
=
zipfile
.
ZipFile
(
cs
)
# A disk file would be more RAM efficient
for
f
in
z
.
infolist
():
fn
=
f
.
filename
if
fn
.
endswith
(
'html'
):
if
self
.
getPortalType
()
==
'Presentation'
\
and
not
(
fn
.
find
(
'impr'
)
>=
0
):
continue
data
=
z
.
read
(
fn
)
break
mime
=
'text/html'
self
.
_populateConversionCacheWithHTML
(
zip_file
=
z
)
# Maybe some parts should be asynchronous for
self
.
_populateConversionCacheWithHTML
(
zip_file
=
z
,
**
kw
)
# Maybe some parts should be asynchronous for
# better usability
z
.
close
()
cs
.
close
()
if
original_format
not
in
VALID_IMAGE_FORMAT_LIST
\
and
not
requires_pdf_first
:
and
not
requires_pdf_first
:
if
not
self
.
getPortalType
()
==
'Presentation'
:
self
.
setConversion
(
data
,
mime
,
format
=
original_format
,
**
kw
)
else
:
# create temporary image and use it to resize accordingly
...
...
@@ -381,12 +383,11 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
mime
,
data
=
temp_image
.
convert
(
original_format
,
frame
=
frame
,
**
kw
)
# store conversion
self
.
setConversion
(
data
,
mime
,
format
=
original_format
,
**
kw
)
return
self
.
getConversion
(
format
=
original_format
,
**
kw
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'_populateConversionCacheWithHTML'
)
def
_populateConversionCacheWithHTML
(
self
,
zip_file
=
None
):
def
_populateConversionCacheWithHTML
(
self
,
zip_file
=
None
,
**
kw
):
"""
Extract content from the ODF zip file and populate the document.
Optional parameter zip_file prevents from converting content twice.
...
...
@@ -419,6 +420,8 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
else
:
mime
=
guess_content_type
(
filename
)[
0
]
data
=
Pdata
(
zip_file
.
read
(
filename
))
if
".impr."
in
filename
and
self
.
getPortalType
()
==
'Presentation'
:
self
.
setConversion
(
data
,
mime
,
format
=
"html"
,
**
kw
)
self
.
setConversion
(
data
,
mime
=
mime
,
format
=
EMBEDDED_FORMAT
,
filename
=
filename
)
if
must_close
:
zip_file
.
close
()
...
...
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