OpenOffice.org

From Mandriva Community Wiki

Jump to: navigation, search
OpenOffice.org (or more strictly OpenOffice.org) is a fully featured office suite for GNU/Linux and other platforms. The main features of OpenOffice.org are word processing, spreadsheets, presentations, drawings, data charting, formula editing, and file conversion facilities (including those for Microsoft's WORD, EXCEL and Adobe's PDF formats).

What is OpenOffice.org?

OpenOffice.org (sometimes OOo for short) is distributed as part of your Mandriva Linux distribution. Openoffice is a truly huge package - it actually has more lines of source code than the linux kernel - as a result you may find it quite slow at times but it does get the job done. The commercial editon is StarOffice from Sun and it includes a handbook and the Adabas database. The drawing program OpenOffice.org Draw is described under that page.

One of the key features of OOo is it's ability to read and write Microsoft Office formats (Word, Powerpoint etc). This enables the GNU/Linux user to interact easily with users of other operating systems.

Another extremely useful element of OpenOffice is the ability to export to PDF easily. On competing products you have to pay extra to get PDF output, but in OpenOffice a button on the toolbar provides PDF export functionality.


OpenOffice.org Tips

  • OpenOfficeCommandline: how to convert documents into PDF documents from the command line (same for HTML)

I haven't tested this myself, nor am I aware of anyone who has, but according to "DannyB" at the Openoffice.org support forum, the conversion of .doc files to .pdf files can be accomplished at the command line this way. Notice: this information is lifted directly from the OOo support forum post linked above.

While exporting documents to PDF from within the OO.o graphical user interface is simply a matter of clicking on a menu item, you need a Macro to do the work from the commandline. That part is written in OOo's dialect of Basic.

Get into OpenOffice.org.

Tools -> Macros -> Macro....

Now click the button Organizer.....

Click the Libraries tab.

Set Application/Document to "soffice".

Click the button New...

Give the library the name "DannysLibrary".

Now click the Modules tab.

Unfold the tree of items under soffice. Find DannysLibrary and hilight it. Click the button New Module...

Name the module "Conversion".

The Basic IDE window should appear. Paste in the following code. Be sure to watch out for trailing spaces on lines copied from this web site. Especially on lines ending with an underscore, there cannot be any trailing spaces.
lsmod|Sub test( cArg )
   Print "|"+cArg+"|"
End Sub

Sub ConvertWordToPDF( cFile )
   cURL = ConvertToURL( cFile )
   
   ' Open the document.
   ' Just blindly assume that the document is of a type that OOo will
   '  correctly recognize and open -- without specifying an import filter.
   oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array(_
            MakePropertyValue( "Hidden", True ),_
            ) )


   cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"
   cURL = ConvertToURL( cFile )
   
   ' Save the document using a filter.   
   oDoc.storeToURL( cURL, Array(_
            MakePropertyValue( "FilterName", "writer_pdf_Export" ),_
            )
   
   oDoc.close( True )
End Sub


Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue() = oPropertyValue
End Function


This macro code is now part of OpenOffice.org and not specific to any document. That is, the macro is available at all times. Even if no documents are currently open.

Now write a Windows batch file. (Or a Linux shell script, let me know if I need to do this on Linux and post a followup.)


[Yes, this section describes a DOS batch file and a DOS file environment. I would apologize for it, but as I said, this is lifted from another site. It's really not my fault it's here. A bash script is really no problem to cobble together to do this work. Post a message in the Mandriva support forum for help if you need it.]

@ECHO OFF

"c:\program files\OpenOffice.org1.1.0\program\soffice" -invisible "macro:///DannysLibrary.Conversion.ConvertWordToPDF(%1)"

rem "c:\program files\OpenOffice.org1.1.0\program\soffice" -invisible "macro:///DannysLibrary.Conversion.test(%1)"


Be sure that you do not have any spaces between the parenthesis and the %1. You can un-comment the DannysLibrary.Converstion.test() line if you would like to call the simpler test function. When you do so, OOo hangs while a dialog is displayed that you need to dismiss before the batch file will continue.

Now from the command line, run your BAT file like this...

convert  c:\test.doc


A new file c:\test.pdf should appear.

If you want to convert bunches of documents, I have written a document converter utility that you can get over on the web site OOoMacros.org.

_________________

OpenOffice.org Links

Openoffice.org is a hugely popular package so unsurprisingly there are lots of useful links:-

Personal tools