[Solved] Writer How to set Margins of a document?

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

[Solved] Writer How to set Margins of a document?

Post by jfpetit »

I create an OpenOffice document with Delphi.
My question is : How to set TopMargin, BottomMargin, LeftMargin, RightMargin of the document?
Thanks for help
Last edited by jfpetit on Tue Dec 11, 2012 3:28 pm, edited 1 time in total.
OpenOffice 3.4.1
Windows XP
User avatar
RoryOF
Moderator
Posts: 35210
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Writer How to set Margins of a document?

Post by RoryOF »

Best way is to /Format /Styles and Formatting, click on 4th icon from left, then right click on Page Style you wish to change and select Modify. On Page tab you can now set your Paper size and Margins. Note that, in spite of settings on Organiser tab, page styles are not hierarchical (i.e., are not interlinked so one depends on another).
 Edit: Reading your query again, I see that you wish to set the style from Delphi. You may need to inspect a file with some low level utility such as
MRI
or Xray
Xray
to find the parameters you need to set. 
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer How to set Margins of a document?

Post by jfpetit »

Thanks but i want to do that by programming in Delphi.
OpenOffice 3.4.1
Windows XP
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer How to set Margins of a document?

Post by jfpetit »

Thanks
But I don't find anything to set margins of document in the URL you give.
OpenOffice 3.4.1
Windows XP
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer How to set Margins of a document?

Post by jfpetit »

I found this in http://www.pitonyak.org/AndrewMacro.odt
Listing 5.32: Set the margins by modifying the text style.

Code: Select all

Sub Margins( )
  Dim oStyleFamilies, oFamilies, oPageStyles, oStyle
  Dim oVCurs, oPageStyleName
  Dim fromleft%, fromtop%, fromright%, frombottom%
  Dim oDoc
  oDoc = ThisComponent

  REM You don't need the view cursor, you can use any TextCursor 
  oVCurs = oDoc.CurrentController.getViewCursor() 
  oPageStyleName = oVCurs.PageStyleName
  oPageStyles = oDoc.StyleFamilies.getByName("PageStyles")
  oStyle  = oPageStyles.getByName(oPageStyleName)
  REM fromleft, fromtop, fromright, frombottom = whatever you want 
  oStyle.LeftMargin = fromleft
  oStyle.TopMargin = fromtop  
  oStyle.RightMargin = fromright
  oStyle.BottomMargin = frombottom
End Sub
Thanks to JohnSUN-Pensioner
OpenOffice 3.4.1
Windows XP
Post Reply