1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: apicalls.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:19:05 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.skottke@sun.com
36 '* short description : Various calls to the API
38 '\******************************************************************************
40 function hGetFileLocationAPI() as string
42 '///<h3>Get the location of the current file from API - experimental, do not use</h3>
44 dim oUnoConnect as object
45 dim oUnoService as object
46 dim oDocument as object
47 dim cDocument as string
49 const CFN = "hGetFileLocationAPI::"
51 oUnoConnect = GetUNOApp
52 if ( isNull( oUnoConnect ) ) then
53 warnlog( CFN & "No UNO connection established" )
55 oUnoService = oUnoConnect.createInstance( "com.sun.star.frame.Desktop" )
56 if ( isNull( oUnoService ) ) then
57 warnlog( CFN & "No UNO Service available" )
59 oDocument = oUnoService.getCurrentComponent()
60 if ( isNull( oDocument ) ) then
61 warnlog( CFN & "No current component available" )
63 if ( oDocument.hasLocation() ) then
64 cDocument = oDocument.getLocation()
65 hGetFileLocationAPI() = cDocument
66 printlog( CFN & cDocument )
68 warnlog( "Document has no storage location" )
69 hGetFileLocationAPI() = ""
77 '*******************************************************************************
79 function hGetDocTypeAPI() as string
81 '///<h3>Get the current document via API - experimental, do not use</h3>
83 dim oUnoConnect as object
84 dim oUnoService as object
85 dim oDocument as object
86 dim cDocument as string
88 const CFN = "hGetDocTypeAPI::"
90 oUnoConnect = GetUNOApp
91 if ( isNull( oUnoConnect ) ) then
92 warnlog( CFN & "No UNO connection established" )
94 oUnoService = oUnoConnect.createInstance( "com.sun.star.frame.Desktop" )
95 if ( isNull( oUnoService ) ) then
96 warnlog( CFN & "No UNO Service available" )
98 oDocument = oUnoService.getCurrentComponent()
99 if ( isNull( oDocument ) ) then
100 warnlog( CFN & "No current component available" )
102 if ( oDocument.SupportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )then
103 hGetDoctypeAPI() = "CALC"
104 elseif( oDocument.SupportsService( "com.sun.star.text.TextDocument" ) ) then
105 hGetDocTypeAPI() = "WRITER"
106 elseif( oDocument.SupportsService( "com.sun.star.drawing.DrawingDocument" ) ) then
107 hGetDocTypeAPI() = "DRAW"
108 elseif( oDocument.SupportsService( "com.sun.star.formula.FormulaProperties" ) ) then
109 hGetDocTypeAPI() = "MATH"
110 elseif( oDocument.SupportsService("com.sun.star.presentation.PresentationDocument") ) then
111 hGetDocTypeAPI() = "IMPRESS"
113 warnlog( "Unknown document type" )
114 hGetDocTypeAPI() = ""