OOOlatex

Hello,

On a fedora 19 machine (Build ID: 4.1.3.2-5.fc19), when I try to use the ooolatex equation
tool, I get an error message (it works fine with fedora 18)

Is OOolatex not anymore maintained?

Thank.

'
'    OOoLatexTools
'
'    Copyright (C) 2005-2007 Geoffroy Piroux (gpiroux@gmail.com)
'
'    This program is free software; you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation; either version 2 of the License, or
'    (at your option) any later version.
'
'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.
'
'    You should have received a copy of the GNU General Public License
'    along with this program; if not, write to the Free Software
'    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
'
'
'
' Import graphic from URL into the clipboard.
' Inspired from OOoForums Danny's code
Sub ImportGraphicIntoClipboard(cURL)

oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )

' Import the graphic from URL into a new draw document.
Dim arg1(0) As New com.sun.star.beans.PropertyValue
arg1(0).Name = "Hidden"
arg1(0).Value = true
oDrawDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, arg1() )
oDrawDocCtrl = oDrawDoc.getCurrentController()

' Get the shape...
oDrawPage = oDrawDoc.DrawPages(0)
   oImportShape = oDrawPage(0)

' Get the dimension of the image...
oShapeSize = oImportShape.Size()

' Strange bug with the eps and emf format... correction of the size
if sFormat = "eps" then oShapeSize.Width = oShapeSize.Width * 0.99
if sFormat = "eps" then oShapeSize.Height = oShapeSize.Height * 0.91
if sFormat = "emf" then oShapeSize.Width = oShapeSize.Width * 1.13
if sFormat = "emf" then oShapeSize.Height = oShapeSize.Height * 1.1

' Copy the image to clipboard and close the draw document
oDrawDocCtrl.select(oImportShape)
Dim Array()
oDispatcher.executeDispatch( oDrawDocCtrl.Frame, ".uno:Copy", "", 0, Array() )
oDrawDoc.dispose()
End Sub
'###########################################################
Function ReadAttributes( oShape As Object ) As String
On Error Goto ErrorHandler
   oAttributes = oShape.UserDefinedAttributes()
   ReadAttributes = oAttributes.getByName("OOoLatexArgs").Value
   exit function
ErrorHandler:
ReadAttributes = ""
End Function
'###########################################################
Sub SetAttributes( oShape, iEqSize, sEqType, sCode)
'On Error Goto ErrorHandler
' ' Remove the attribute is one existes...
' oAttributes = oShape.UserDefinedAttributes()
' oAttributes.removeByName("OOoLatexArgs")
' oShape.UserDefinedAttributes() = oAttributes
'ErrorHandler:
' Add the Latex attribute to the image.
oAttributes = oShape.UserDefinedAttributes
   oLatexAttribute = createUnoStruct( "com.sun.star.xml.AttributeData" )
  oLatexAttribute.Type = "CDATA"      
   oLatexAttribute.Value = iEqSize & "§" & sEqType & "§" & sCode
   oAttributes.insertByName("OOoLatexArgs", oLatexAttribute )
oShape.UserDefinedAttributes = oAttributes
End sub

'###########################################################
' Get the bounding box information for inline equation
' The base line in not necessary at the bottom of the image.
Function bbox(BaseLine as Double) as Double
Dim sbbox() as String
Dim bby1,bby2 as Double
iNumber = Freefile
sLines = ""
Open sTmpPath & "tmpfile.bbx" For Input As iNumber
Line Input #iNumber, sLine
If sLine <> "" then sbbox() = Split(sLine," ")
Close #iNumber
bby1 = CDbl(sbbox(1))
bby2 = CDbl(sbbox(3))
bbox = (bby2-BaseLine)/(bby2-bby1)
End Function

'###########################################################
' Get the cropping information from bbox
Function getCropping()
Dim sbbox() as String
Dim bbx1,bbx2,hbbx1,hbbx2 as Double
iNumber = Freefile
Open sTmpPath & "tmpfile.bbx" For Input As iNumber
Line Input #iNumber, sLine
If sLine <> "" then sbbox() = Split(sLine," ")
Close #iNumber
bbx1 = CDbl(sbbox(0))
bbx2 = CDbl(sbbox(2))
hbbx1 = CDbl2(sbbox(4)) - 0.5 'remove 1/2 point to the left
hbbx2 = CDbl2(sbbox(6)) + 0.75 'add 3/4 point to the right

oCrop = createUnoStruct( "com.sun.star.text.GraphicCrop" )
   oCrop.Left = (hbbx1-bbx1)/(bbx2-bbx1) * oShapeSize.Width
   oCrop.Right = (bbx2-hbbx2)/(bbx2-bbx1) * oShapeSize.Width
getCropping = oCrop

End Function
'###########################################################
'to avoid problem with point or virgule : (x)xx.xx or (x)xx,xx
Function CDbl2( s as string) as double
if Mid(s,3,1) = "." then i=3
if Mid(s,4,1) = "." then i=4
CDbl2 = CDbl(Mid(s,1,i-1)+Mid(s,i+1,2))/100
end function

'###########################################################
' Display file on screen from temp directory
Sub PrintFile(sFile as String)
if not FileExists(sTmpPath & sFile) then
Msgbox "Error : the file " & TmpPath & sFile & " doesn't exist..."
exit sub
end if
iNumber = Freefile
Open sTmpPath & sFile For Input As iNumber
While not eof(iNumber)
  Line Input #iNumber, sLine
sMsg = sMsg & sLine & chr(10)
wend
Close #iNumber
Msgbox  sMsg
End sub

