create a new page, using OOobbs3/90 as a template.
Front page
Search
掲示板
Reload
Help
Browse Log
掲示板の使い方
OOo 掲示板3
OOo 掲示板2
OOo 掲示板
掲示板
雑談掲示板
New
List of pages
Recent changes
Backup
簡単ヘルプ
整形ルール
Start:
** [[OOobbs3/90]] [#e9d490c3]
-''サマリ'': ドキュメントのカスタムプロパティを追加・削除...
-''環境'': General
-''状態'': 解決
-''投稿者'': [[いしみず]]
-''投稿日'': 2012-04-09 (月) 13:11:44
*** 質問 [#r4b3d6a5]
いつもお世話になってます。OpenOffice3.3のカルクを利用して...
*** 回答 [#bfdc3fab]
- 次のような感じになります。
Sub SetDocumentProperty
doc = ThisComponent
p = doc.getDocumentProperties()
props = p.getUserDefinedProperties()
' プロパティを追加
' REMOVEABLE を指定しなければ削除できなくなる
attr = com.sun.star.beans.PropertyAttribute.REMOVEABLE
' プロパティ名、フィールド属性、デフォルト値
props.addProperty("New2", attr, "")
' プロパティに値を設定
props.setPropertyValue("New2", "foo")
' プロパティを削除
'props.removeProperty("New2")
End Sub
プロパティがすでにあるかどうかを調べるには次のようにしま...
props.getPropertySetInfo().hasPropertyByName("name")
プロパティ追加時に REMOVEABLE を指定しなければそのプロパ...
-- はにゃ? &new{2012-04-09 (月) 15:00:42};
- ありがとうございました。解決しました。hasByNameは、hasP...
- 関連でもうひとつ質問ですが、ThisComponentではなく別の開...
- > hasPropertyByName 直しておきました。 -- はにゃ? &new{...
- 新規ドキュメントでなければ、デスクトップオブジェクトか...
components = StarDesktop.getComponents()
enume = components.createEnumeration()
Do while enume.hasMoreElements()
comp = enume.nextElement()
' この場合、css.lang.XComponent インターフェースをエク...
' css.frame.XModel インタフェースをエクスポートしてい...
'...
If comp.getURL() = "nantokakantoka" then
exit do
End If
Loop
-- はにゃ? &new{2012-04-09 (月) 21:27:45};
- お返事遅くなりました。ありがとうございました。ですがプ...
- 私の環境では問題なく動作するようです。 -- はにゃ? &new{...
- URLをコンバートしないとだめでした。開いている他のドキュ...
#comment
*** 感想,コメント,メモ [#pf1a21ad]
#comment
コードを書きました。よろしくお願いします。
Option Explicit
Private Sub TestBtn_Push()
Dim sURL As String
sURL = "D:\OooBasic\テスト\testX71.ods"
'Call getCustomProperty(sURL)
Call setCustomProperty(sURL)
End Sub
Sub getCustomProperty(sURL As String)
Dim oDoc As Object
Dim oDocInfo As Object
Dim oProps As Object
Dim oProp As Object
oDoc = getDocObject(sURL)
oDocInfo = oDoc.getDocumentProperties()
oProps = oDocInfo.getUserDefinedProperties()
If oProps.getPropertySetInfo().hasPropertyByName("te...
oProp = oProps.getPropertySetInfo().getPropertyB...
msgbox oProps.getPropertyValue("test")
End If
End Sub
Sub setCustomProperty(sURL As String)
' カスタムプロパティのセット
Dim oDoc As Object
Dim oDocInfo As Object
Dim oProps As Object
Dim attr as Variant
'oDoc = ThisComponent
'oDocInfo = oDoc.getDocumentProperties()
oDoc = getDocObject(sURL)
oDocInfo = oDoc.getDocumentProperties()
oProps = oDocInfo.getUserDefinedProperties()
' プロパティを追加
' REMOVEABLE を指定しなければ削除できなくなる
attr = com.sun.star.beans.PropertyAttribute.REMOVEABLE
' プロパティ名、フィールド属性、デフォルト値
If oProps.getPropertySetInfo().hasPropertyByName("te...
oProps.addProperty("test", attr, "")
End If
' プロパティに値を設定
oProps.setPropertyValue("test", "aaaa")
' プロパティを削除
'oProps.removeProperty("New2")
End Sub
Function getDocObject(sURL As String) As Object
Dim oComponents As Object
Dim oEnume As Object
Dim oComp As Object
oComponents = StarDesktop.getComponents()
oEnume = oComponents.createEnumeration()
Do while oEnume.hasMoreElements()
oComp = oEnume.nextElement()
' この場合、css.lang.XComponent インターフェースをエク...
' css.frame.XModel インタフェースをエクスポートしている...
'...
If oComp.getURL() = ConvetToUrl(sURL) Then
Exit Do
End If
Loop
getDocObject = oComp
End Function
End:
** [[OOobbs3/90]] [#e9d490c3]
-''サマリ'': ドキュメントのカスタムプロパティを追加・削除...
-''環境'': General
-''状態'': 解決
-''投稿者'': [[いしみず]]
-''投稿日'': 2012-04-09 (月) 13:11:44
*** 質問 [#r4b3d6a5]
いつもお世話になってます。OpenOffice3.3のカルクを利用して...
*** 回答 [#bfdc3fab]
- 次のような感じになります。
Sub SetDocumentProperty
doc = ThisComponent
p = doc.getDocumentProperties()
props = p.getUserDefinedProperties()
' プロパティを追加
' REMOVEABLE を指定しなければ削除できなくなる
attr = com.sun.star.beans.PropertyAttribute.REMOVEABLE
' プロパティ名、フィールド属性、デフォルト値
props.addProperty("New2", attr, "")
' プロパティに値を設定
props.setPropertyValue("New2", "foo")
' プロパティを削除
'props.removeProperty("New2")
End Sub
プロパティがすでにあるかどうかを調べるには次のようにしま...
props.getPropertySetInfo().hasPropertyByName("name")
プロパティ追加時に REMOVEABLE を指定しなければそのプロパ...
-- はにゃ? &new{2012-04-09 (月) 15:00:42};
- ありがとうございました。解決しました。hasByNameは、hasP...
- 関連でもうひとつ質問ですが、ThisComponentではなく別の開...
- > hasPropertyByName 直しておきました。 -- はにゃ? &new{...
- 新規ドキュメントでなければ、デスクトップオブジェクトか...
components = StarDesktop.getComponents()
enume = components.createEnumeration()
Do while enume.hasMoreElements()
comp = enume.nextElement()
' この場合、css.lang.XComponent インターフェースをエク...
' css.frame.XModel インタフェースをエクスポートしてい...
'...
If comp.getURL() = "nantokakantoka" then
exit do
End If
Loop
-- はにゃ? &new{2012-04-09 (月) 21:27:45};
- お返事遅くなりました。ありがとうございました。ですがプ...
- 私の環境では問題なく動作するようです。 -- はにゃ? &new{...
- URLをコンバートしないとだめでした。開いている他のドキュ...
#comment
*** 感想,コメント,メモ [#pf1a21ad]
#comment
コードを書きました。よろしくお願いします。
Option Explicit
Private Sub TestBtn_Push()
Dim sURL As String
sURL = "D:\OooBasic\テスト\testX71.ods"
'Call getCustomProperty(sURL)
Call setCustomProperty(sURL)
End Sub
Sub getCustomProperty(sURL As String)
Dim oDoc As Object
Dim oDocInfo As Object
Dim oProps As Object
Dim oProp As Object
oDoc = getDocObject(sURL)
oDocInfo = oDoc.getDocumentProperties()
oProps = oDocInfo.getUserDefinedProperties()
If oProps.getPropertySetInfo().hasPropertyByName("te...
oProp = oProps.getPropertySetInfo().getPropertyB...
msgbox oProps.getPropertyValue("test")
End If
End Sub
Sub setCustomProperty(sURL As String)
' カスタムプロパティのセット
Dim oDoc As Object
Dim oDocInfo As Object
Dim oProps As Object
Dim attr as Variant
'oDoc = ThisComponent
'oDocInfo = oDoc.getDocumentProperties()
oDoc = getDocObject(sURL)
oDocInfo = oDoc.getDocumentProperties()
oProps = oDocInfo.getUserDefinedProperties()
' プロパティを追加
' REMOVEABLE を指定しなければ削除できなくなる
attr = com.sun.star.beans.PropertyAttribute.REMOVEABLE
' プロパティ名、フィールド属性、デフォルト値
If oProps.getPropertySetInfo().hasPropertyByName("te...
oProps.addProperty("test", attr, "")
End If
' プロパティに値を設定
oProps.setPropertyValue("test", "aaaa")
' プロパティを削除
'oProps.removeProperty("New2")
End Sub
Function getDocObject(sURL As String) As Object
Dim oComponents As Object
Dim oEnume As Object
Dim oComp As Object
oComponents = StarDesktop.getComponents()
oEnume = oComponents.createEnumeration()
Do while oEnume.hasMoreElements()
oComp = oEnume.nextElement()
' この場合、css.lang.XComponent インターフェースをエク...
' css.frame.XModel インタフェースをエクスポートしている...
'...
If oComp.getURL() = ConvetToUrl(sURL) Then
Exit Do
End If
Loop
getDocObject = oComp
End Function
Page: