diff --git a/product/ERP5/Document/TextDocument.py b/product/ERP5/Document/TextDocument.py index 69f0d10db682873a11acff125119b44831fcf79f..338878f6fc653b90232deca74783c7e9e4806117 100644 --- a/product/ERP5/Document/TextDocument.py +++ b/product/ERP5/Document/TextDocument.py @@ -128,7 +128,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, **substitution_method_parameter_dict) def _convert(self, format, substitution_method_parameter_dict=None, - safe_substitute=True, charset=None, text_content=None, **kw): + safe_substitute=True, charset=None, text_content=None, substitute=True, **kw): """ Convert text using portal_transforms or oood """ @@ -184,7 +184,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, self.setConversion(result, original_mime_type, **kw) else: mime_type, result = self.getConversion(**kw) - if format in VALID_TEXT_FORMAT_LIST: + if substitute and format in VALID_TEXT_FORMAT_LIST: # only textual content can be sustituted if substitution_method_parameter_dict is None: substitution_method_parameter_dict = {} diff --git a/product/ERP5/mixin/text_convertable.py b/product/ERP5/mixin/text_convertable.py index 5ed12c25c32e2a178e9a36f66f14e727d065c400..d017a1a5441188f94ef77d3786c4bae705253ff7 100644 --- a/product/ERP5/mixin/text_convertable.py +++ b/product/ERP5/mixin/text_convertable.py @@ -49,6 +49,16 @@ class TextConvertableMixin: mime, data = self.convert(format='txt', **kw) return str(data) + security.declareProtected(Permissions.AccessContentsInformation, + 'asRawText') + def asRawText(self, **kw): + """ + Converts the current document to plain text without substitution + """ + kw.pop('format', None) + mime, data = self.convert(format='txt', substitute=False, **kw) + return str(data) + security.declareProtected(Permissions.AccessContentsInformation, 'asTextContent') def asTextContent(self, **kw):