xref: /aoo41x/main/embedserv/source/embed/guid.cxx (revision 79aad27f)
1*f78e906fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f78e906fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f78e906fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f78e906fSAndrew Rist  * distributed with this work for additional information
6*f78e906fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f78e906fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f78e906fSAndrew Rist  * "License"); you may not use this file except in compliance
9*f78e906fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f78e906fSAndrew Rist  *
11*f78e906fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f78e906fSAndrew Rist  *
13*f78e906fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f78e906fSAndrew Rist  * software distributed under the License is distributed on an
15*f78e906fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f78e906fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f78e906fSAndrew Rist  * specific language governing permissions and limitations
18*f78e906fSAndrew Rist  * under the License.
19*f78e906fSAndrew Rist  *
20*f78e906fSAndrew Rist  *************************************************************/
21*f78e906fSAndrew Rist 
22*f78e906fSAndrew Rist 
23cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER > 1310)
24cdf0e10cSrcweir #pragma warning(disable : 4917 4555)
25cdf0e10cSrcweir #endif
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "common.h"
28cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
30cdf0e10cSrcweir 
getStorageTypeFromGUID_Impl(GUID * guid)31cdf0e10cSrcweir ::rtl::OUString getStorageTypeFromGUID_Impl( GUID* guid )
32cdf0e10cSrcweir {
33cdf0e10cSrcweir     if ( *guid == OID_WriterTextServer )
34cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarWriterDocument.6" ) );
35cdf0e10cSrcweir 
36cdf0e10cSrcweir     if ( *guid == OID_WriterOASISTextServer )
37cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.WriterDocument.1" ) );
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     if ( *guid == OID_CalcServer )
40cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarCalcDocument.6" ) );
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     if ( *guid == OID_CalcOASISServer )
43cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.CalcDocument.1" ) );
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     if ( *guid == OID_DrawingServer )
46cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarDrawDocument.6" ) );
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     if ( *guid == OID_DrawingOASISServer )
49cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.DrawDocument.1" ) );
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     if ( *guid == OID_PresentationServer )
52cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarImpressDocument.6" ) );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     if ( *guid == OID_PresentationOASISServer )
55cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.ImpressDocument.1" ) );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     if ( *guid == OID_MathServer )
58cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarMathDocument.6" ) );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     if ( *guid == OID_MathOASISServer )
61cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.MathDocument.1" ) );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     return ::rtl::OUString();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
getServiceNameFromGUID_Impl(GUID * guid)66cdf0e10cSrcweir ::rtl::OUString getServiceNameFromGUID_Impl( GUID* guid )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir     if ( *guid == OID_WriterTextServer )
69cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     if ( *guid == OID_WriterOASISTextServer )
72cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     if ( *guid == OID_CalcServer )
75cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     if ( *guid == OID_CalcOASISServer )
78cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     if ( *guid == OID_DrawingServer )
81cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     if ( *guid == OID_DrawingOASISServer )
84cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     if ( *guid == OID_PresentationServer )
87cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     if ( *guid == OID_PresentationOASISServer )
90cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     if ( *guid == OID_MathServer )
93cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     if ( *guid == OID_MathOASISServer )
96cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     return ::rtl::OUString();
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
getFilterNameFromGUID_Impl(GUID * guid)101cdf0e10cSrcweir ::rtl::OUString getFilterNameFromGUID_Impl( GUID* guid )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     if ( *guid == OID_WriterTextServer )
104cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Writer)" ) );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     if ( *guid == OID_WriterOASISTextServer )
107cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer8" ) );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     if ( *guid == OID_CalcServer )
110cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Calc)" ) );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     if ( *guid == OID_CalcOASISServer )
113cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "calc8" ) );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     if ( *guid == OID_DrawingServer )
116cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Draw)" ) );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     if ( *guid == OID_DrawingOASISServer )
119cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw8" ) );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     if ( *guid == OID_PresentationServer )
122cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Impress)" ) );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     if ( *guid == OID_PresentationOASISServer )
125cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "impress8" ) );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     if ( *guid == OID_MathServer )
128cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Math)" ) );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     if ( *guid == OID_MathOASISServer )
131cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "math8" ) );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     return ::rtl::OUString();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
getTestFileURLFromGUID_Impl(GUID * guid)136cdf0e10cSrcweir ::rtl::OUString getTestFileURLFromGUID_Impl( GUID* guid )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     if ( *guid == OID_WriterTextServer )
139cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxw" ) );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     if ( *guid == OID_WriterOASISTextServer )
142cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odt" ) );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     if ( *guid == OID_CalcServer )
145cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxc" ) );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     if ( *guid == OID_CalcOASISServer )
148cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.ods" ) );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     if ( *guid == OID_DrawingServer )
151cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxd" ) );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     if ( *guid == OID_DrawingOASISServer )
154cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odg" ) );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     if ( *guid == OID_PresentationServer )
157cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxi" ) );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     if ( *guid == OID_PresentationOASISServer )
160cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odp" ) );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     if ( *guid == OID_MathServer )
163cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxm" ) );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     if ( *guid == OID_MathOASISServer )
166cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odf" ) );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     return ::rtl::OUString();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir /*
172cdf0e10cSrcweir ::rtl::OUString getCurTypeNameFromGUID_Impl( const uno::Reference< lang::XMultiServiceFactory > xFactory, GUID* guid )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     ::rtl::OUString aResult;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.document.FilterFactory" ) );
177cdf0e10cSrcweir     uno::Reference < container::XNameAccess > xFilters = uno::Reference < io::XOutputStream > (
178cdf0e10cSrcweir     xFactory->createInstance ( aServiceName ),
179cdf0e10cSrcweir     uno::UNO_QUERY );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     if ( xFilters.is() )
182cdf0e10cSrcweir     {
183cdf0e10cSrcweir         ::rtl::OUString aFilterName = getFilterNameFromGUID_Impl( guid );
184cdf0e10cSrcweir         if ( aFilterName.getLength() )
185cdf0e10cSrcweir         {
186cdf0e10cSrcweir             uno::Any aAnyProp = xFilters->getByName( aFilterName );
187cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue > aProperties;
188cdf0e10cSrcweir             if ( aAnyProp >>= aProperties ) )
189cdf0e10cSrcweir             {
190cdf0e10cSrcweir                 for ( sal_Int32 nInd = 0; nInd < aProperties.getLength; nInd++ )
191cdf0e10cSrcweir                 if ( aProperties[nInd].Name.equalsAscii( "UIName" )
192cdf0e10cSrcweir                 {
193cdf0e10cSrcweir                     aProperties[nInd].Value >>= aResult;
194cdf0e10cSrcweir                     break;
195cdf0e10cSrcweir                 }
196cdf0e10cSrcweir             }
197cdf0e10cSrcweir 	}
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     return aResult;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir */
203cdf0e10cSrcweir 
204cdf0e10cSrcweir // Fix strange warnings about some
205cdf0e10cSrcweir // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
206cdf0e10cSrcweir // warning C4505: 'xxx' : unreferenced local function has been removed
207cdf0e10cSrcweir #if defined(_MSC_VER)
208cdf0e10cSrcweir #pragma warning(disable: 4505)
209cdf0e10cSrcweir #endif
210