xref: /trunk/main/sw/source/ui/uno/unodoc.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 // System - Includes -----------------------------------------------------
31 
32 #include <tools/string.hxx>
33 #include <sfx2/docfac.hxx>
34 #include <sfx2/sfxmodelfactory.hxx>
35 #include "swdll.hxx"
36 #include "docsh.hxx"
37 #include "globdoc.hxx"
38 #include "wdocsh.hxx"
39 #include <vos/mutex.hxx>
40 #include <vcl/svapp.hxx>
41 
42 using namespace ::com::sun::star;
43 
44 //============================================================
45 // com.sun.star.comp.Writer.TextDocument
46 
47 uno::Sequence< ::rtl::OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw()
48 {
49     // return only top level services here! All others must be
50     // resolved by rtti!
51     uno::Sequence< ::rtl::OUString > aRet ( 1 );
52 	::rtl::OUString* pArray = aRet.getArray();
53 	pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.TextDocument" ) );
54 
55 	return aRet;
56 }
57 
58 ::rtl::OUString SAL_CALL SwTextDocument_getImplementationName() throw()
59 {
60 	return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
61 }
62 
63 uno::Reference< uno::XInterface > SAL_CALL SwTextDocument_createInstance(
64         const uno::Reference< lang::XMultiServiceFactory >&, const sal_uInt64 _nCreationFlags )
65 	throw( uno::Exception )
66 {
67     ::vos::OGuard aGuard( Application::GetSolarMutex() );
68 	SwDLL::Init();
69     SfxObjectShell* pShell = new SwDocShell( _nCreationFlags );
70 	return uno::Reference< uno::XInterface >( pShell->GetModel() );
71 }
72 
73 //============================================================
74 // com.sun.star.comp.Writer.WebDocument
75 
76 uno::Sequence< ::rtl::OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw()
77 {
78     // return only top level services here! All others must be
79     // resolved by rtti!
80     uno::Sequence< ::rtl::OUString > aRet ( 1 );
81 	::rtl::OUString* pArray = aRet.getArray();
82     pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.WebDocument" ) );
83 
84 	return aRet;
85 }
86 
87 ::rtl::OUString SAL_CALL SwWebDocument_getImplementationName() throw()
88 {
89 	return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WebDocument" ) );
90 }
91 
92 uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance(
93     const uno::Reference< lang::XMultiServiceFactory > & )
94         throw( uno::Exception )
95 {
96     ::vos::OGuard aGuard( Application::GetSolarMutex() );
97 	SwDLL::Init();
98 	SfxObjectShell* pShell = new SwWebDocShell( SFX_CREATE_MODE_STANDARD );
99 	return uno::Reference< uno::XInterface >( pShell->GetModel() );
100 }
101 
102 //============================================================
103 // com.sun.star.comp.Writer.GlobalDocument
104 
105 uno::Sequence< ::rtl::OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw()
106 {
107     uno::Sequence< ::rtl::OUString > aRet ( 1 );
108 	::rtl::OUString* pArray = aRet.getArray();
109     pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.GlobalDocument" ) );
110 
111 	return aRet;
112 }
113 
114 ::rtl::OUString SAL_CALL SwGlobalDocument_getImplementationName() throw()
115 {
116 	return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.GlobalDocument" ) );
117 }
118 
119 uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance(
120     const uno::Reference< lang::XMultiServiceFactory > &)
121         throw( uno::Exception )
122 {
123     ::vos::OGuard aGuard( Application::GetSolarMutex() );
124 	SwDLL::Init();
125 	SfxObjectShell* pShell = new SwGlobalDocShell( SFX_CREATE_MODE_STANDARD );
126 	return uno::Reference< uno::XInterface >( pShell->GetModel() );
127 }
128 
129