Skip to content

Commit aeb1c28

Browse files
authored
Merge pull request #25 from edgar79/relativeIncludes
Added function GetRelativeIncludeStatement
2 parents b4b6497 + 2a422c1 commit aeb1c28

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

extension/OOoLilyPond/LilyPond.xba

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,45 @@
44

55
Option Explicit
66

7+
8+
'Returns the include statement with the absolute path of the LO-file
9+
'Returns an empty String if the file is not yet saved
10+
Function GetRelativeIncludeStatement As String
11+
Dim sURL
12+
Dim sParts
13+
Dim sPath
14+
15+
sURL=ThisComponent.getURL()
16+
If Len(sURL) > 0 And Not IsNull(sURL) Then
17+
sParts=Split(sURL,"/")
18+
ReDim Preserve sParts(0 to UBound(sParts) -1)
19+
sPath=ConvertFromURL(Join(sParts,"/"))
20+
While InStr (sPath, "\") > 0 ' replace "\" by "/", even in Windows LilyPond expects paths to be written with forward slashes
21+
Mid (sPath, InStr (sPath, "\"), 1, "/")
22+
Wend
23+
GetRelativeIncludeStatement="-I" & Chr(34) & sPath & Chr(34)
24+
Else
25+
GetRelativeIncludeStatement=""
26+
End If
27+
End Function
28+
29+
730
Function CallLilyPond() As Boolean
831
Dim sCommand As String
932
Dim sBackendOpt As String
1033
Dim sLilyPondOutput As String
1134

35+
Dim sRelativeIncludeStatement As String
36+
sRelativeIncludeStatement=GetRelativeIncludeStatement()
37+
38+
If Len(sRelativeIncludeStatement) > 0 Then
39+
If Len(sIncludeStatement) > 0 Then
40+
sIncludeStatement=sRelativeIncludeStatement & " " & sIncludeStatement
41+
Else
42+
sIncludeStatement=sRelativeIncludeStatement
43+
End If
44+
End If
45+
1246
sBackendOpt="-dbackend=eps"
1347
If Val(sLilyPondVersionMajor)=2 and Val(sLilyPondVersionMinor)<=10 Then
1448
sBackendOpt="-b eps"

0 commit comments

Comments
 (0)