[Solved] Correct steps to change format setting Writer
Posted: Mon Oct 02, 2017 9:39 am
Hi all,
In Xray I can see that all setting(TabStops, Pageformat, Margin and font setting) are set in the way I ordered.
But except the changes in the cursor, nothing changes in the document on the screen.
I think a change properties on the wrong place, in the wrong order and they do not work together.
How to make them work?
Here is my code:
Kind regards,
Jan Flikweert
In Xray I can see that all setting(TabStops, Pageformat, Margin and font setting) are set in the way I ordered.
But except the changes in the cursor, nothing changes in the document on the screen.
I think a change properties on the wrong place, in the wrong order and they do not work together.
How to make them work?
Here is my code:
Code: Select all
*******************Declaratie variabelen************************
*1. Declaration vaiables
PUBLIC loOfcMgr, loDesktop, loCoreReflection,loDocument,loCursor,loText,loPropertyValue,oStyle,oPageStyle,loPgsz
PUBLIC args(1),tbstps(3),tbstp
***************Maakt Office manager loOfcMgr aan. Deze is public.*********************
*2. Create ServiceManager
LoOfcMgr=CREATEOBJECT("Empty")
COMARRAY(loOfcMgr,10)
Thisformset.Baseform12.Lofuncties1.ooogetservicemanager
************************Maakt Desktop aan.********************
*3. Create Desktop
LoDesktop=CREATEOBJECT("Empty")
COMARRAY(loDesktop,10)
Thisformset.Baseform12.Lofuncties1.ooogetdesktop
**********************Document aanmaken en de args daar voor***********************
*4. Create empty text document
loCoreReflection=CREATEOBJECT("Empty")
COMARRAY(loCoreReflection,10)
loCoreReflection = loOfcMgr.createInstance("com.sun.star.reflection.CoreReflection" )
loDocument=CREATEOBJECT("Empty")
COMARRAY(loDocument,10)
loPropertyValue = CREATEOBJECT("Empty")
loCoreReflection.forName( "com.sun.star.beans.PropertyValue").createobject(@loPropertyValue)
args(1)=loPropertyValue
args(1).name="ReadOnly"
args(1).value=.f.
*fnm="file:///"+STRTRAN(thuispad, "\","/")+"/LIBRARY/Default_A5.ott"
loDocument = loDesktop.loadComponentFromURL("private:factory/swriter","Standaard", 0, @args)
**************************Einde aanmaken document********************************
*****************Nu de tabstops***********************************
*5. Create tabstops in scom.sun.star.tyle.Paragraph
oStyle=CREATEOBJECT("Empty")
COMARRAY(oStyle,10)
oStyle=loDocument.createInstance("com.sun.star.style.ParagraphStyle")
oStyle.name="Standaard"
oStyle.FollowStyle="Standaard"
oStyle.IsAutoUpdate=.t.
tbstps(1)=Thisform.lofuncties1.ooocreatestruct("com.sun.star.style.TabStop")
tbstps(2)=Thisform.lofuncties1.ooocreatestruct("com.sun.star.style.TabStop")
tbstps(3)=Thisform.lofuncties1.ooocreatestruct("com.sun.star.style.TabStop")
tbstp=tbstps(1)
WITH tbstp
.Alignment = 0
.DecimalChar = 44
.FillChar = 32
.Position = 500
ENDWITH
tbstps(1)=tbstp
tbstp=tbstps(2)
WITH tbstp
.Alignment = 0
.DecimalChar = 44
.FillChar = 32
.Position = 6250
ENDWITH
tbstps(2)=tbstp
tbstp=tbstps(3)
WITH tbstp
.Alignment = 0
.DecimalChar = 44
.FillChar = 32
.Position = 6750
ENDWITH
tbstps(3)=tbstp
oStyle.SetPropertyValue("ParaTabStops",@tbstps) &&Works
*Thisform.lofuncties1.call_xray(oStyle)
**********************Einde tabstops************************
***********************Marges********************
*6 Create margin in com.sun.star.style.PageStyle
oPageStyle=CREATEOBJECT("Empty")
COMARRAY(oPageStyle,10)
oPageStyle=loDocument.createInstance("com.sun.star.style.PageStyle")
oPageStyle.SetPropertyValue("TopMargin",1000)
oPageStyle.SetPropertyValue("BottomMargin",1500)
oPageStyle.SetPropertyValue("RightMargin",2000)
oPageStyle.SetPropertyValue("LeftMargin",1000)
***********************Einde marges**************************
**********************Pagina formaat**************************
*7 Create in com.sun.star.style.Pagestyle the page sizes using com.sun.star.awt.size
loPgsz=CREATEOBJECT("Empty")
COMARRAY(loPgsz,10)
loPgsz=Thisform.lofuncties1.ooocreatestruct("com.sun.star.awt.size")
loPgsz=oPageStyle.Size
loPgsz.Width=14800
loPgsz.Height=21000
oPageStyle.SetPropertyValue("Size",@loPgsz)
oPageStyle.SetPropertyValue("IsLandscape",.f.)
*******************************Eind pagina formaat***************************
*********************En de tekst.************************************
*8 Create Test object
loText=loDocument.getText() && Create text object
COMARRAY(loText,10)
**********************Einde tekst******************************************
************************** Cursor aanmaken***************************************
*9 Create cursor object
loCursor= loText.createTextCursor()
COMARRAY(loCursor,10)
*******************Einde cursor aanmaken*************************
************************************Instellinge cursor******************************
*10 Character setting in cursor
s
loCursor.SetPropertyValue("CharFontFamily",3)
loCursor.SetPropertyValue("CharFontName","Times New Roman")
loCursor.SetPropertyValue("CharHeight",10)
loCursor.SetPropertyValue("CharWeight",100)
***********************************Einde isntellinge cursor******************************
**************************Nu de tekst er in****************************************
*11 Put some text from object loTest in object lo cursor
loText.insertString(loCursor,"Le premier texte en france", .F.)
*************************Einde tekst er in
Jan Flikweert