@@ -36,7 +36,6 @@ Sub OOoLilyPond()
36
36
Dim oDoc As Object
37
37
Dim oDocCtrl As Object
38
38
Dim bWrongDocumentType As Boolean
39
- Dim oShape As Object
40
39
41
40
oMessages = CreateUnoService (" com.sun.star.beans.PropertyBag" )
42
41
@@ -123,6 +122,26 @@ Sub OOoLilyPond()
123
122
bUseDefaultCustom1 = True
124
123
bUseDefaultCustom2 = True
125
124
125
+ If Not ReadSelectionObject () Then Exit Sub ' create Cursor and read Attributes if Object is selected
126
+
127
+ ' Now we know which template to use
128
+ ReadTemplate()
129
+
130
+ ' Open the dialog box
131
+ EditorDialog()
132
+ End Sub
133
+
134
+
135
+ Function ReadSelectionObject () As Boolean
136
+
137
+ Dim oDoc As Object
138
+ Dim oDocCtrl As Object
139
+ Dim oShape As Object
140
+
141
+ ' Get the current document and controller
142
+ oDoc = ThisComponent
143
+ oDocCtrl = oDoc.getCurrentController()
144
+
126
145
' create Cursor and read Attributes if Object is selected
127
146
If Not IsEmpty(oDocCtrl.getSelection) Then ' Is only empty in Impress or Draw when nothing is selected
128
147
oSelection=oDocCtrl.getSelection
@@ -134,16 +153,25 @@ Sub OOoLilyPond()
134
153
oShape = oSelection.getByIndex(0)
135
154
If bInWriter Then ' OLy < 0.4 in Writer
136
155
' oCursor = oDoc.Text.createTextCursorByRange(oSelection(0).getAnchor())
137
- If Not ReadAttributes(oShape) Then Exit Sub ' Read the OLy fields from the Object Attributes
156
+ If Not ReadAttributes(oShape) Then ' Read the OLy fields from the Object Attributes
157
+ ReadSelectionObject = False
158
+ Exit Function
159
+ End If
138
160
' oSelection(0).getParent().remove(oSelection(0)) ' Delete old OLyObject
139
161
Else ' OLy object in Draw / Impress
140
- If Not ReadAttributes(oShape) Then Exit Sub ' Read the OLy fields from the Object Attributes
162
+ If Not ReadAttributes(oShape) Then ' Read the OLy fields from the Object Attributes
163
+ ReadSelectionObject = False
164
+ Exit Function
165
+ End If
141
166
End If
142
167
oShapePosition = oShape.position()
143
168
bShapeIsSelected = True
144
169
145
170
Case " SwXTextGraphicObject" ' Graphic is selected in Writer
146
- If Not ReadAttributes(oSelection) Then Exit Sub ' Read the OLy fields from the Object Attributes
171
+ If Not ReadAttributes(oSelection) Then ' Read the OLy fields from the Object Attributes
172
+ ReadSelectionObject = False
173
+ Exit Function
174
+ End If
147
175
bShapeIsSelected = True
148
176
149
177
Case " SwXTextRanges" ' Nothing or normal text selection in Writer
@@ -152,18 +180,13 @@ Sub OOoLilyPond()
152
180
Case Else
153
181
' Msgbox (" The selected object is not an OLy object ..." , 0, " Error" )
154
182
Msgbox (oMessages.getPropertyValue (" sMsgNoOlyObject" ), iMsgBox_E, oMessages.getPropertyValue (" sCaptionError" ))
155
- Exit Sub
183
+ ReadSelectionObject = False
184
+ Exit Function
156
185
157
186
End Select
158
187
End If
159
-
160
-
161
- ' Now we know which template to use
162
- ReadTemplate()
163
-
164
- ' Open the dialog box
165
- EditorDialog()
166
- End Sub
188
+ ReadSelectionObject = True
189
+ End Function
167
190
168
191
169
192
sub Make()
@@ -242,6 +265,7 @@ sub Make()
242
265
243
266
' If there were errors or warnings
244
267
If iNErr > = 1 And Not bIgnoreWarnings Then
268
+ ReadSelectionObject ()
245
269
iErrNum = 1
246
270
DisplayError()
247
271
Exit Sub
0 commit comments