graphicCrop doesn't seem to work

I load an image into Calc, and I can change several properties with a macro:

			If Brightness <> 0 Then objImage.AdjustLuminance = Brightness
			If Contrast <> 0 Then objImage.AdjustContrast = Contrast
			If Gamma <> 0 Then objImage.Gamma = Gamma
			If ColorMode = "C" Then
				objImage.GraphicColorMode = com.sun.star.drawing.ColorMode.STANDARD
			End If

However, adding code like:
objImage.GraphicCrop.Left = 500

does nothing.

An I missing something, or does this call not work in Calc?

We extract written data from scanned images, and sometimes it would make our lives easier if we could crop each image a set amount as it’s loaded. I could do it using a call in the macro to a program like ImageMagick, but there are issues with that.

I didn’t check specifically this property, but with many properties, when you write something like

obj.Propname

the property getter gives you not a reference to the object’s “internal data”, but a copy. So modifying its members operates on a temporary, not on original object.

Test doing it like

oCrop = objImage.GraphicCrop
oCrop.Left = 500
objImage.GraphicCrop = oCrop

This way, the last line calls object’s setter of the property.

Thank you, thank you, thank you, Mike! That works. At first I wasn’t sure it worked, 500 made a very small difference in the image’s position, but when I used 10000 I could see that was indeed the solution.