This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch python-editing-embedding in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 36f82a9eeb51ffd41f8a3b66fee49cccb41f67a8 Author: Damjan Jovanovic <[email protected]> AuthorDate: Sun Apr 26 19:10:44 2026 +0200 Cleanups. Save in UTF-8 format just in case. Patch by: me --- main/scripting/source/pyprov/pythonscript.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/main/scripting/source/pyprov/pythonscript.py b/main/scripting/source/pyprov/pythonscript.py index 77346bec1f..9b7edbee83 100644 --- a/main/scripting/source/pyprov/pythonscript.py +++ b/main/scripting/source/pyprov/pythonscript.py @@ -583,7 +583,7 @@ def isScript( candidate ): return ret #------------------------------------------------------- -class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, XActionListener ): +class ScriptBrowseNode( unohelper.Base, XBrowseNode, XPropertySet, XInvocation, XActionListener ): def __init__( self, provCtx, parent, fileName, funcName ): self.parent = parent self.fileName = fileName @@ -667,16 +667,12 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, elif event.ActionCommand == "Save": toWrite = uno.ByteSequence( - self.editor.getControl("EditorTextField").getText().encode( - sys.getdefaultencoding())) + self.editor.getControl("EditorTextField").getText().encode("utf-8")) copyUrl = self.uri() + ".orig" self.provCtx.sfa.move( self.uri(), copyUrl ) log.debug( "Saving Python macro to URI " + self.uri() ) self.provCtx.sfa.writeFile( self.uri(), BytesInputStream( toWrite.value ) ) self.provCtx.sfa.kill( copyUrl ) -# log.debug("Save is not implemented yet") -# text = self.editor.getControl("EditorTextField").getText() -# log.debug("Would save: " + text) except Exception as e: # TODO: add an error box here ! log.error( lastException2String() ) @@ -834,16 +830,12 @@ class FileBrowseNode( unohelper.Base, XBrowseNode, XPropertySet, XInvocation, XA elif event.ActionCommand == "Save": toWrite = uno.ByteSequence( - self.editor.getControl("EditorTextField").getText().encode( - sys.getdefaultencoding())) + self.editor.getControl("EditorTextField").getText().encode("utf-8")) copyUrl = self.uri() + ".orig" self.provCtx.sfa.move( self.uri(), copyUrl ) log.debug( "Saving Python macro to URI " + self.uri() ) self.provCtx.sfa.writeFile( self.uri(), BytesInputStream( toWrite.value ) ) self.provCtx.sfa.kill( copyUrl ) -# log.debug("Save is not implemented yet") -# text = self.editor.getControl("EditorTextField").getText() -# log.debug("Would save: " + text) except Exception as e: # TODO: add an error box here ! log.error( lastException2String() )
