1 /*************************************************************************
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: guid.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #if defined(_MSC_VER) && (_MSC_VER > 1310)
31 #pragma warning(disable : 4917 4555)
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/container/XNameAccess.hpp>
38 ::rtl::OUString
getStorageTypeFromGUID_Impl( GUID
* guid
)
40 if ( *guid
== OID_WriterTextServer
)
41 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarWriterDocument.6" ) );
43 if ( *guid
== OID_WriterOASISTextServer
)
44 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.WriterDocument.1" ) );
46 if ( *guid
== OID_CalcServer
)
47 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarCalcDocument.6" ) );
49 if ( *guid
== OID_CalcOASISServer
)
50 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.CalcDocument.1" ) );
52 if ( *guid
== OID_DrawingServer
)
53 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarDrawDocument.6" ) );
55 if ( *guid
== OID_DrawingOASISServer
)
56 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.DrawDocument.1" ) );
58 if ( *guid
== OID_PresentationServer
)
59 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarImpressDocument.6" ) );
61 if ( *guid
== OID_PresentationOASISServer
)
62 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.ImpressDocument.1" ) );
64 if ( *guid
== OID_MathServer
)
65 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarMathDocument.6" ) );
67 if ( *guid
== OID_MathOASISServer
)
68 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.MathDocument.1" ) );
70 return ::rtl::OUString();
73 ::rtl::OUString
getServiceNameFromGUID_Impl( GUID
* guid
)
75 if ( *guid
== OID_WriterTextServer
)
76 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
78 if ( *guid
== OID_WriterOASISTextServer
)
79 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
81 if ( *guid
== OID_CalcServer
)
82 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) );
84 if ( *guid
== OID_CalcOASISServer
)
85 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) );
87 if ( *guid
== OID_DrawingServer
)
88 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) );
90 if ( *guid
== OID_DrawingOASISServer
)
91 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) );
93 if ( *guid
== OID_PresentationServer
)
94 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) );
96 if ( *guid
== OID_PresentationOASISServer
)
97 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) );
99 if ( *guid
== OID_MathServer
)
100 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) );
102 if ( *guid
== OID_MathOASISServer
)
103 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) );
105 return ::rtl::OUString();
108 ::rtl::OUString
getFilterNameFromGUID_Impl( GUID
* guid
)
110 if ( *guid
== OID_WriterTextServer
)
111 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Writer)" ) );
113 if ( *guid
== OID_WriterOASISTextServer
)
114 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer8" ) );
116 if ( *guid
== OID_CalcServer
)
117 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Calc)" ) );
119 if ( *guid
== OID_CalcOASISServer
)
120 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "calc8" ) );
122 if ( *guid
== OID_DrawingServer
)
123 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Draw)" ) );
125 if ( *guid
== OID_DrawingOASISServer
)
126 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw8" ) );
128 if ( *guid
== OID_PresentationServer
)
129 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Impress)" ) );
131 if ( *guid
== OID_PresentationOASISServer
)
132 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "impress8" ) );
134 if ( *guid
== OID_MathServer
)
135 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Math)" ) );
137 if ( *guid
== OID_MathOASISServer
)
138 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "math8" ) );
140 return ::rtl::OUString();
143 ::rtl::OUString
getTestFileURLFromGUID_Impl( GUID
* guid
)
145 if ( *guid
== OID_WriterTextServer
)
146 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxw" ) );
148 if ( *guid
== OID_WriterOASISTextServer
)
149 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odt" ) );
151 if ( *guid
== OID_CalcServer
)
152 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxc" ) );
154 if ( *guid
== OID_CalcOASISServer
)
155 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.ods" ) );
157 if ( *guid
== OID_DrawingServer
)
158 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxd" ) );
160 if ( *guid
== OID_DrawingOASISServer
)
161 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odg" ) );
163 if ( *guid
== OID_PresentationServer
)
164 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxi" ) );
166 if ( *guid
== OID_PresentationOASISServer
)
167 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odp" ) );
169 if ( *guid
== OID_MathServer
)
170 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxm" ) );
172 if ( *guid
== OID_MathOASISServer
)
173 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odf" ) );
175 return ::rtl::OUString();
179 ::rtl::OUString getCurTypeNameFromGUID_Impl( const uno::Reference< lang::XMultiServiceFactory > xFactory, GUID* guid )
181 ::rtl::OUString aResult;
183 const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.document.FilterFactory" ) );
184 uno::Reference < container::XNameAccess > xFilters = uno::Reference < io::XOutputStream > (
185 xFactory->createInstance ( aServiceName ),
190 ::rtl::OUString aFilterName = getFilterNameFromGUID_Impl( guid );
191 if ( aFilterName.getLength() )
193 uno::Any aAnyProp = xFilters->getByName( aFilterName );
194 uno::Sequence< beans::PropertyValue > aProperties;
195 if ( aAnyProp >>= aProperties ) )
197 for ( sal_Int32 nInd = 0; nInd < aProperties.getLength; nInd++ )
198 if ( aProperties[nInd].Name.equalsAscii( "UIName" )
200 aProperties[nInd].Value >>= aResult;
211 // Fix strange warnings about some
212 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
213 // warning C4505: 'xxx' : unreferenced local function has been removed
214 #if defined(_MSC_VER)
215 #pragma warning(disable: 4505)