Top > OOoBasic > Generic > TypeDetection
*ドキュメントタイプの判定 [#v7caa77f]

ドキュメントなどファイルの形式を判定する com.sun.star.document.TypeDetection サービス。

#contents

**TypeDetection サービス [#x3c2b369]
サービスをインスタンス化して ''queryTypeByURL'' メソッドを呼び出す。

 Sub Main
   sFileURL = "file:///C:/Users/Desktop/paragraph.odt"
   oTypeDetection = CreateUnoService("com.sun.star.document.TypeDetection")
   msgbox oTypeDetection.queryTypeByURL(sFileURL)
 End Sub

戻り値は string 型で OOo でファイルを読み込む際のフィルター名。

このフィルター名はファイルを開くときに利用できます。


**フィルター名の一覧取得 [#sc8a15e1]

 Sub Main
   sFileURL = "file:///C:/Users/Desktop/paragraph.odt"
   oTypeDetection = CreateUnoService("com.sun.star.document.TypeDetection")
   sElements = oTypeDetection.getElementNames()
   sTxt = ""
   For i = 0 To UBound(sElements)
     sTxt = sTxt & sElements(i) & chr(10)
   Next i
   msgbox sTxt
 End Sub

実行結果例。結果は環境によって違います。


-BibTeX
-LaTeX
-StarBase
-StarBaseReport
-bmp_MS_Windows
-calc8
-calc8_template
-calc_DIF
-calc_Lotus
-calc_MS_Excel_2003_XML
-calc_MS_Excel_40
-calc_MS_Excel_40_VorlageTemplate
-calc_MS_Excel_5095
-calc_MS_Excel_5095_VorlageTemplate
-calc_MS_Excel_95
-calc_MS_Excel_95_VorlageTemplate
-calc_MS_Excel_97
-calc_MS_Excel_97_VorlageTemplate
-calc_QPro
-calc_SYLK
-calc_StarCalc_10
-calc_StarCalc_30
-calc_StarCalc_30_VorlageTemplate
-calc_StarCalc_40
-calc_StarCalc_40_VorlageTemplate
-calc_StarCalc_50
-calc_StarCalc_50_VorlageTemplate
-calc_StarOffice_XML_Calc
-calc_StarOffice_XML_Calc_Template
-calc_Text_txt_csv_StarCalc
-calc_dBase
-chart8
-chart_StarChart_30
-chart_StarChart_40
-chart_StarChart_50
-chart_StarOffice_XML_Chart
-component_Bibliography
-component_DB
-draw8
-draw8_template
-draw_StarDraw_30
-draw_StarDraw_30_Vorlage
-draw_StarDraw_50
-draw_StarDraw_50_Vorlage
-draw_StarOffice_XML_Draw
-draw_StarOffice_XML_Draw_Template
-dxf_AutoCAD_Interchange
-emf_MS_Windows_Metafile
-eps_Encapsulated_PostScript
-gif_Graphics_Interchange
-graphic_HTML
-graphic_SWF
-impress8
-impress8_template
-impress_CGM_Computer_Graphics_Metafile
-impress_MS_PowerPoint_97
-impress_MS_PowerPoint_97_Vorlage
-impress_StarImpress_40
-impress_StarImpress_40_Vorlage
-impress_StarImpress_50
-impress_StarImpress_50_Vorlage
-impress_StarImpress_50_packed
-impress_StarOffice_XML_Impress
-impress_StarOffice_XML_Impress_Template
-jpg_JPEG
-math8
-math_MathML_XML_Math
-math_MathType_3x
-math_StarMath_20
-math_StarMath_30
-math_StarMath_40
-math_StarMath_50
-math_StarOffice_XML_Math
-met_OS2_Metafile
-pbm_Portable_Bitmap
-pcd_Photo_CD_Base
-pcd_Photo_CD_Base16
-pcd_Photo_CD_Base4
-pct_Mac_Pict
-pcx_Zsoft_Paintbrush
-pdf_Portable_Document_Format
-pgm_Portable_Graymap
-png_Portable_Network_Graphic
-ppm_Portable_Pixelmap
-psd_Adobe_Photoshop
-pwp_PlaceWare
-ras_Sun_Rasterfile
-sgf_StarOffice_Writer_SGF
-sgv_StarDraw_20
-svg_Scalable_Vector_Graphics
-svm_StarView_Metafile
-tga_Truevision_TARGA
-tif_Tag_Image_File
-wav_Wave_Audio_File
-wmf_MS_Windows_Metafile
-writer8
-writer8_template
-writer_JustSystem_Ichitaro_10
-writer_JustSystem_Ichitaro_10_template
-writer_Lotus_1_2_3_10_DOS_StarWriter
-writer_Lotus_1_2_3_10_WIN_StarWriter
-writer_MIZI_Hwp_97
-writer_MS_WinWord_5
-writer_MS_WinWord_60
-writer_MS_Word_2003_XML
-writer_MS_Word_95
-writer_MS_Word_95_Vorlage
-writer_MS_Word_97
-writer_MS_Word_97_Vorlage
-writer_Rich_Text_Format
-writer_StarOffice_XML_Writer
-writer_StarOffice_XML_Writer_Template
-writer_StarWriter_10
-writer_StarWriter_20
-writer_StarWriter_30
-writer_StarWriter_30_VorlageTemplate
-writer_StarWriter_40
-writer_StarWriter_40_VorlageTemplate
-writer_StarWriter_50
-writer_StarWriter_50_VorlageTemplate
-writer_StarWriter_DOS
-writer_Text
-writer_Text_encoded
-writer_WPSSystem_WPS2000_10
-writer_WordPerfect_Document
-writer_globaldocument_StarOffice_XML_Writer_GlobalDocument
-writer_globaldocument_StarWriter_40GlobalDocument
-writer_globaldocument_StarWriter_50GlobalDocument
-writer_web_HTML
-writer_web_HTML_help
-writer_web_StarOffice_XML_Writer_Web_Template
-writer_web_StarWriterWeb_40_VorlageTemplate
-writer_web_StarWriterWeb_50_VorlageTemplate
-writerglobal8
-writerweb8_writer_template
-xbm_X_Consortium
-xpm_XPM


** ModuleManager [#q00f0d77]
読み込み済みのドキュメントの種類を判定します。

ドキュメントオブジェクト XModel、コントローラ XController、フレーム XFrame のどれかからドキュメントのコンポーネントの種類を判定します。

 oModManager = CreateUnoService("com.sun.star.frame.ModuleManager")
 sModuelName = oModManager.identify(ThisComponent)
 Msgbox sModuleName

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes