Bugzilla – Attachment 138672 Details for
Bug 114080
FILESAVE: "Save as Text" doesn't put end-of-line after each line shown on screen
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
macro to save current document as text, with hard line breaks
LOM-SaveAsText.bas (text/plain), 3.29 KB, created by
Jay Michael
on 2017-12-27 03:40:39 UTC
(
hide
)
Description:
macro to save current document as text, with hard line breaks
Filename:
MIME Type:
Creator:
Jay Michael
Created:
2017-12-27 03:40:39 UTC
Size:
3.29 KB
patch
obsolete
>SUB SaveAsText > oDoc = ThisComponent > dim SAVENAME as STRING > dim TXTDIR as STRING > dim TXTNAME as STRING > get_default_savefile_name( oDoc, TXTDIR, TXTNAME ) > SAVENAME = GET_SAVEFILE_NAME( TXTDIR, TXTNAME ) > if SAVENAME <> "" then > SAVE_DOC_AS_TEXT( oDoc, SAVENAME ) > end if >END SUB > >function GET_DEFAULT_SAVEFILE_NAME( oDoc as Object, _ > TXTDIR as STRING, TXTNAME as STRING ) as STRING > Dim strPath As String > > REM Use some methods from the Tools library. > If NOT GlobalScope.BasicLibraries.isLibraryLoaded("Tools") Then > GlobalScope.BasicLibraries.LoadLibrary("Tools") > End If > > If oDoc.hasLocation() Then > strPath = oDoc.getLocation() > TXTDIR = DirectoryNameOutOfPath( strPath, "/" ) > TXTNAME = GetFilenameWithoutExtension( strPath, "/" ) > Else > TXTDIR = curDir() > TXTNAME = oDoc.getTitle() > End If >end function > >function GET_SAVEFILE_NAME( TXTDIR as STRING, TXTNAME as STRING ) as STRING >dim FPtype(0) as integer >FilePicker = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") >FPtype(0)=com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION >rem FPtype(0)=com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE >FilePicker.initialize(FPtype()) >FilePicker.appendFilter( "Text File (*.TXT)", "*.TXT" ) >FilePicker.appendFilter( "All Files (*.*)", "*.*" ) >rem clear AUTOEXTENSION checkbox >rem FilePicker.setValue( com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, _ >rem com.sun.star.ui.dialogs.ControlActions.SET_SELECT_ITEM, false ) >FilePicker.setTitle( "Save Text as..." ) >FilePicker.setDisplayDirectory( TXTDIR ) >FilePicker.setDefaultName( TXTNAME ) > >If FilePicker.execute() Then > GET_SAVEFILE_NAME = ConvertFromURL( filepicker.files(0) ) >EndIf > >end function > >Sub Writer_Save_As_Text_With_LineBreaks( Optional oDoc as Object ) >REM https://ask.libreoffice.org/en/question/137329/feature-request-save-as-text-with-line-breaks/ >REM Exports Writer text lines to a text file. >REM The output file will be located in the same folder as the Writer document, or in the current directory. >REM <oDoc> : [OPTIONAL] The Writer document whose lines to export; Default = current document. > If IsMissing( oDoc ) Then oDoc = ThisComponent > If oDoc.supportsService( "com.sun.star.text.TextDocument" ) Then > > Dim strPath As String > If oDoc.hasLocation() Then > strPath = oDoc.getLocation() & ".txt" > Else > strPath = curDir() & getPathSeparator() & oDoc.getTitle() & ".txt" > End If > > End If >End Sub > >sub SAVE_DOC_AS_TEXT( oDoc as Object, strPath as STRING ) > If oDoc.supportsService( "com.sun.star.text.TextDocument" ) Then > Dim iOutputFile As Integer > iOutputFile = Freefile() > Open strPath For Output As #iOutputFile > > Dim oViewCursor as Object > oViewCursor = oDoc.CurrentController.getViewCursor() > oViewCursor.gotoStart( False ) > > Do > oViewCursor.gotoStartOfLine( False ) > oViewCursor.gotoEndOfLine( True ) > Print #iOutputFile, oViewCursor.getString() > Loop While oViewCursor.goRight( 1, False ) > > Close #iOutputFile > > End If >End Sub
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 114080
:
138007
|
138162
| 138672