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
Eugene Shen
erp5
Commits
4000bc0a
Commit
4000bc0a
authored
Jan 18, 2017
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OOoDocument: hack to handle OnlyOffice document
parent
8217bffe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
4 deletions
+43
-4
product/ERP5OOo/Document/OOoDocument.py
product/ERP5OOo/Document/OOoDocument.py
+43
-4
No files found.
product/ERP5OOo/Document/OOoDocument.py
View file @
4000bc0a
...
...
@@ -242,7 +242,13 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
DeprecationWarning)
# tuple order is reversed to be compatible with ERP5 Form
return [(y, x) for x, y in allowed]
return [(y, x) for x, y in allowed] + (
# XXX Hack to force cloudooo to say "I can convert odt to docy"
# which should be portal transforms'
job
.
{
"application/vnd.oasis.opendocument.text"
:
[(
"OnlyOffice Text Document"
,
"docy"
)],
"application/vnd.oasis.opendocument.spreadsheet"
:
[(
"OnlyOffice Spreadsheet"
,
"xlsy"
)],
"application/vnd.oasis.opendocument.presentation"
:
[(
"OnlyOffice Presentation"
,
"ppty"
)]}.
get
(
content_type
,
[])
)
# Cache valid format list
cached_getTargetFormatItemList
=
CachingMethod
(
...
...
@@ -272,6 +278,19 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
return
'text/plain'
,
s
server_proxy
=
OOoServerProxy
(
self
)
orig_format
=
self
.
getBaseContentType
()
# XXX hack to handle OnlyOffice yformats unless Cloudooo is able
# to convert from "odt" to "docy" without two step conversion.
if
format
in
(
"docy"
,
"application/x-asc-text+zip"
,
"application/x-asc-text"
):
encdata
=
server_proxy
.
convertFile
(
enc
(
str
(
self
.
getBaseData
())),
"odt"
,
"docx"
)
return
"application/x-asc-text"
,
Pdata
(
dec
(
server_proxy
.
convertFile
(
encdata
,
"docx"
,
"docy"
)))
if
format
in
(
"xsly"
,
"application/x-asc-spreadsheet+zip"
,
"application/x-asc-spreadsheet"
):
encdata
=
server_proxy
.
convertFile
(
enc
(
str
(
self
.
getBaseData
())),
"ods"
,
"xlsx"
)
return
"application/x-asc-spreadsheet"
,
Pdata
(
dec
(
server_proxy
.
convertFile
(
encdata
,
"xlsx"
,
"xlsy"
)))
if
format
in
(
"ppty"
,
"application/x-asc-presentation+zip"
,
"application/x-asc-presentation"
):
encdata
=
server_proxy
.
convertFile
(
enc
(
str
(
self
.
getBaseData
())),
"odp"
,
"pptx"
)
return
"application/x-asc-presentation"
,
Pdata
(
dec
(
server_proxy
.
convertFile
(
encdata
,
"pptx"
,
"ppty"
)))
generate_result
=
server_proxy
.
run_generate
(
self
.
getId
(),
enc
(
str
(
self
.
getBaseData
())),
None
,
...
...
@@ -446,12 +465,32 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
on the object. Update metadata information.
"""
server_proxy
=
OOoServerProxy
(
self
)
# XXX hack to handle OnlyOffice yformats unless Cloudooo is able
# to convert from "docy" to "odt" without two step conversion.
content_type
=
self
.
getContentType
()
filename
=
self
.
getFilename
()
or
self
.
getId
()
if
content_type
in
(
"application/x-asc-text+zip"
,
"application/x-asc-text"
):
encdata
=
server_proxy
.
convertFile
(
enc
(
str
(
self
.
getData
())),
"docy"
,
"docx"
)
content_type
=
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
filename
+=
".docx"
elif
content_type
in
(
"application/x-asc-spreadsheet+zip"
,
"application/x-asc-spreadsheet"
):
encdata
=
server_proxy
.
convertFile
(
enc
(
str
(
self
.
getData
())),
"xlsy"
,
"xlsx"
)
content_type
=
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
filename
+=
".xlsx"
elif
content_type
in
(
"application/x-asc-presentation+zip"
,
"application/x-asc-presentation"
):
encdata
=
server_proxy
.
convertFile
(
enc
(
str
(
self
.
getData
())),
"ppty"
,
"pptx"
)
content_type
=
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
filename
+=
".pptx"
else
:
encdata
=
enc
(
str
(
self
.
getData
()))
response_code
,
response_dict
,
response_message
=
server_proxy
.
run_convert
(
self
.
getFilename
()
or
self
.
getId
()
,
enc
(
str
(
self
.
getData
()))
,
filename
,
enc
data
,
None
,
None
,
self
.
getContentType
()
)
content_type
)
if
response_code
==
200
:
# sucessfully converted document
self
.
_setBaseData
(
dec
(
response_dict
[
'data'
]))
...
...
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