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