LibreOffice5(102)ストレージのサービスとインターフェイスの一覧

2017-12-05

旧ブログ

t f B! P L
ストレージはXNameAccessインターフェイスをもっているので、StorageFactoryサービスのcreateInstanceWithArguments()メソッドで取得したあとは子要素名をキーとする辞書のように扱えます(XNameReplaceXNameContainerはないので置換や挿入、削除はできません)。storage[key1][key2]で取得した値ではfor key in objでエラーになりました。

前の関連記事:LibreOffice5(101)埋め込みマクロの更新とマクロセレクターとAPSO


ファイルのストレージのサービスとインターフェイスの一覧

from com.sun.star.embed import ElementModes  # 定数
def macro():
 ctx = XSCRIPTCONTEXT.getComponentContext()  # コンポーネントコンテクストの取得。
 smgr = ctx.getServiceManager()  # サービスマネージャーの取得。 
 tcu = smgr.createInstanceWithContext("pq.Tcu", ctx)  # サービス名か実装名でインスタンス化。
 tempfile = smgr.createInstanceWithContext("com.sun.star.io.TempFile", ctx) # TempFile
 storagefactory = smgr.createInstanceWithContext('com.sun.star.embed.StorageFactory', ctx)
 storage = storagefactory.createInstanceWithArguments((tempfile.Uri, ElementModes.READ))
 tcu.wtree(storage) 
一時ファイルのストレージを取得しています。

Calcドキュメントから取得したストレージでも同じ結果でした。

ElementModes.READで取得してもElementModes.WRITEで取得しても同じ結果でした。

