Difference between revisions of "API/Samples/StarBasic/ListOfFilterName"

From Apache OpenOffice Wiki
< API‎ | Samples‎ | StarBasic
Jump to: navigation, search
m
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Description: To get a list of Filter Name in OpenOffice.org 2.3, the property of Filter Name used to importand export has to be exactly matched the name in the list. This snippet will open a new ODT document and append the list to the document.
+
Description: To get a list of Filter Name in {{AOo}}, the property of Filter Name used to import and export has to be exactly matched to the name in the list. This snippet will open a new ODT document and append the list to the document.
  
<source lang="oobas">
+
 
 +
'''Note: This macro was taken from a thread at [https://web.archive.org/web/20070307190812/http://www.oooforum.org/forum/viewtopic.phtml?t=3549 http://www.oooforum.org/forum/viewtopic.phtml?t=3549], it was discussed for OpenOffice.org 1.1rc1, but it still works with OpenOffice version 4.1.'''
 +
 
 +
<syntaxhighlight lang="oobas">
 
REM  *****  BASIC  *****
 
REM  *****  BASIC  *****
 
Sub Main
 
Sub Main
Line 24: Line 27:
 
   Next
 
   Next
 
End Sub  
 
End Sub  
</source>
+
</syntaxhighlight>
 
[[Category:API]]
 
[[Category:API]]
 
[[Category:Samples]]
 
[[Category:Samples]]
 
[[Category:StarBasic]]
 
[[Category:StarBasic]]
 
[[Category:Office]]
 
[[Category:Office]]

Latest revision as of 16:20, 24 August 2022

Description: To get a list of Filter Name in Apache OpenOffice, the property of Filter Name used to import and export has to be exactly matched to the name in the list. This snippet will open a new ODT document and append the list to the document.


Note: This macro was taken from a thread at http://www.oooforum.org/forum/viewtopic.phtml?t=3549, it was discussed for OpenOffice.org 1.1rc1, but it still works with OpenOffice version 4.1.

REM  *****  BASIC  *****
Sub Main
   oFF = createUnoService( "com.sun.star.document.FilterFactory" )
   oFilterNames = oFF.getElementNames()
 
   ' Now print the filter names.
'   For i = LBound( oFilterNames ) To UBound( oFilterNames )
'      Print oFilterNames(i)
'   Next
 
   ' Create a Writer doc and save the filter names to it.
   oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array() )
   oText = oDoc.getText()
   oCursor = oText.createTextCursor()
   oCursor.gotoEnd( False )
 
   ' Print the filter names into a Writer document.
   For i = LBound( oFilterNames ) To UBound( oFilterNames )
      oText.insertString( oCursor, oFilterNames(i), False )
      oText.insertControlCharacter( oCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False )
   Next
End Sub
Personal tools