'###########################################################
' Convert decimal into two digits hexadecimal number as String
Function Hex2( Value as Integer) as String
if Value = 0 then
Hex2="00"
Exit Function
end if
Hex2 = Hex( Value )
if Len( Hex2 ) = 1 then Hex2 = "0"& Hex2
End Function

'###########################################################
' This macro is used when buttons Apply or Save are pushed from
' Config or from preamble dialog...
sub FinishApply()
if SettingEmbed = 1 then
SettingDoc( "Save" )
SystemLog = "New settings applied and embedded into document ... "
else
SystemLog = "New settings applied ... "
end if
end sub
'###########################################################
' Add a slash if necessary
Function CheckPath( sPath as String) as String
If Right(sPath,1) = "/" then
CheckPath = sPath
else
CheckPath = sPath & "/"
end if
end Function

'###########################################################
' Check the existance of the file...
Function CheckFile( sUrl as String, ErrorMsg as String) As Boolean
' Test the existance of the OOoLatex script ...
if FileExists(sUrl) then
CheckFile = False
else
if ErrorMsg = "OOoLatex" then _
ErrorMsg = "Cannot find " & sUrl & chr(10) & "Check your installation..."
Msgbox ErrorMsg
CheckFile = True
end if
End Function
'###########################################################
' Return true if string "s" doesn't contains "c"
Function StringNotContains( s as String, c as String ) as Boolean
StringNotContains = true
If (Len(s) <> 0) then
For j = 1 to Len(s)
if Mid(s,j,1) = c then
StringNotContains = false
Exit For
End if
Next
end if
End Function

'###########################################################
' Function to manipulate information from "Doc Properties".
' There is two actions :
' "Get" : return the preamble or the configuration as string
' "Delete" : return the "doc info" without preamble or configuration
Function DocInfo( sAction as String, sWhat as String) as String
DocInfo = ""
oDocInfo = StarDesktop.CurrentComponent.getDocumentInfo()
sDocDesc =  oDocInfo.Description

if sWhat = "DocInfo" then
DocInfo = sDocDesc
Exit Function
end if

' Exit If only one line exit !
If StringNotContains(sDocDesc,chr(10)) then exit Function

if sWhat = "Preamble" then sStart = "%%% OOoLatex Preamble %%%%%%%%%%%%%%"
   if sWhat = "Preamble" then sEnd = "%%% End OOoLatex Preamble %%%%%%%%%%%%"
   if sWhat = "Config" then sStart = "%%% OOoLatex Configuration %%%%%%%%%%%%"
   if sWhat = "Config" then sEnd = "%%% End OOoLatex Configuration %%%%%%%%%%"

SplitDocDesc() = Split(sDocDesc,chr(10))
ii = 0
startLine = -1
endLine = -1
For i = 0 to 1024
If SplitDocDesc(i) = sStart then
startLine = i
elseif SplitDocDesc(i) = sEnd then
endLine = i
end if
ii = ii + 1 + Len(SplitDocDesc(i))
If Len(sDocDesc) < ii  then Exit For
Next
lastLine = i
'Print sWhat & " " & sAction & ", startLine = " & startLine & ",  endLine = " & endLine & ", LastLine = " & lastLine
If (startLine <> -1) and (endLine <> -1) and (endLine > startLine) then
if sAction = "Get" then
For i = startLine +1 to endLine - 1
DocInfo = DocInfo & chr(10) & SplitDocDesc(i)
Next
elseif sAction = "Delete" then
For i = 0 to startLine - 1
DocInfo = DocInfo & chr(10) & SplitDocDesc(i)
Next
For i = endLine + 1 to LastLine
DocInfo = DocInfo & chr(10) & SplitDocDesc(i)
Next
end if
elseif  (startLine = 0) and (endLine = 0) and sAction = "Delete" then
DocInfo = sDocDesc
end if
If sWhat = "Preamble" and Mid(DocInfo,1,1) = chr(10) then DocInfo = Mid(DocInfo,2,Len(DocInfo))
End Function

'*** Get access to the repository !
Function GetConfigAccess(ByVal cNodePath As String,_
ByVal bWriteAccess As Boolean,_
Optional bEnableSync,_
Optional bLazyWrite ) As Object

If IsMissing( bEnableSync ) Then bEnableSync = True
If IsMissing( bLazyWrite )  Then bLazyWrite = False

oConfigProvider = GetProcessServiceManager().createInstanceWithArguments(_
"com.sun.star.configuration.ConfigurationProvider",_
Array( MakePropertyValue( "enableasync", bEnableSync ) ) )

If bWriteAccess Then
cServiceName = "com.sun.star.configuration.ConfigurationUpdateAccess"
Else
cServiceName = "com.sun.star.configuration.ConfigurationAccess"
EndIf

oConfigAccess = oConfigProvider.createInstanceWithArguments(_
cServiceName,_
      Array(  MakePropertyValue( "nodepath",  cNodePath  ),_
MakePropertyValue( "lazywrite", bLazyWrite ) ) )

GetConfigAccess = oConfigAccess
End Function

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )

If Not IsMissing( cName )  Then oPropertyValue.Name  = cName
If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue
MakePropertyValue() = oPropertyValue
End Function

'*** Generate path for MinSYS as "/C/path_to_file/"
Function WinPath(sPath as String) as String
sPath = ConvertToURL(sPath)
WinPath = "/" & mid(sPath,9,1) & join(split(mid(sPath,11),"%20")," ")
End function