* クエリー [#b6768a6f] テーブルからレコードを取得するために事前に作成しておくクエリー。 #contents ** クエリー定義コンテナ [#o00e8f00] クエリーの定義はデータベースドキュメントのデータソースからアクセスできます。 Sub query_1 oDoc = StarDesktop.getCurrentComponent() oDataSource = oDoc.DataSource oQueryDefs = oDataSource.getQueryDefinitions() End Sub ** クエリーの操作 [#e5585cd3] クエリー定義コンテナオブジェクトは次のようなインターフェースをサポートしています。名前やインデックスで取得、削除などの操作が行えます。 - com.sun.star.container.XChild - com.sun.star.container.XContainer - com.sun.star.container.XContainerApproveBroadcaster - com.sun.star.container.XElementAccess - com.sun.star.container.XEnumerationAccess - com.sun.star.container.XIndexAccess - com.sun.star.container.XNameAccess - com.sun.star.container.XNameContainer - com.sun.star.container.XNameReplace Sub query_2 oDoc = StarDesktop.getCurrentComponent() oDataSource = oDoc.DataSource oQueryDefs = oDataSource.getQueryDefinitions() oQueryDef = oQueryDefs.getByName("クエリー1") End Sub 注:~ XNameReplace インターフェースの replaceByName メソッドを使用して既存のクエリーを編集、置換しようとすると com.sun.star.container.ElementExistException を吐きます。replaceByName メソッドは既存のものを置換するメソッドなのにおかしな動作です。 また、removeByName の後で insertByName メソッドで新しく追加するとデータベースドキュメントの UI 上で重複して同じ名前のクエリーが表示されます。これを何度も行うとデータベースドキュメントが破壊されることがあります。 ** クエリーの作成 [#o89a58e0] 新規クエリーの作成は以下のように createInstance メソッドを使用して新しいクエリーを作成、編集した後に追加します。 Sub query_10 oDoc = StarDesktop.getCurrentComponent() oDataSource = oDoc.DataSource oQueryDefs = oDataSource.getQueryDefinitions() oNewQueryDef = oQueryDefs.createInstance() oNewQueryDef.Command = "SELECT * FROM ""Table""" oQueryDefs.insertByName("NewQuery1", oNewQueryDef) End Sub ** クエリーのプロパティ [#e64b2af6] |プロパティ|型|説明| |ApplyFilter|boolean|| |Command|string|| |EscapeProcessing|boolean|| |Filter|string|| |FontCharWidth|float|| |FontCharset|short|| |FontDescriptor|.awt.FontDescriptor|| |FontEmphasisMark|short|| |FontFamily|short|| |FontHeight|short|| |FontKerning|boolean|| |FontName|string|| |FontOrientation|float|| |FontPitch|short|| |FontRelief|short|| |FontSlant|.awt.FontSlant|| |FontStrikeout|short|| |FontStyleName|string|| |FontType|short|| |FontUnderline|short|| |FontWeight|float|| |FontWidth|short|| |FontWordLineMode|boolean|| |GroupBy|string|| |HavingClause|string|| |LayoutInformation|[].beans.PropertyValue|| |Name|string|| |Order|string|| |RowHeight|long|| |TextColor|long|| |TextLineColor|long|| |UpdateCatalogName|string|| |UpdateSchemaName|string|| |UpdateTableName|string|| ** メモ [#i01296ec] クエリーでもフィルターを設定できる様子。UI からフィルターを設定、変更する方法が見つからなかった。そこで、API から ApplyFilter および Filter を設定したところクエリー後のレコードデータの表示ではフィルターされたデータが表示された。 しかし、そのクエリーを使用したレポートにはフィルターが反映されなかった。 クエリーをソースとしたフォームでも同様にフィルターが反映されなかった。 |