1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER > 1310) 28*cdf0e10cSrcweir #pragma warning(disable : 4917 4555) 29*cdf0e10cSrcweir #endif 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "common.h" 32*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir ::rtl::OUString getStorageTypeFromGUID_Impl( GUID* guid ) 36*cdf0e10cSrcweir { 37*cdf0e10cSrcweir if ( *guid == OID_WriterTextServer ) 38*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarWriterDocument.6" ) ); 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir if ( *guid == OID_WriterOASISTextServer ) 41*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.WriterDocument.1" ) ); 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir if ( *guid == OID_CalcServer ) 44*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarCalcDocument.6" ) ); 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir if ( *guid == OID_CalcOASISServer ) 47*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.CalcDocument.1" ) ); 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir if ( *guid == OID_DrawingServer ) 50*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarDrawDocument.6" ) ); 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir if ( *guid == OID_DrawingOASISServer ) 53*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.DrawDocument.1" ) ); 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir if ( *guid == OID_PresentationServer ) 56*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarImpressDocument.6" ) ); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir if ( *guid == OID_PresentationOASISServer ) 59*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.ImpressDocument.1" ) ); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir if ( *guid == OID_MathServer ) 62*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "soffice.StarMathDocument.6" ) ); 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir if ( *guid == OID_MathOASISServer ) 65*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "opendocument.MathDocument.1" ) ); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir return ::rtl::OUString(); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir ::rtl::OUString getServiceNameFromGUID_Impl( GUID* guid ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir if ( *guid == OID_WriterTextServer ) 73*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir if ( *guid == OID_WriterOASISTextServer ) 76*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) ); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir if ( *guid == OID_CalcServer ) 79*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) ); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir if ( *guid == OID_CalcOASISServer ) 82*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Calc.SpreadsheetDocument" ) ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir if ( *guid == OID_DrawingServer ) 85*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) ); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir if ( *guid == OID_DrawingOASISServer ) 88*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.DrawingDocument" ) ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir if ( *guid == OID_PresentationServer ) 91*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) ); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir if ( *guid == OID_PresentationOASISServer ) 94*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.PresentationDocument" ) ); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir if ( *guid == OID_MathServer ) 97*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) ); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir if ( *guid == OID_MathOASISServer ) 100*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Math.FormulaDocument" ) ); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir return ::rtl::OUString(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir ::rtl::OUString getFilterNameFromGUID_Impl( GUID* guid ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir if ( *guid == OID_WriterTextServer ) 108*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Writer)" ) ); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir if ( *guid == OID_WriterOASISTextServer ) 111*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer8" ) ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if ( *guid == OID_CalcServer ) 114*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Calc)" ) ); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if ( *guid == OID_CalcOASISServer ) 117*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "calc8" ) ); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir if ( *guid == OID_DrawingServer ) 120*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Draw)" ) ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir if ( *guid == OID_DrawingOASISServer ) 123*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw8" ) ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if ( *guid == OID_PresentationServer ) 126*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Impress)" ) ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if ( *guid == OID_PresentationOASISServer ) 129*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "impress8" ) ); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if ( *guid == OID_MathServer ) 132*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "StarOffice XML (Math)" ) ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir if ( *guid == OID_MathOASISServer ) 135*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "math8" ) ); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir return ::rtl::OUString(); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir ::rtl::OUString getTestFileURLFromGUID_Impl( GUID* guid ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir if ( *guid == OID_WriterTextServer ) 143*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxw" ) ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if ( *guid == OID_WriterOASISTextServer ) 146*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odt" ) ); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir if ( *guid == OID_CalcServer ) 149*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxc" ) ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir if ( *guid == OID_CalcOASISServer ) 152*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.ods" ) ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir if ( *guid == OID_DrawingServer ) 155*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxd" ) ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if ( *guid == OID_DrawingOASISServer ) 158*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odg" ) ); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir if ( *guid == OID_PresentationServer ) 161*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxi" ) ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir if ( *guid == OID_PresentationOASISServer ) 164*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odp" ) ); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir if ( *guid == OID_MathServer ) 167*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.sxm" ) ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir if ( *guid == OID_MathOASISServer ) 170*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "file:///d:/OLE_TEST/test.odf" ) ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir return ::rtl::OUString(); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir /* 176*cdf0e10cSrcweir ::rtl::OUString getCurTypeNameFromGUID_Impl( const uno::Reference< lang::XMultiServiceFactory > xFactory, GUID* guid ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir ::rtl::OUString aResult; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.document.FilterFactory" ) ); 181*cdf0e10cSrcweir uno::Reference < container::XNameAccess > xFilters = uno::Reference < io::XOutputStream > ( 182*cdf0e10cSrcweir xFactory->createInstance ( aServiceName ), 183*cdf0e10cSrcweir uno::UNO_QUERY ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if ( xFilters.is() ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ::rtl::OUString aFilterName = getFilterNameFromGUID_Impl( guid ); 188*cdf0e10cSrcweir if ( aFilterName.getLength() ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir uno::Any aAnyProp = xFilters->getByName( aFilterName ); 191*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties; 192*cdf0e10cSrcweir if ( aAnyProp >>= aProperties ) ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aProperties.getLength; nInd++ ) 195*cdf0e10cSrcweir if ( aProperties[nInd].Name.equalsAscii( "UIName" ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir aProperties[nInd].Value >>= aResult; 198*cdf0e10cSrcweir break; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir return aResult; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir */ 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir // Fix strange warnings about some 209*cdf0e10cSrcweir // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions. 210*cdf0e10cSrcweir // warning C4505: 'xxx' : unreferenced local function has been removed 211*cdf0e10cSrcweir #if defined(_MSC_VER) 212*cdf0e10cSrcweir #pragma warning(disable: 4505) 213*cdf0e10cSrcweir #endif 214