create a new page, using OOoPython/WriterOverView as a template.
Front page
Search
掲示板
Reload
Help
Browse Log
掲示板の使い方
OOo 掲示板3
OOo 掲示板2
OOo 掲示板
掲示板
雑談掲示板
New
List of pages
Recent changes
Backup
簡単ヘルプ
整形ルール
Start:
* Python と Writer [#f2ef28d1]
Python で Writer ドキュメントを操作します。
#code(python){{
#!
# -*- coding: utf_8 -*-
from com.sun.star.beans import PropertyValue
from com.sun.star.table import TableBorder
from com.sun.star.text import TableColumnSeparator
from com.sun.star.text.HoriOrientation import NONE as HO_...
def writer_test():
doc = XSCRIPTCONTEXT.getDocument()
if doc.supportsService("com.sun.star.text.TextDocument"):
text = doc.getText()
#insert_heading1(text, u'見出しを入力')
# 見出しを作成
cursor = text.createTextCursorByRange(text.getStart())
cursor.setString(u'見出しを入力')
cursor.setPropertyValue(u'ParaStyleName', u'Heading 1')
insert_para(text, u'枠線のない表')
# 表を作成、挿入
table = doc.createInstance("com.sun.star.text.TextTable")
table.setName("NewTable")
table.initialize(3, 2)
text.insertTextContent(text.getEnd(),table,True)
# 表の枠線をなしに、幅などを変更
border = TableBorder()
border.IsTopLineValid = True
border.IsBottomLineValid = True
border.IsLeftLineValid = True
border.IsRightLineValid = True
border.IsHorizontalLineValid = True
border.IsVerticalLineValid = True
table.TableBorder = border
#table.Width = 12000
table.LeftMargin = 2000
table.RightMargin = 2000
table.HoriOrient = HO_NONE
t = TableColumnSeparator()
t.Position = 3000
t.IsVisible = True
table.TableColumnSeparators = t,
# 一度にセルにデータを入力
d = (
(u'項目', u'説明'),
(u'みかん', u'蜜柑'),
(u'りんご', u'林檎')
)
table.setDataArray(d)
def insert_para(text, string):
p = make_PropertyValue("ParaStyleName", "Standard")
text.appendParagraph((p,))
text.insertString(text.getEnd(), string, False)
text.finishParagraph(())
def insert_heading1(text, string):
p = make_PropertyValue("ParaStyleName", "Heading 1")
text.appendParagraph( (p,) )
text.insertString(text.getEnd(), string, False)
def make_PropertyValue(name, value):
p = PropertyValue()
p.Name = name
p.Value = value
return p
g_exportedScripts = writer_test,
}}
End:
* Python と Writer [#f2ef28d1]
Python で Writer ドキュメントを操作します。
#code(python){{
#!
# -*- coding: utf_8 -*-
from com.sun.star.beans import PropertyValue
from com.sun.star.table import TableBorder
from com.sun.star.text import TableColumnSeparator
from com.sun.star.text.HoriOrientation import NONE as HO_...
def writer_test():
doc = XSCRIPTCONTEXT.getDocument()
if doc.supportsService("com.sun.star.text.TextDocument"):
text = doc.getText()
#insert_heading1(text, u'見出しを入力')
# 見出しを作成
cursor = text.createTextCursorByRange(text.getStart())
cursor.setString(u'見出しを入力')
cursor.setPropertyValue(u'ParaStyleName', u'Heading 1')
insert_para(text, u'枠線のない表')
# 表を作成、挿入
table = doc.createInstance("com.sun.star.text.TextTable")
table.setName("NewTable")
table.initialize(3, 2)
text.insertTextContent(text.getEnd(),table,True)
# 表の枠線をなしに、幅などを変更
border = TableBorder()
border.IsTopLineValid = True
border.IsBottomLineValid = True
border.IsLeftLineValid = True
border.IsRightLineValid = True
border.IsHorizontalLineValid = True
border.IsVerticalLineValid = True
table.TableBorder = border
#table.Width = 12000
table.LeftMargin = 2000
table.RightMargin = 2000
table.HoriOrient = HO_NONE
t = TableColumnSeparator()
t.Position = 3000
t.IsVisible = True
table.TableColumnSeparators = t,
# 一度にセルにデータを入力
d = (
(u'項目', u'説明'),
(u'みかん', u'蜜柑'),
(u'りんご', u'林檎')
)
table.setDataArray(d)
def insert_para(text, string):
p = make_PropertyValue("ParaStyleName", "Standard")
text.appendParagraph((p,))
text.insertString(text.getEnd(), string, False)
text.finishParagraph(())
def insert_heading1(text, string):
p = make_PropertyValue("ParaStyleName", "Heading 1")
text.appendParagraph( (p,) )
text.insertString(text.getEnd(), string, False)
def make_PropertyValue(name, value):
p = PropertyValue()
p.Name = name
p.Value = value
return p
g_exportedScripts = writer_test,
}}
Page: