|
ツール 
ウィンドウを作成するときに楽するための関数など。
OOo Basic 
ウィンドウ作成 
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| | Function CreateNewWindow( _
oToolkit,oParent,nType,sType,nAttr,_
nX,nY,nWidth,nHeight) As Object
aRect = CreateUnoStruct("com.sun.star.awt.Rectangle")
With aRect
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
aWinDesc = CreateUnoStruct("com.sun.star.awt.WindowDescriptor")
With aWinDesc
.Type = nType'com.sun.star.awt.WindowClass.TOP
.WindowServiceName = sType
.ParentIndex = -1
.Bounds = aRect
.Parent = oParent
.WindowAttributes = nAttr
End With
CreateNewWindow = oToolkit.createWindow(aWinDesc)
End Function
|
コントロール作成 
0
1
2
3
4
5
6
7
8
9
10
11
| | Function CreateCtr( CtrType, nX, nY, nWidth, nHeight, sNames, vProps )
Dim oCtr As Object, oCtrModel As Object
oCtr = createUnoService("com.sun.star.awt.UnoControl" & CtrType )
oCtrModel = createUnoService("com.sun.star.awt.UnoControl" & CtrType & "Model" )
oCtrModel.setPropertyValues( sNames, vProps )
With oCtr
.setModel( oCtrModel )
.setPosSize( nX, nY, nWidth, nHeight, _
com.sun.star.awt.PosSize.POSSIZE )
End With
CreateCtr() = oCtr 'model can be got from returned value
End Function
|
Python 
ダイアログ -> ウィンドウ変換 
ダイアログからウィンドウを作成するコードを生成する Python マクロ。
dlg2win_py.py
- ダイアログの URL: vnd.sun.star.script:LIB_NAME.DIALG_NAME?location=application
- アプリケーションダイアログライブラリしか対応していません
- 親ウィンドウなどの取得の部分は自分で記述してください
- ウィンドウを作成する時の WindowAttributes は作成するウィンドウに応じて変更してください
- 下記のウィンドウ作成およびコントロール作成の関数を利用します
ウィンドウ作成 
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| | import uno
from com.sun.star.awt.WindowClass import SIMPLE as WC_SIMPLE
def createWindow(toolkit,parent,service,attr,nX,nY,nWidth,nHeight):
d = uno.createUnoStruct("com.sun.star.awt.WindowDescriptor")
d.Type = WC_SIMPLE
d.WindowServiceName = service
d.ParentIndex = -1
d.Bounds = createRect(nX,nY,nWidth,nHeight)
d.Parent = parent
d.WindowAttributes = attr
return toolkit.createWindow(d)
def createRect(x,y,width,height):
aRect = uno.createUnoStruct("com.sun.star.awt.Rectangle")
aRect.X = x
aRect.Y = y
aRect.Width = width
aRect.Height = height
return aRect
|
使い方
subwin = createWindow(
toolkit,
parent,
"modaldialog",
WA_SHOW + WA_BORDER + WA_MOVEABLE + WA_CLOSEABLE,
100,100,300,200)
コントロール作成 
0
1
2
3
4
5
6
7
8
9
10
11
| | from com.sun.star.awt.PosSize import POSSIZE as PS_POSSIZE
# create control by its type with property values
def createControl(smgr,ctx,ctype,x,y,width,height,names,values):
ctrl = smgr.createInstanceWithContext(
"com.sun.star.awt.UnoControl%s" % ctype,ctx)
ctrl_model = smgr.createInstanceWithContext(
"com.sun.star.awt.UnoControl%sModel" % ctype,ctx)
ctrl_model.setPropertyValues(names,values)
ctrl.setModel(ctrl_model)
ctrl.setPosSize(x,y,width,height,PS_POSSIZE)
return ctrl
|
使い方
edit1 = createControl(
smgr,ctx,
"Edit",
0,0,300,99,
("AutoVScroll","MultiLine",),
(True,True,))
|