CustomShape Type ..inspect xRay How to?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
richard_jazz
Posts: 3
Joined: Thu Apr 12, 2012 7:22 pm

CustomShape Type ..inspect xRay How to?

Post by richard_jazz »

given a previous post “draw- basic shapes” quote “The shapeGeometry.Value is the type of CustomShape. To see what these are, it is probably easiest to draw one manually and inspect it with MRI or xRay, as It isn't always obvious. For example, for a decision shape, the CustomShapeGeometry type is "diamond." .. Ive installed the macro xray drawn a shape I.e 5 star pointed . In the shape Marco ive called the xray sub which contains “Xray ThisComponent” and indeed when compiled and clicked over said shape the xray window comes up ...with with loads of information .. given all this info in xray where do you find the drawn shape .. CustomShape Type.. or is this the wrong way of gong about inspecting the shape for its type.

Thanks .
openoffice 3 windowsxp
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: CustomShape Type ..inspect xRay How to?

Post by Charlie Young »

richard_jazz wrote:given a previous post “draw- basic shapes” quote “The shapeGeometry.Value is the type of CustomShape. To see what these are, it is probably easiest to draw one manually and inspect it with MRI or xRay, as It isn't always obvious. For example, for a decision shape, the CustomShapeGeometry type is "diamond." .. Ive installed the macro xray drawn a shape I.e 5 star pointed . In the shape Marco ive called the xray sub which contains “Xray ThisComponent” and indeed when compiled and clicked over said shape the xray window comes up ...with with loads of information .. given all this info in xray where do you find the drawn shape .. CustomShape Type.. or is this the wrong way of gong about inspecting the shape for its type.

Thanks .
Sorry, actually MRI is more convenient for this, but XRay works fine with a little coaxing, and maybe Bernard (or someone) has further tips.

Select the shape, then run this macro:

Code: Select all

sub XRaySelectedCustomShape
	Dim Doc As Object
	
	Doc = ThisComponent
			
	Globalscope.BasicLibraries.LoadLibrary( "XrayTool" )
			
	XRay Doc.CurrentSelection.getByIndex(0).CustomShapeGeometry(0).Value
End Sub
This will fail if something other than a custom shape is selected.

And as long as we're doing macros, we could also skip the object inspector:

Code: Select all

sub ShowSelectedCustomShapeType
	Dim Doc As Object
	
	Doc = ThisComponent
			
	MsgBox Doc.CurrentSelection.getByIndex(0).CustomShapeGeometry(0).Value
End Sub

Apache OpenOffice 4.1.1
Windows XP
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: CustomShape Type ..inspect xRay How to?

Post by Charlie Young »

I noticed a problem with the macros posted above, namely that the Type property isn't necessarily at index 0.

This fixes that problem, and does some other checking of the current selection:

Code: Select all

sub ShowCustomShapeType
	Dim Doc As Object
	Dim Sel As Object
	Dim geo
	Dim prop As new com.sun.star.beans.PropertyValue
	Dim i As Long
	
	Doc = ThisComponent
	Sel = Doc.CurrentSelection
	if Sel.supportsService("com.sun.star.drawing.ShapeCollection") then	
		if Sel.getByIndex(0).supportsService("com.sun.star.drawing.CustomShape") then
			geo = Sel.getByIndex(0).CustomShapeGeometry
			i = 0
			do
				prop = geo(i)
				i = i + 1
			loop until prop.Name = "Type"
			MsgBox(prop.Value)
		else
			MsgBox("Custom Shape not selected")
		endif
	else
		MsgBox("Custom Shape not selected")
	endif
End sub

Apache OpenOffice 4.1.1
Windows XP
Post Reply