Skip to content

Commit 4681907

Browse files
committed
Merge branch 'aoo'
2 parents 85a4456 + fb8b5d7 commit 4681907

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

extension/OOoLilyPond/LilyPond.xba

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ End Sub
190190
Function DeleteTempFilesOfType (sFileType As String) As Integer ' 0: success, 1: error
191191
Dim sDirEntry As String
192192
Dim sCurrentFile As String
193-
193+
194+
On Error GoTo ErrorHandler
194195
sDirEntry = Dir (sTmpPath & constOLyFileName & "*." & sFileType)
195196
Do While sDirEntry <> ""
196197
' If oFileAccess.exists (sTmpPath & sDirEntry) Then
@@ -230,11 +231,11 @@ Sub CleanUpAfterwards()
230231
Exit Sub
231232

232233
ErrorHandler:
233-
' If Err <> 1 Then
234+
If Err <> 1 Then
234235
MsgBox (Err & Chr(10) & Error, iMsgBox_E, oMessages.getPropertyValue ("sCaptionError"))
235-
' Else ' Error 1: "A file or directory could not be deleted"
236+
Else ' Error 1: "A file or directory could not be deleted"
236237
' Nothing. This can happen in old-fashioned OpenOffice if you use the "direct" method to insert images. Apparently, it works anyway, don't know why...
237-
' End If
238+
End If
238239
Resume Next
239240
End Sub
240241

extension/OOoLilyPond/OOoLilyPond.xba

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,14 @@ Sub InsertOOoLilyPondObjectViaClipboard (sIdentifier As String, sNumber As Strin
768768
oGraphic.TopMargin = 0
769769
oGraphic.BottomMargin = 0
770770
oGraphic.VertOrient = 0
771+
oGraphic.HoriOrient = com.sun.star.text.HoriOrientation.NONE
772+
if iAnchor = com.sun.star.text.TextContentAnchorType.AT_CHARACTER Then
773+
oGraphic.HoriOrientRelation = com.sun.star.text.RelOrientation.CHAR
774+
oGraphic.VertOrientRelation = com.sun.star.text.RelOrientation.CHAR
775+
Else
776+
oGraphic.HoriOrientRelation = com.sun.star.text.RelOrientation.PRINT_AREA
777+
oGraphic.HoriOrientRelation = com.sun.star.text.RelOrientation.PRINT_AREA
778+
End If
771779

772780
if bShapeIsSelected And (iAnchor = iOriginalAnchor) And Not IsNull (oShapePosition) Then oGraphic.position = oShapePosition
773781

@@ -824,10 +832,15 @@ Sub InsertOOoLilyPondObject (sIdentifier As String, sNumber As String, sAddition
824832
Else ' should never be the case
825833
oGraphic = ImportBitmapIntoWriter (ConvertToURL (sTmpPath & constOLyFileName & sNumber & sAddition & "." & sExtension), oCurrentGraphicObject(0), true)
826834
End If
835+
oGraphic.VertOrient = 0
827836
if bShapeIsSelected And (iAnchor = iOriginalAnchor) And Not IsNull (oShapePosition) Then
828837
oGraphic.HoriOrientPosition = oShapePosition.X
829838
oGraphic.VertOrientPosition = oShapePosition.Y
830-
oGraphic.AnchorPageNo = iAnchorPageNo
839+
If iAnchor = 2 Then ' AT_PAGE
840+
oGraphic.AnchorPageNo = iAnchorPageNo
841+
' OpenOffice was crashed by this when iAnchor was AS_CHARACTER
842+
' No problem with LibreOffice
843+
End If
831844
End If
832845

833846
Case "SwXTextGraphicObject" ' Graphic is selected in Writer
@@ -841,9 +854,11 @@ Sub InsertOOoLilyPondObject (sIdentifier As String, sNumber As String, sAddition
841854
oGraphic = ImportBitmapIntoWriter (ConvertToURL (sTmpPath & constOLyFileName & sNumber & sAddition & "." & sExtension), oCurrentGraphicObject, true)
842855
End If
843856
End If
857+
oGraphic.VertOrient = 0
844858

845859
Case "SwXTextRanges" ' Nothing or normal text selection in Writer
846860
oGraphic = ImportBitmapIntoWriter (ConvertToURL (sTmpPath & constOLyFileName & sNumber & sAddition & "." & sExtension), oCurrentCursor, false)
861+
oGraphic.VertOrient = 0
847862

848863
End Select
849864

@@ -853,7 +868,14 @@ Sub InsertOOoLilyPondObject (sIdentifier As String, sNumber As String, sAddition
853868

854869
oGraphic.TopMargin = 0
855870
oGraphic.BottomMargin = 0
856-
oGraphic.VertOrient = 0
871+
oGraphic.HoriOrient = com.sun.star.text.HoriOrientation.NONE
872+
if iAnchor = com.sun.star.text.TextContentAnchorType.AT_CHARACTER Then
873+
oGraphic.HoriOrientRelation = com.sun.star.text.RelOrientation.CHAR
874+
oGraphic.VertOrientRelation = com.sun.star.text.RelOrientation.CHAR
875+
Else
876+
oGraphic.HoriOrientRelation = com.sun.star.text.RelOrientation.PRINT_AREA
877+
oGraphic.HoriOrientRelation = com.sun.star.text.RelOrientation.PRINT_AREA
878+
End If
857879

858880
Else 'We are in Impress or Draw
859881

0 commit comments

Comments
 (0)