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

Java, C++, C#, Delphi, ??? - Using the UNO bridges

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

Postby jfpetit » Mon Dec 10, 2012 11:17 am

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
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer How to set Margins of a document?

Postby RoryOF » Mon Dec 10, 2012 11:24 am

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.7 on Xubuntu 18.04.4 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31232
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Writer How to set Margins of a document?

Postby jfpetit » Mon Dec 10, 2012 11:36 am

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?

Postby jfpetit » Mon Dec 10, 2012 11:46 am

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?

Postby jfpetit » Tue Dec 11, 2012 3:27 pm

I found this in http://www.pitonyak.org/AndrewMacro.odt
Listing 5.32: Set the margins by modifying the text style.
Code: Select all   Expand viewCollapse view
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
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests