| View previous topic :: View next topic |
| Author |
Message |
John_Hall General User

Joined: 01 Jan 2004 Posts: 10
|
Posted: Mon Feb 02, 2004 7:14 pm Post subject: How to read RasterResolutionX etc? |
|
|
I'm writing a macro in Basic, and it needs to find the settings for the Grid in a Draw document. I have determined (I think) that the properties I need are
RasterResolutionX
RasterResolutionY
RasterSubdivisionX
RasterSubdivisionX
and they exist in either Settings or DocumentSettings.
But I can't find how to reach them. Can someone help, please?
BTW it would be more helpful if these property names had an obvious connection with the Grid, but I found them after only about four hours searching.
NB I determine the page margins (which I also need) with:-
'Get size of Left & Top Margins
If Not IsNull(oDoc.DrawPages(0).BorderLeft) Then
LeftMargin = oDoc.DrawPages(0).BorderLeft
Else
LeftMargin = 296 'Hard-wired default value - varies by printer
End If
If Not IsNull(oDoc.DrawPages(0).BorderTop) Then
TopMargin = oDoc.DrawPages(0).BorderTop
Else
TopMargin = 296 'Hard-wired default value - varies by printer
End If |
|
| Back to top |
|
 |
John_Hall General User

Joined: 01 Jan 2004 Posts: 10
|
Posted: Tue Feb 03, 2004 3:56 am Post subject: More info about Grid parameters |
|
|
I unzipped my document file and looked in settings.xml,
and I find the following:-
view-settings
..views
....GridCoarseWidth
....GridCoarseHeight
....GridFineWidth....
....GridFineHeight
along with the values that are set in the document.
So it appears this is where they are stored.
But I still can't see how to read them in a Basic macro. |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Feb 03, 2004 9:08 am Post subject: |
|
|
The four properties you mention
RasterResolutionX
RasterResolutionY
RasterSubdivisionX
RasterSubdivisionX
seem to only apply to a spreadsheet document. Looking in the API reference, in the Index, under the letter R...
http://api.openoffice.org/docs/common/ref/index-files/index-18.html
and then scrolling down the page to RasterResolutionX, shows that this property belongs to com.sun.star.sheet.DocumentSettings.
I can find nothing in the API that allows you to manipulate the grid of a drawing window.
Any API that would affect the grid would naturally appear in the DrawingDocumentView service
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/DrawingDocumentDrawView.html
which is what you get when you call getCurrentController() from the document model.
A drawing can have multiple windows (i.e. controllers, each with a frame) open. With a drawing open, pick Window ---> New Window. You get a second Controller (with associated frame). The Grid can be viewed independantly on these two windows of the same drawing. The two windows (i.e. controllers w/frames) can independantly be showing different draw pages, with or without the grid, layer mode, or master page mode. The API on the controller (DrawingDocumentView linked above) does allow you to programmatically put a view into layer mode, master page mode, manipulate that view's selection, resize or reshape the window, change the title bar of the window, switch which drawing page is selected, and other things. But no API I can find to manipulate the grid, or whether or not the grid is displayed. This might be a feature request to add to the API for the DrawingDocumentView service.
As for the page properties, BorderLeft, etc. I just access these without testing them for Null. Every DrawPage is documented
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/DrawPage.html
to be a GenericDrawPage
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/GenericDrawPage.html
which has these properties. I have never had it fail. Not every implementation of a GenericDrawPage service will necessarily have these properties, (for instance, a GenericDrawPage from a spreadsheet might not, as a hypothetical example) but every page of a DrawingDocument seems to have them every time. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
John_Hall General User

Joined: 01 Jan 2004 Posts: 10
|
Posted: Tue Feb 03, 2004 9:44 am Post subject: |
|
|
Thanks for your response, Danny. I'll dig deeper into the docs.
I can do without the Grid specs for this project, only the Borders aka margins are critical.
What I'm doing is a macro to align Draw objects with the grid.
On one computer they rarely snap-to-grid when moved, on my other computer they often will, but not always. I can't determine why not, so decided to write this macro to align them. It's working well, I'm just making it more generalised.
BTW since writing the macro, objects tend to snap-to-grid more frequently (without running the macro) - just general cussedness I suppose. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|