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