Writer: get current zoom value (for ENTIRE_PAGE zoom type) with C++

Hi,

is it possible to read the current zoom value if the zoom type is set to ENTIRE_PAGE?
If so, how would I achieve this with C++?

I want to know the value because setting the zoom to 125% or 85% and then back to 100% yields a different zoom than ENTIRE_PAGE does.

Hi - Below a Basic example.

Sub PysDisplayZoom

dim sMsg as string

with thiscomponent.currentcontroller.ViewSettings
	select case .ZoomType
		case com.sun.star.view.DocumentZoomType.OPTIMAL
			sMsg = "OPTIMAL"
		case com.sun.star.view.DocumentZoomType.PAGE_WIDTH
			sMsg = "PAGE_WIDTH"
		case com.sun.star.view.DocumentZoomType.ENTIRE_PAGE
			sMsg = "ENTIRE_PAGE"
		case com.sun.star.view.DocumentZoomType.BY_VALUE
			sMsg = "BY_VALUE"
		case com.sun.star.view.DocumentZoomType.PAGE_WIDTH_EXACT
			sMsg = "PAGE_WIDTH_EXACT"
	end select
	msgbox sMsg & chr(13) & " Value: " & .ZoomValue
end with
End Sub

HTH - Regards

Any idea how I could translate accessing the ViewSettings into C++? I have the current controller as an XController interface…

Unfortunately no. I guess you already looked here ?

Yes, the only thing I have found so far is that ViewSettings returns an Any, which does not really implement any interface. That’s not really documented :\

This works, but not directly after setting the zoom to ENTIRE_PAGE on load (assuming that xControlleris the XControllerfor the current XModel):

Reference< XViewSettingsSupplier  > XViewSettingsSupplier(xController, UNO_QUERY);
Reference< XPropertySet  > viewprops = XViewSettingsSupplier->getViewSettings();
Any anyZoomValue = viewprops->getPropertyValue(OUString::createFromAscii("ZoomValue"));
sal_Int16 actualZoomValue = 0;
anyZoomValue >>= actualZoomValue;