xref: /core/starmath/source/unodoc.cxx (revision f807e70e)
1 /*************************************************************************
2  *
3  *  $RCSfile: unodoc.cxx,v $
4  *
5  *  $Revision: 1.2 $
6  *
7  *  last change: $Author: hr $ $Date: 2003-04-04 19:13:01 $
8  *
9  *  The Contents of this file are made available subject to the terms of
10  *  either of the following licenses
11  *
12  *         - GNU Lesser General Public License Version 2.1
13  *         - Sun Industry Standards Source License Version 1.1
14  *
15  *  Sun Microsystems Inc., October, 2000
16  *
17  *  GNU Lesser General Public License Version 2.1
18  *  =============================================
19  *  Copyright 2000 by Sun Microsystems, Inc.
20  *  901 San Antonio Road, Palo Alto, CA 94303, USA
21  *
22  *  This library is free software; you can redistribute it and/or
23  *  modify it under the terms of the GNU Lesser General Public
24  *  License version 2.1, as published by the Free Software Foundation.
25  *
26  *  This library is distributed in the hope that it will be useful,
27  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29  *  Lesser General Public License for more details.
30  *
31  *  You should have received a copy of the GNU Lesser General Public
32  *  License along with this library; if not, write to the Free Software
33  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34  *  MA  02111-1307  USA
35  *
36  *
37  *  Sun Industry Standards Source License Version 1.1
38  *  =================================================
39  *  The contents of this file are subject to the Sun Industry Standards
40  *  Source License Version 1.1 (the "License"); You may not use this file
41  *  except in compliance with the License. You may obtain a copy of the
42  *  License at http://www.openoffice.org/license.html.
43  *
44  *  Software provided under this License is provided on an "AS IS" basis,
45  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48  *  See the License for the specific provisions governing your rights and
49  *  obligations concerning the Software.
50  *
51  *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
52  *
53  *  Copyright: 2000 by Sun Microsystems, Inc.
54  *
55  *  All Rights Reserved.
56  *
57  *  Contributor(s): _______________________________________
58  *
59  *
60  ************************************************************************/
61 
62 // System - Includes -----------------------------------------------------
63 
64 #include <tools/string.hxx>
65 #include <sfx2/docfac.hxx>
66 
67 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
68 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
69 #endif
70 
71 #include "smmod.hxx"
72 
73 #ifndef _VOS_MUTEX_HXX_
74 #include <vos/mutex.hxx>
75 #endif
76 #ifndef _SV_SVAPP_HXX
77 #include <vcl/svapp.hxx>
78 #endif
79 
80 using namespace ::com::sun::star;
81 
82 ::rtl::OUString SAL_CALL SmDocument_getImplementationName() throw()
83 {
84     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.FormulaDocument" ) );
85 }
86 
87 uno::Sequence< rtl::OUString > SAL_CALL SmDocument_getSupportedServiceNames() throw()
88 {
89     uno::Sequence< rtl::OUString > aSeq( 1 );
90     aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.formula.FormulaProperties" ));
91     return aSeq;
92 }
93 
94 uno::Reference< uno::XInterface > SAL_CALL SmDocument_createInstance(
95                 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
96 {
97     ::vos::OGuard aGuard( Application::GetSolarMutex() );
98 
99     // to create the service the SW_MOD should be already initialized
100     DBG_ASSERT( SM_MOD(), "No StarMath module!" );
101 
102     if ( SM_MOD() )
103     {
104         ::rtl::OUString aFactoryURL( RTL_CONSTASCII_USTRINGPARAM ( "private:factory/smath" ) );
105         const SfxObjectFactory* pFactory = SfxObjectFactory::GetFactory( aFactoryURL );
106         if ( pFactory )
107         {
108             SfxObjectShell* pShell = pFactory->CreateObject();
109             if( pShell )
110                 return uno::Reference< uno::XInterface >( pShell->GetModel() );
111         }
112     }
113 
114     return uno::Reference< uno::XInterface >();
115 }
116 
117 
118