├─.beans.XPropertySet
│                        void  addPropertyChangeListener( [in]                         string aPropertyName,
│                                                         [in] .beans.XPropertyChangeListener xListener
│                                              ) raises ( .lang.WrappedTargetException,
│                                                         .beans.UnknownPropertyException)
│                        void  addVetoableChangeListener( [in]                         string PropertyName,
│                                                         [in] .beans.XVetoableChangeListener aListener
│                                              ) raises ( .lang.WrappedTargetException,
│                                                         .beans.UnknownPropertyException)
│     .beans.XPropertySetInfo  getPropertySetInfo()
│                         any  getPropertyValue( [in] string PropertyName
│                                     ) raises ( .lang.WrappedTargetException,
│                                                .beans.UnknownPropertyException)
│                        void  removePropertyChangeListener( [in]                         string aPropertyName,
│                                                            [in] .beans.XPropertyChangeListener aListener
│                                                 ) raises ( .lang.WrappedTargetException,
│                                                            .beans.UnknownPropertyException)
│                        void  removeVetoableChangeListener( [in]                         string PropertyName,
│                                                            [in] .beans.XVetoableChangeListener aListener
│                                                 ) raises ( .lang.WrappedTargetException,
│                                                            .beans.UnknownPropertyException)
│                        void  setPropertyValue( [in] string aPropertyName,
│                                                [in]    any aValue
│                                     ) raises ( .lang.WrappedTargetException,
│                                                .lang.IllegalArgumentException,
│                                                .beans.PropertyVetoException,
│                                                .beans.UnknownPropertyException)
├─.embed.XEncryptionProtectedStorage
│   │   [.beans.NamedValue]  getEncryptionAlgorithms()
│   │                  void  setEncryptionAlgorithms( [in] [.beans.NamedValue] aAlgorithms
│   │                                      ) raises ( .lang.IllegalArgumentException)
│   └─.embed.XEncryptionProtectedSource2
│     │   boolean  hasEncryptionData()
│     │      void  setEncryptionData( [in] [.beans.NamedValue] aEncryptionData
│     │                    ) raises ( .io.IOException)
│     └─.embed.XEncryptionProtectedSource
│           void  removeEncryption()
│           void  setEncryptionPassword( [in] string sPassword
│                             ) raises ( .io.IOException)
├─.embed.XStorage2
│   │   .io.XStream  cloneEncryptedStream( [in]              string sStreamName,
│   │                                      [in] [.beans.NamedValue] aEncryptionData
│   │                           ) raises ( .embed.StorageWrappedTargetException,
│   │                                      .io.IOException,
│   │                                      .packages.WrongPasswordException,
│   │                                      .packages.NoEncryptionException,
│   │                                      .lang.IllegalArgumentException,
│   │                                      .embed.InvalidStorageException)
│   │   .io.XStream  openEncryptedStream( [in]              string sStreamName,
│   │                                     [in]                long nOpenMode,
│   │                                     [in] [.beans.NamedValue] aEncryptionData
│   │                          ) raises ( .embed.StorageWrappedTargetException,
│   │                                     .io.IOException,
│   │                                     .packages.WrongPasswordException,
│   │                                     .packages.NoEncryptionException,
│   │                                     .lang.IllegalArgumentException,
│   │                                     .embed.InvalidStorageException)
│   └─.embed.XStorage
│     │       .io.XStream  cloneEncryptedStreamElement( [in] string sStreamName,
│     │                                                 [in] string sPassword
│     │                                      ) raises ( .embed.StorageWrappedTargetException,
│     │                                                 .io.IOException,
│     │                                                 .packages.WrongPasswordException,
│     │                                                 .packages.NoEncryptionException,
│     │                                                 .lang.IllegalArgumentException,
│     │                                                 .embed.InvalidStorageException)
│     │       .io.XStream  cloneStreamElement( [in] string sStreamName
│     │                             ) raises ( .embed.StorageWrappedTargetException,
│     │                                        .io.IOException,
│     │                                        .packages.WrongPasswordException,
│     │                                        .lang.IllegalArgumentException,
│     │                                        .embed.InvalidStorageException)
│     │              void  copyElementTo( [in]          string sElementName,
│     │                                   [in] .embed.XStorage xDest,
│     │                                   [in]          string sNewName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.ElementExistException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │              void  copyLastCommitTo( [in] .embed.XStorage xTargetStorage
│     │                           ) raises ( .embed.StorageWrappedTargetException,
│     │                                      .io.IOException,
│     │                                      .lang.IllegalArgumentException,
│     │                                      .embed.InvalidStorageException)
│     │              void  copyStorageElementLastCommitTo( [in]          string sStorName,
│     │                                                    [in] .embed.XStorage xTargetStorage
│     │                                         ) raises ( .embed.StorageWrappedTargetException,
│     │                                                    .io.IOException,
│     │                                                    .lang.IllegalArgumentException,
│     │                                                    .embed.InvalidStorageException)
│     │              void  copyToStorage( [in] .embed.XStorage xDest
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │           boolean  isStorageElement( [in] string sElementName
│     │                           ) raises ( .embed.InvalidStorageException,
│     │                                      .lang.IllegalArgumentException,
│     │                                      .container.NoSuchElementException)
│     │           boolean  isStreamElement( [in] string sElementName
│     │                          ) raises ( .embed.InvalidStorageException,
│     │                                     .lang.IllegalArgumentException,
│     │                                     .container.NoSuchElementException)
│     │              void  moveElementTo( [in]          string sElementName,
│     │                                   [in] .embed.XStorage xDest,
│     │                                   [in]          string sNewName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.ElementExistException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │       .io.XStream  openEncryptedStreamElement( [in] string sStreamName,
│     │                                                [in]   long nOpenMode,
│     │                                                [in] string sPassword
│     │                                     ) raises ( .embed.StorageWrappedTargetException,
│     │                                                .io.IOException,
│     │                                                .packages.WrongPasswordException,
│     │                                                .packages.NoEncryptionException,
│     │                                                .lang.IllegalArgumentException,
│     │                                                .embed.InvalidStorageException)
│     │   .embed.XStorage  openStorageElement( [in] string sStorName,
│     │                                        [in]   long nOpenMode
│     │                             ) raises ( .embed.StorageWrappedTargetException,
│     │                                        .io.IOException,
│     │                                        .lang.IllegalArgumentException,
│     │                                        .embed.InvalidStorageException)
│     │       .io.XStream  openStreamElement( [in] string sStreamName,
│     │                                       [in]   long nOpenMode
│     │                            ) raises ( .embed.StorageWrappedTargetException,
│     │                                       .io.IOException,
│     │                                       .packages.WrongPasswordException,
│     │                                       .lang.IllegalArgumentException,
│     │                                       .embed.InvalidStorageException)
│     │              void  removeElement( [in] string sElementName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │              void  renameElement( [in] string sElementName,
│     │                                   [in] string sNewName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.ElementExistException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     ├─.container.XNameAccess
│     │   │        any  getByName( [in] string aName
│     │   │             ) raises ( .lang.WrappedTargetException,
│     │   │                        .container.NoSuchElementException)
│     │   │   [string]  getElementNames()
│     │   │    boolean  hasByName( [in] string aName)
│     │   └─.container.XElementAccess
│     │           type  getElementType()
│     │        boolean  hasElements()
│     └─.lang.XComponent
│           void  addEventListener( [in] .lang.XEventListener xListener)
│           void  dispose()
│           void  removeEventListener( [in] .lang.XEventListener aListener)
├─.embed.XStorageRawAccess
│     .io.XInputStream  getPlainRawStreamElement( [in] string sStreamName
│                                      ) raises ( .embed.StorageWrappedTargetException,
│                                                 .io.IOException,
│                                                 .container.NoSuchElementException,
│                                                 .lang.IllegalArgumentException,
│                                                 .embed.InvalidStorageException)
│     .io.XInputStream  getRawEncrStreamElement( [in] string sStreamName
│                                     ) raises ( .embed.StorageWrappedTargetException,
│                                                .io.IOException,
│                                                .container.NoSuchElementException,
│                                                .packages.NoEncryptionException,
│                                                .lang.IllegalArgumentException,
│                                                .embed.InvalidStorageException)
│                 void  insertRawEncrStreamElement( [in]           string sStreamName,
│                                                   [in] .io.XInputStream xInStream
│                                        ) raises ( .embed.StorageWrappedTargetException,
│                                                   .io.IOException,
│                                                   .container.ElementExistException,
│                                                   .packages.NoRawFormatException,
│                                                   .lang.IllegalArgumentException,
│                                                   .embed.InvalidStorageException)
├─.embed.XTransactedObject
│     void  commit()
│     void  revert()
├─.embed.XTransactionBroadcaster
│     void  addTransactionListener( [in] .embed.XTransactionListener aListener)
│     void  removeTransactionListener( [in] .embed.XTransactionListener aListener)
└─.util.XModifiable
  │   boolean  isModified()
  │      void  setModified( [in] boolean bModified
  │              ) raises ( .beans.PropertyVetoException)
  └─.util.XModifyBroadcaster
        void  addModifyListener( [in] .util.XModifyListener aListener)
        void  removeModifyListener( [in] .util.XModifyListener aListener)

ストレージはフォルダに該当するようですが、操作方法はだいぶ違うようです。

通常のフォルダをストレージとして扱うにはファイルシステムストレージを使います(LibreOffice5(103)ファイルシステムストレージのサービスとインターフェイスの一覧参照)。

ストレージのメソッドをみるとドキュメントに埋め込むファイルを暗号化できそうにみえますけど、これもまだやり方はわかりません。

XStream型が戻ってくるメソッドからはインプットストリームとアウトプットストリームが取得できます。

ストリームがファイルに該当します。

Calcドキュメント内フォルダのストレージのサービスとインターフェイス一覧

from com.sun.star.embed import ElementModes  # 定数
def macro():
 ctx = XSCRIPTCONTEXT.getComponentContext()  # コンポーネントコンテクストの取得。
 smgr = ctx.getServiceManager()  # サービスマネージャーの取得。 
 tcu = smgr.createInstanceWithContext("pq.Tcu", ctx)  # サービス名か実装名でインスタンス化。
 doc = XSCRIPTCONTEXT.getDocument()
 documentstorage = doc.getDocumentStorage()  # ドキュメントストレージを取得。
 thumbnailsstorage = documentstorage.openStorageElement("Thumbnails", ElementModes.READ)  # ドキュメント内のThumbnailsストレージを取得。
 tcu.wtree(thumbnailsstorage)
7行目でドキュメントモデルからドキュメントストレージを取得しています。

8行目でドキュメントファイル内にあるThumbnailsフォルダのストレージを取得していますが、取得したドキュメントがディスク上にないと、IOExceptionになります。

ドキュメントのストレージと比較すると、XEncryptionProtectedSourceXEncryptionProtectedSource2XEncryptionProtectedStorageのインターフェイスがありません。

├─.beans.XPropertySet
│                        void  addPropertyChangeListener( [in]                         string aPropertyName,
│                                                         [in] .beans.XPropertyChangeListener xListener
│                                              ) raises ( .lang.WrappedTargetException,
│                                                         .beans.UnknownPropertyException)
│                        void  addVetoableChangeListener( [in]                         string PropertyName,
│                                                         [in] .beans.XVetoableChangeListener aListener
│                                              ) raises ( .lang.WrappedTargetException,
│                                                         .beans.UnknownPropertyException)
│     .beans.XPropertySetInfo  getPropertySetInfo()
│                         any  getPropertyValue( [in] string PropertyName
│                                     ) raises ( .lang.WrappedTargetException,
│                                                .beans.UnknownPropertyException)
│                        void  removePropertyChangeListener( [in]                         string aPropertyName,
│                                                            [in] .beans.XPropertyChangeListener aListener
│                                                 ) raises ( .lang.WrappedTargetException,
│                                                            .beans.UnknownPropertyException)
│                        void  removeVetoableChangeListener( [in]                         string PropertyName,
│                                                            [in] .beans.XVetoableChangeListener aListener
│                                                 ) raises ( .lang.WrappedTargetException,
│                                                            .beans.UnknownPropertyException)
│                        void  setPropertyValue( [in] string aPropertyName,
│                                                [in]    any aValue
│                                     ) raises ( .lang.WrappedTargetException,
│                                                .lang.IllegalArgumentException,
│                                                .beans.PropertyVetoException,
│                                                .beans.UnknownPropertyException)
├─.embed.XStorage2
│   │   .io.XStream  cloneEncryptedStream( [in]              string sStreamName,
│   │                                      [in] [.beans.NamedValue] aEncryptionData
│   │                           ) raises ( .embed.StorageWrappedTargetException,
│   │                                      .io.IOException,
│   │                                      .packages.WrongPasswordException,
│   │                                      .packages.NoEncryptionException,
│   │                                      .lang.IllegalArgumentException,
│   │                                      .embed.InvalidStorageException)
│   │   .io.XStream  openEncryptedStream( [in]              string sStreamName,
│   │                                     [in]                long nOpenMode,
│   │                                     [in] [.beans.NamedValue] aEncryptionData
│   │                          ) raises ( .embed.StorageWrappedTargetException,
│   │                                     .io.IOException,
│   │                                     .packages.WrongPasswordException,
│   │                                     .packages.NoEncryptionException,
│   │                                     .lang.IllegalArgumentException,
│   │                                     .embed.InvalidStorageException)
│   └─.embed.XStorage
│     │       .io.XStream  cloneEncryptedStreamElement( [in] string sStreamName,
│     │                                                 [in] string sPassword
│     │                                      ) raises ( .embed.StorageWrappedTargetException,
│     │                                                 .io.IOException,
│     │                                                 .packages.WrongPasswordException,
│     │                                                 .packages.NoEncryptionException,
│     │                                                 .lang.IllegalArgumentException,
│     │                                                 .embed.InvalidStorageException)
│     │       .io.XStream  cloneStreamElement( [in] string sStreamName
│     │                             ) raises ( .embed.StorageWrappedTargetException,
│     │                                        .io.IOException,
│     │                                        .packages.WrongPasswordException,
│     │                                        .lang.IllegalArgumentException,
│     │                                        .embed.InvalidStorageException)
│     │              void  copyElementTo( [in]          string sElementName,
│     │                                   [in] .embed.XStorage xDest,
│     │                                   [in]          string sNewName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.ElementExistException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │              void  copyLastCommitTo( [in] .embed.XStorage xTargetStorage
│     │                           ) raises ( .embed.StorageWrappedTargetException,
│     │                                      .io.IOException,
│     │                                      .lang.IllegalArgumentException,
│     │                                      .embed.InvalidStorageException)
│     │              void  copyStorageElementLastCommitTo( [in]          string sStorName,
│     │                                                    [in] .embed.XStorage xTargetStorage
│     │                                         ) raises ( .embed.StorageWrappedTargetException,
│     │                                                    .io.IOException,
│     │                                                    .lang.IllegalArgumentException,
│     │                                                    .embed.InvalidStorageException)
│     │              void  copyToStorage( [in] .embed.XStorage xDest
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │           boolean  isStorageElement( [in] string sElementName
│     │                           ) raises ( .embed.InvalidStorageException,
│     │                                      .lang.IllegalArgumentException,
│     │                                      .container.NoSuchElementException)
│     │           boolean  isStreamElement( [in] string sElementName
│     │                          ) raises ( .embed.InvalidStorageException,
│     │                                     .lang.IllegalArgumentException,
│     │                                     .container.NoSuchElementException)
│     │              void  moveElementTo( [in]          string sElementName,
│     │                                   [in] .embed.XStorage xDest,
│     │                                   [in]          string sNewName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.ElementExistException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │       .io.XStream  openEncryptedStreamElement( [in] string sStreamName,
│     │                                                [in]   long nOpenMode,
│     │                                                [in] string sPassword
│     │                                     ) raises ( .embed.StorageWrappedTargetException,
│     │                                                .io.IOException,
│     │                                                .packages.WrongPasswordException,
│     │                                                .packages.NoEncryptionException,
│     │                                                .lang.IllegalArgumentException,
│     │                                                .embed.InvalidStorageException)
│     │   .embed.XStorage  openStorageElement( [in] string sStorName,
│     │                                        [in]   long nOpenMode
│     │                             ) raises ( .embed.StorageWrappedTargetException,
│     │                                        .io.IOException,
│     │                                        .lang.IllegalArgumentException,
│     │                                        .embed.InvalidStorageException)
│     │       .io.XStream  openStreamElement( [in] string sStreamName,
│     │                                       [in]   long nOpenMode
│     │                            ) raises ( .embed.StorageWrappedTargetException,
│     │                                       .io.IOException,
│     │                                       .packages.WrongPasswordException,
│     │                                       .lang.IllegalArgumentException,
│     │                                       .embed.InvalidStorageException)
│     │              void  removeElement( [in] string sElementName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     │              void  renameElement( [in] string sElementName,
│     │                                   [in] string sNewName
│     │                        ) raises ( .embed.StorageWrappedTargetException,
│     │                                   .io.IOException,
│     │                                   .container.ElementExistException,
│     │                                   .container.NoSuchElementException,
│     │                                   .lang.IllegalArgumentException,
│     │                                   .embed.InvalidStorageException)
│     ├─.container.XNameAccess
│     │   │        any  getByName( [in] string aName
│     │   │             ) raises ( .lang.WrappedTargetException,
│     │   │                        .container.NoSuchElementException)
│     │   │   [string]  getElementNames()
│     │   │    boolean  hasByName( [in] string aName)
│     │   └─.container.XElementAccess
│     │           type  getElementType()
│     │        boolean  hasElements()
│     └─.lang.XComponent
│           void  addEventListener( [in] .lang.XEventListener xListener)
│           void  dispose()
│           void  removeEventListener( [in] .lang.XEventListener aListener)
├─.embed.XStorageRawAccess
│     .io.XInputStream  getPlainRawStreamElement( [in] string sStreamName
│                                      ) raises ( .embed.StorageWrappedTargetException,
│                                                 .io.IOException,
│                                                 .container.NoSuchElementException,
│                                                 .lang.IllegalArgumentException,
│                                                 .embed.InvalidStorageException)
│     .io.XInputStream  getRawEncrStreamElement( [in] string sStreamName
│                                     ) raises ( .embed.StorageWrappedTargetException,
│                                                .io.IOException,
│                                                .container.NoSuchElementException,
│                                                .packages.NoEncryptionException,
│                                                .lang.IllegalArgumentException,
│                                                .embed.InvalidStorageException)
│                 void  insertRawEncrStreamElement( [in]           string sStreamName,
│                                                   [in] .io.XInputStream xInStream
│                                        ) raises ( .embed.StorageWrappedTargetException,
│                                                   .io.IOException,
│                                                   .container.ElementExistException,
│                                                   .packages.NoRawFormatException,
│                                                   .lang.IllegalArgumentException,
│                                                   .embed.InvalidStorageException)
├─.embed.XTransactedObject
│     void  commit()
│     void  revert()
├─.embed.XTransactionBroadcaster
│     void  addTransactionListener( [in] .embed.XTransactionListener aListener)
│     void  removeTransactionListener( [in] .embed.XTransactionListener aListener)
└─.util.XModifiable
  │   boolean  isModified()
  │      void  setModified( [in] boolean bModified
  │              ) raises ( .beans.PropertyVetoException)
  └─.util.XModifyBroadcaster
        void  addModifyListener( [in] .util.XModifyListener aListener)
        void  removeModifyListener( [in] .util.XModifyListener aListener)

参考にしたサイト


OOoBasic/Generic/Storage - ...?
ストレージの解説。

次の関連記事:LibreOffice5(103)ファイルシステムストレージのサービスとインターフェイスの一覧

ブログ検索 by Blogger

Translate

最近のコメント

Created by Calendar Gadget

QooQ