Michael,
This is a very interesting question and I spent an hour or
so and was
not able to solve the problem.
I am copying the dev mailing list to see if there are any
clues there:
The problem:
Assume a draw document with a single shape selected.
I want to delete the single shape.
The code shown below obtains a reference to the selected
shape from the
current controller (because it is selected).
So, if I have a reference to a shape that is inserted into a
draw page,
how can I delete it?
I tried oShape.Dispose(), which crashed OOo.
I tried oShape.getParent().Remove(oShape), which crashed
OOo.
Original code:
Sub Main
Dim oShapeName as String
Dim oDoc As Object
oDoc = ThisComponent
oDocCtrl = oDoc.getCurrentController()
' See what is currently selected.
oSelection = oDocCtrl.getSelection()
If IsEmpty( oSelection ) Then
MsgBox( "Zum Löschen muss eine Grafik makiert
sein" )
Exit Sub
EndIf
If oSelection.getCount() > 1 Then
MsgBox( "Bitte nur eine Grafik zum löschen
auswählen" )
Exit Sub
EndIf
oOrigShape = oSelection.getByIndex( 0 )
oShapeName = oOrigShape.getName()
print oShapeName
REM The Delete Function doesn't work
'oDoc.Remove(oOrigShape)
End Sub
Nice to hear from you again....
I am overly busy (nothing new there), but I will take a
quick look.
Michael Simader wrote:
> Hi Andrew!
>
> How are you? Hope you are find.
> I think you know me, because you helped me with my
macro for inserting
> a costum shape. It is working great and i updated the
macro with a
> database and i am so proud of it. But now to the
problem: If i insert
> a graphic in the draw document i make a entry in my
database, but the
> problem is, if i delete a shape, i cant remove the
database row. So i
> wrote a macro, where i can select a single shape and
get the name of
> the shape (for deleting the database row), but the
problem is, i can't
> remove the shape from the document. Do you know the
methode for
> removing graphics?
Remove a graphic from a Draw document. Did you know that I
cover this in
my published book? Did you know that the Draw and Impress
chapter are
available as a free download from the publisher?
> here is the macro which i want to use for deleting:
>
> Sub Main
>
> Dim oShapeName as String
> Dim oDoc As Object
>
> oDoc = ThisComponent
>
> oDocCtrl = oDoc.getCurrentController()
>
> ' See what is currently selected.
> oSelection = oDocCtrl.getSelection()
> If IsEmpty( oSelection ) Then
> MsgBox( "Zum Löschen muss eine Grafik
makiert sein" )
> Exit Sub
> EndIf
> If oSelection.getCount() > 1 Then
> MsgBox( "Bitte nur eine Grafik zum löschen
auswählen" )
> Exit Sub
> EndIf
>
> oOrigShape = oSelection.getByIndex( 0 )
> oShapeName = oOrigShape.getName()
>
> print oShapeName
>
> REM The Delete Function doesn't work
> oDoc.Remove(oOrigShape)
>
> End Sub
Yeah, I do not expect you to be able to remove a shape this
way.
>
> best regards!
> Your Michael
>
>
____________________________________________________________
_____
> Sie möchten Teil der Evolution der Kommunikation
werden?
> http://www
.communicationevolved.com/de-at/
>
--
Andrew Pitonyak
My Macro Document: http://www.pi
tonyak.org/AndrewMacro.odt
My Book: http://w
ww.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.or
g/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|