A Writer document has one DrawPage. You can enumerate the objects inserted into the DrawPage, among them those creatable with the help of the drawing tools, and make distinctions based on some property. All the “draw objects” should support the service “com.sun.star.drawing.Shape” I suppose. (The SupportsService function is case sensitive!)
A raw sketch:
Sub clearDrawPageFromShapes
theDrawPage = ThisComponent.DrawPage
theEnum = theDrawPage.CreateEnumeration
Do While theEnum.HasMoreElements
theElement = theEnum.NextElement
If theElement.SupportsService("com.sun.star.drawing.Shape") Then
theElement.Dispose
End If
Loop
End Sub