11/03/2011

calc python macro: print cell range

## set tmpRange => from (0, 0) to (5, 40)  <= (Col, Row)
tmpRange = oSheet.getCellRangeByPosition(0, 0, 8, 78)  

## oSheet1.setPrintAreas( Array() )
oSheet1.setPrintAreas( (tmpRange.RangeAddress, ) )

## set print margin

oFamilies = oDoc.getStyleFamilies()

oPageStyles = oFamilies.getByName("PageStyles") 

Style = oPageStyles.getByName(oSheet.PageStyle) 

Style.BackColor = &HCCCCFF 
Style.BottomMargin = 1000 
Style.TopMargin = 1000 
Style.LeftMargin = 1000 
Style.RightMargin = 500 

Style.PageScale = 77

Style.HeaderIsOn = False
Style.FooterIsOn = False

11/02/2011

python calc macro: create textbox (TextShape) on a sheet

oTextShape = oDoc.createInstance("com.sun.star.drawing.TextShape")  

oSheet.DrawPage.add(oTextShape)  

aa = oSheet.DrawPage.getByindex( n )   


## set string...  
aa.String = "babo hehe"   

## set Size...  
tmpSize = aa.getSize()  
tmpSize.Width = 9999  
aa.setSize(tmpSize)    

## set RotateAngle  
aa.RotateAngle = 9000  ## rotate 90 degree    

## paragraph adjust 
aa.ParaAdjust = 1  ## set right align 


4/08/2011

python-dialog example code..

python-dialog example code..

The usage is quite straightforward... very simple and easy to use.



import dialog
import time

d = dialog.Dialog()
d.setBackgroundTitle('what the hell')

## choice menu
aa = d.menu("asdf", choices=[('1', '1 means 1'), ('2', '2 means 2')])
print aa

## file or directory selection
aa = d.fselect("/home/junseok/", 10, 30)
print aa

## displaying a progress bar (gauge)
d.gauge_start('babo', percent=0)
for loopi in range(11):
d.gauge_update(loopi*10)
time.sleep(1)
d.gauge_stop()

2/18/2011

samba IP allow setting

samba IP allow setting

$ sudo vi /etc/samba/smb.conf

in [global] section, add this line

hosts allow = 192.168.0.11 192.168.0.12


$ sudo service smbd restart

1/14/2011

HOWTO sort sheets using python


import uno

def getReady():
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext )
ctx = resolver.resolve( "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
oDoc = desktop.getCurrentComponent()

return oDoc

oDoc = getReady()
oSheets = oDoc.getSheets()

## getting all sheet name
sheetNames = []
for loopi in range(oSheets.Count):
tmpSheet = oSheets.getByIndex(loopi)
sheetNames.append(tmpSheet.Name)

## get sorting
sheetNames.sort(reverse=True)

for tmpName in sheetNames :
oSheets.moveByName(tmpName, 0)