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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
9f9e7abd
Commit
9f9e7abd
authored
Nov 25, 2016
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xxx workaround 4 wip
parent
59f66814
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
5 deletions
+61
-5
product/ERP5OOo/Document/OOoDocument.py
product/ERP5OOo/Document/OOoDocument.py
+61
-5
No files found.
product/ERP5OOo/Document/OOoDocument.py
View file @
9f9e7abd
...
...
@@ -111,7 +111,13 @@ class OOoServerProxy(ServerProxy):
or
OOO_SERVER_PROXY_TIMEOUT
transport
=
TimeoutTransport
(
timeout
=
timeout
,
scheme
=
scheme
)
ServerProxy
.
__init__
(
self
,
uri
,
allow_none
=
True
,
transport
=
transport
)
#ServerProxy.__init__(self, uri, allow_none=True, transport=transport)
from
xmlrpclib
import
SafeTransport
import
ssl
host
=
"[2001:67c:1254:9c::e1f]:8000"
# cloudooo3 - CloudoooTest
ssl_context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
# allow invalid/autosigned certs
ssl_context
.
verify_mode
=
ssl
.
CERT_NONE
ServerProxy
.
__init__
(
self
,
"https://"
+
host
,
allow_none
=
True
,
transport
=
SafeTransport
(
context
=
ssl_context
))
def
__getattr__
(
self
,
attr
):
obj
=
ServerProxy
.
__getattr__
(
self
,
attr
)
...
...
@@ -214,6 +220,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
def cached_getTargetFormatItemList(content_type):
server_proxy = OOoServerProxy(self)
# XXX cloudooo3 needed to have allowed target list given by x2t + ooo
try:
allowed_target_item_list = server_proxy.getAllowedTargetItemList(
content_type)
...
...
@@ -242,7 +249,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] + (
##### BEGIN hack - handle yformat (which should not be OOoDocument) XXX##
{"Text": [("OnlyOffice Text Document", "docy")],
"Spreadsheet": [("OnlyOffice Spreadsheet", "xlsy")],
"Presentation": [("OnlyOffice Presentation", "ppty")]}.get(self.getPortalType(), [])
##### END hack #####
)
# Cache valid format list
cached_getTargetFormatItemList = CachingMethod(
...
...
@@ -271,7 +284,24 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
z.close()
return '
text
/
plain
', s
server_proxy = OOoServerProxy(self)
# XXX cloudooo3 needed to convert with x2t
orig_format = self.getBaseContentType()
##### BEGIN hack - handle yformat (should not be OOoDocument) XXX##
# XXX public cloudooo.erp5.net cannot handle x2t because of an OSError
__traceback_info__ = ("orig_format", orig_format, "format", format)
if format in ("docy", "application/x-asc-text"):
encdata = server_proxy.convertFile(enc(str(self.getBaseData())), "odt", "docx")
#orig_format = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
return "application/x-asc-text", Pdata(dec(server_proxy.convertFile(encdata, "docx", "docy")))
if format in ("xsly", "application/x-asc-spreadsheet"):
encdata = server_proxy.convertFile(enc(str(self.getBaseData())), "ods", "xlsx")
#orig_format = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
return "application/x-asc-spreadsheet", Pdata(dec(server_proxy.convertFile(encdata, "xlsx", "xlsy")))
if format in ("ppty", "application/x-asc-presentation"):
encdata = server_proxy.convertFile(enc(str(self.getBaseData())), "odp", "pptx")
#orig_format = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
return "application/x-asc-presentation", Pdata(dec(server_proxy.convertFile(encdata, "pptx", "ppty")))
##### END hack #####
generate_result = server_proxy.run_generate(self.getId(),
enc(str(self.getBaseData())),
None,
...
...
@@ -354,6 +384,12 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
self
.
setConversion
(
data
,
mime
,
format
=
original_format
)
return
mime
,
data
return
self
.
getConversion
(
format
=
original_format
)
try
:
__traceback_info__
=
repr
(
self
),
repr
(
self
.
getTargetFormatItemList
())
except
ConflictError
,
e
:
raise
e
except
Exception
,
e
:
__traceback_info__
=
str
(
e
)
# Raise an error if the format is not supported
if
not
self
.
isTargetFormatAllowed
(
format
):
raise
ConversionError
(
"OOoDocument: target format %s is not supported"
%
format
)
...
...
@@ -446,12 +482,31 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
on the object. Update metadata information.
"""
server_proxy
=
OOoServerProxy
(
self
)
# XXX cloudooo3 needed to have x2t convert available
##### BEGIN hack - handle yformat (which should not be OOoDocument) XXX##
content_type
=
self
.
getContentType
()
filename
=
self
.
getFilename
()
or
self
.
getId
()
if
content_type
==
"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
==
"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
==
"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
()))
##### END hack #####
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'
]))
...
...
@@ -485,6 +540,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
raise
NotConvertedError
()
server_proxy
=
OOoServerProxy
(
self
)
# XXX cloudooo3 needed to have setMetadata on x2t
response_code
,
response_dict
,
response_message
=
\
server_proxy
.
run_setmetadata
(
self
.
getId
(),
enc
(
str
(
self
.
getBaseData
())),
...
...
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