xref: /AOO41X/main/embeddedobj/source/msole/xdialogcreator.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_embeddedobj.hxx"
30*cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/embed/XEmbeddedObject.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/embed/EntryInitModes.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/datatransfer/DataFlavor.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <osl/thread.h>
39*cdf0e10cSrcweir #include <osl/file.hxx>
40*cdf0e10cSrcweir #include <vos/module.hxx>
41*cdf0e10cSrcweir #include <comphelper/classids.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include "platform.h"
44*cdf0e10cSrcweir #include <comphelper/mimeconfighelper.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "xdialogcreator.hxx"
47*cdf0e10cSrcweir #include "oleembobj.hxx"
48*cdf0e10cSrcweir // LLA: tip from FS
49*cdf0e10cSrcweir // #include <confighelper.hxx>
50*cdf0e10cSrcweir #include <xdialogcreator.hxx>
51*cdf0e10cSrcweir #include <oleembobj.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #ifdef WNT
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #include <oledlg.h>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir class InitializedOleGuard
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir public:
61*cdf0e10cSrcweir 	InitializedOleGuard()
62*cdf0e10cSrcweir 	{
63*cdf0e10cSrcweir 		if ( !SUCCEEDED( OleInitialize( NULL ) ) )
64*cdf0e10cSrcweir 			throw ::com::sun::star::uno::RuntimeException();
65*cdf0e10cSrcweir 	}
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 	~InitializedOleGuard()
68*cdf0e10cSrcweir 	{
69*cdf0e10cSrcweir 		OleUninitialize();
70*cdf0e10cSrcweir 	}
71*cdf0e10cSrcweir };
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir extern "C" {
74*cdf0e10cSrcweir typedef UINT STDAPICALLTYPE OleUIInsertObjectA_Type(LPOLEUIINSERTOBJECTA);
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir #endif
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir using namespace ::com::sun::star;
81*cdf0e10cSrcweir using namespace ::comphelper;
82*cdf0e10cSrcweir //-------------------------------------------------------------------------
83*cdf0e10cSrcweir uno::Sequence< sal_Int8 > GetRelatedInternalID_Impl( const uno::Sequence< sal_Int8 >& aClassID )
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir 	// Writer
86*cdf0e10cSrcweir 	if ( MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SW_OLE_EMBED_CLASSID_60 ) )
87*cdf0e10cSrcweir 	  || MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SW_OLE_EMBED_CLASSID_8 ) ) )
88*cdf0e10cSrcweir 		return MimeConfigurationHelper::GetSequenceClassID( SO3_SW_CLASSID_60 );
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	// Calc
91*cdf0e10cSrcweir 	if ( MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SC_OLE_EMBED_CLASSID_60 ) )
92*cdf0e10cSrcweir 	  || MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SC_OLE_EMBED_CLASSID_8 ) ) )
93*cdf0e10cSrcweir 		return MimeConfigurationHelper::GetSequenceClassID( SO3_SC_CLASSID_60 );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	// Impress
96*cdf0e10cSrcweir 	if ( MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SIMPRESS_OLE_EMBED_CLASSID_60 ) )
97*cdf0e10cSrcweir 	  || MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SIMPRESS_OLE_EMBED_CLASSID_8 ) ) )
98*cdf0e10cSrcweir 		return MimeConfigurationHelper::GetSequenceClassID( SO3_SIMPRESS_CLASSID_60 );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	// Draw
101*cdf0e10cSrcweir 	if ( MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SDRAW_OLE_EMBED_CLASSID_60 ) )
102*cdf0e10cSrcweir 	  || MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SDRAW_OLE_EMBED_CLASSID_8 ) ) )
103*cdf0e10cSrcweir 		return MimeConfigurationHelper::GetSequenceClassID( SO3_SDRAW_CLASSID_60 );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	// Chart
106*cdf0e10cSrcweir 	if ( MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SCH_OLE_EMBED_CLASSID_60 ) )
107*cdf0e10cSrcweir 	  || MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SCH_OLE_EMBED_CLASSID_8 ) ) )
108*cdf0e10cSrcweir 		return MimeConfigurationHelper::GetSequenceClassID( SO3_SCH_CLASSID_60 );
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	// Math
111*cdf0e10cSrcweir 	if ( MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SM_OLE_EMBED_CLASSID_60 ) )
112*cdf0e10cSrcweir 	  || MimeConfigurationHelper::ClassIDsEqual( aClassID, MimeConfigurationHelper::GetSequenceClassID( SO3_SM_OLE_EMBED_CLASSID_8 ) ) )
113*cdf0e10cSrcweir 		return MimeConfigurationHelper::GetSequenceClassID( SO3_SM_CLASSID_60 );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	return aClassID;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir //-------------------------------------------------------------------------
119*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames()
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > aRet(2);
122*cdf0e10cSrcweir     aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.MSOLEObjectSystemCreator");
123*cdf0e10cSrcweir     aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.MSOLEObjectSystemCreator");
124*cdf0e10cSrcweir     return aRet;
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir //-------------------------------------------------------------------------
128*cdf0e10cSrcweir ::rtl::OUString SAL_CALL MSOLEDialogObjectCreator::impl_staticGetImplementationName()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.MSOLEObjectSystemCreator");
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir //-------------------------------------------------------------------------
134*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL MSOLEDialogObjectCreator::impl_staticCreateSelfInstance(
135*cdf0e10cSrcweir 			const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	return uno::Reference< uno::XInterface >( *new MSOLEDialogObjectCreator( xServiceManager ) );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir //-------------------------------------------------------------------------
141*cdf0e10cSrcweir embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDialog(
142*cdf0e10cSrcweir 			const uno::Reference< embed::XStorage >& xStorage,
143*cdf0e10cSrcweir 			const ::rtl::OUString& sEntName,
144*cdf0e10cSrcweir 			const uno::Sequence< beans::PropertyValue >& aInObjArgs )
145*cdf0e10cSrcweir 	throw ( lang::IllegalArgumentException,
146*cdf0e10cSrcweir 			io::IOException,
147*cdf0e10cSrcweir 			uno::Exception,
148*cdf0e10cSrcweir 			uno::RuntimeException )
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir 	embed::InsertedObjectInfo aObjectInfo;
151*cdf0e10cSrcweir 	uno::Sequence< beans::PropertyValue > aObjArgs( aInObjArgs );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir #ifdef WNT
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	if ( !xStorage.is() )
156*cdf0e10cSrcweir 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
157*cdf0e10cSrcweir 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
158*cdf0e10cSrcweir 											1 );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	if ( !sEntName.getLength() )
161*cdf0e10cSrcweir 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
162*cdf0e10cSrcweir 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
163*cdf0e10cSrcweir 											2 );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	InitializedOleGuard aGuard;
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	OLEUIINSERTOBJECT io;
168*cdf0e10cSrcweir 	char szFile[MAX_PATH];
169*cdf0e10cSrcweir 	UINT uTemp;
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	memset(&io, 0, sizeof(io));
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	io.cbStruct = sizeof(io);
174*cdf0e10cSrcweir 	io.hWndOwner = GetActiveWindow();
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	szFile[0] = 0;
177*cdf0e10cSrcweir 	io.lpszFile = szFile;
178*cdf0e10cSrcweir 	io.cchFile = MAX_PATH;
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	io.dwFlags = IOF_SELECTCREATENEW | IOF_DISABLELINK;
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	::vos::OModule aOleDlgLib;
184*cdf0e10cSrcweir 	if( !aOleDlgLib.load( ::rtl::OUString::createFromAscii( "oledlg" ) ) )
185*cdf0e10cSrcweir 		throw uno::RuntimeException();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	OleUIInsertObjectA_Type * pInsertFct = (OleUIInsertObjectA_Type *)
188*cdf0e10cSrcweir 								aOleDlgLib.getSymbol( ::rtl::OUString::createFromAscii( "OleUIInsertObjectA" ) );
189*cdf0e10cSrcweir 	if( !pInsertFct )
190*cdf0e10cSrcweir 		throw uno::RuntimeException();
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 	uTemp=pInsertFct(&io);
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	if ( OLEUI_OK == uTemp )
195*cdf0e10cSrcweir 	{
196*cdf0e10cSrcweir 		if (io.dwFlags & IOF_SELECTCREATENEW)
197*cdf0e10cSrcweir 		{
198*cdf0e10cSrcweir 			uno::Reference< embed::XEmbedObjectCreator > xEmbCreator(
199*cdf0e10cSrcweir 						m_xFactory->createInstance(
200*cdf0e10cSrcweir 								::rtl::OUString::createFromAscii( "com.sun.star.embed.EmbeddedObjectCreator" ) ),
201*cdf0e10cSrcweir 						uno::UNO_QUERY );
202*cdf0e10cSrcweir 			if ( !xEmbCreator.is() )
203*cdf0e10cSrcweir 				throw uno::RuntimeException();
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 			uno::Sequence< sal_Int8 > aClassID = MimeConfigurationHelper::GetSequenceClassID( io.clsid.Data1,
206*cdf0e10cSrcweir 																	 io.clsid.Data2,
207*cdf0e10cSrcweir 																	 io.clsid.Data3,
208*cdf0e10cSrcweir 																	 io.clsid.Data4[0],
209*cdf0e10cSrcweir 																	 io.clsid.Data4[1],
210*cdf0e10cSrcweir 																	 io.clsid.Data4[2],
211*cdf0e10cSrcweir 																	 io.clsid.Data4[3],
212*cdf0e10cSrcweir 																	 io.clsid.Data4[4],
213*cdf0e10cSrcweir 																	 io.clsid.Data4[5],
214*cdf0e10cSrcweir 																	 io.clsid.Data4[6],
215*cdf0e10cSrcweir 																	 io.clsid.Data4[7] );
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 			aClassID = GetRelatedInternalID_Impl( aClassID );
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 			//TODO: retrieve ClassName
220*cdf0e10cSrcweir 			::rtl::OUString aClassName;
221*cdf0e10cSrcweir 			aObjectInfo.Object = uno::Reference< embed::XEmbeddedObject >(
222*cdf0e10cSrcweir 							xEmbCreator->createInstanceInitNew( aClassID, aClassName, xStorage, sEntName, aObjArgs ),
223*cdf0e10cSrcweir 							uno::UNO_QUERY );
224*cdf0e10cSrcweir 		}
225*cdf0e10cSrcweir 		else
226*cdf0e10cSrcweir 		{
227*cdf0e10cSrcweir 			::rtl::OUString aFileName = ::rtl::OStringToOUString( ::rtl::OString( szFile ), osl_getThreadTextEncoding() );
228*cdf0e10cSrcweir     		rtl::OUString aFileURL;
229*cdf0e10cSrcweir         	if ( osl::FileBase::getFileURLFromSystemPath( aFileName, aFileURL ) != osl::FileBase::E_None )
230*cdf0e10cSrcweir 				throw uno::RuntimeException();
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 			uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
233*cdf0e10cSrcweir 			aMediaDescr[0].Name = ::rtl::OUString::createFromAscii( "URL" );
234*cdf0e10cSrcweir 			aMediaDescr[0].Value <<= aFileURL;
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 			// TODO: use config helper for type detection
237*cdf0e10cSrcweir 			uno::Reference< embed::XEmbedObjectCreator > xEmbCreator;
238*cdf0e10cSrcweir 			::comphelper::MimeConfigurationHelper aHelper( m_xFactory );
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 			if ( aHelper.AddFilterNameCheckOwnFile( aMediaDescr ) )
241*cdf0e10cSrcweir 				xEmbCreator = uno::Reference< embed::XEmbedObjectCreator >(
242*cdf0e10cSrcweir 						m_xFactory->createInstance(
243*cdf0e10cSrcweir 								::rtl::OUString::createFromAscii( "com.sun.star.embed.EmbeddedObjectCreator" ) ),
244*cdf0e10cSrcweir 						uno::UNO_QUERY );
245*cdf0e10cSrcweir 			else
246*cdf0e10cSrcweir 				xEmbCreator = uno::Reference< embed::XEmbedObjectCreator >(
247*cdf0e10cSrcweir 						m_xFactory->createInstance(
248*cdf0e10cSrcweir 								::rtl::OUString::createFromAscii( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) ),
249*cdf0e10cSrcweir 						uno::UNO_QUERY );
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 			if ( !xEmbCreator.is() )
252*cdf0e10cSrcweir 				throw uno::RuntimeException();
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 			aObjectInfo.Object = uno::Reference< embed::XEmbeddedObject >(
255*cdf0e10cSrcweir 							xEmbCreator->createInstanceInitFromMediaDescriptor( xStorage, sEntName, aMediaDescr, aObjArgs ),
256*cdf0e10cSrcweir 							uno::UNO_QUERY );
257*cdf0e10cSrcweir 		}
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 		if ( ( io.dwFlags & IOF_CHECKDISPLAYASICON) && io.hMetaPict != NULL )
260*cdf0e10cSrcweir 		{
261*cdf0e10cSrcweir 			METAFILEPICT* pMF = ( METAFILEPICT* )GlobalLock( io.hMetaPict );
262*cdf0e10cSrcweir 			if ( pMF )
263*cdf0e10cSrcweir 			{
264*cdf0e10cSrcweir 				sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, NULL );
265*cdf0e10cSrcweir 				uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 );
266*cdf0e10cSrcweir 				sal_uInt8* pBuf = (sal_uInt8*)( aMetafile.getArray() );
267*cdf0e10cSrcweir 				*( (long* )pBuf ) = 0x9ac6cdd7L;
268*cdf0e10cSrcweir 				*( (short* )( pBuf+6 )) = ( SHORT ) 0;
269*cdf0e10cSrcweir 				*( (short* )( pBuf+8 )) = ( SHORT ) 0;
270*cdf0e10cSrcweir 				*( (short* )( pBuf+10 )) = ( SHORT ) pMF->xExt;
271*cdf0e10cSrcweir 				*( (short* )( pBuf+12 )) = ( SHORT ) pMF->yExt;
272*cdf0e10cSrcweir 				*( (short* )( pBuf+14 )) = ( USHORT ) 2540;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 				if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) )
275*cdf0e10cSrcweir 				{
276*cdf0e10cSrcweir 					datatransfer::DataFlavor aFlavor(
277*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" ),
278*cdf0e10cSrcweir 						::rtl::OUString::createFromAscii( "Image WMF" ),
279*cdf0e10cSrcweir 						getCppuType( ( const uno::Sequence< sal_Int8 >* ) 0 ) );
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 					aObjectInfo.Options.realloc( 2 );
282*cdf0e10cSrcweir 					aObjectInfo.Options[0].Name = ::rtl::OUString::createFromAscii( "Icon" );
283*cdf0e10cSrcweir 					aObjectInfo.Options[0].Value <<= aMetafile;
284*cdf0e10cSrcweir 					aObjectInfo.Options[1].Name = ::rtl::OUString::createFromAscii( "IconFormat" );
285*cdf0e10cSrcweir 					aObjectInfo.Options[1].Value <<= aFlavor;
286*cdf0e10cSrcweir 				}
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 				GlobalUnlock( io.hMetaPict );
289*cdf0e10cSrcweir 			}
290*cdf0e10cSrcweir 		}
291*cdf0e10cSrcweir 	}
292*cdf0e10cSrcweir 	else
293*cdf0e10cSrcweir 		throw ucb::CommandAbortedException();
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir #else
296*cdf0e10cSrcweir 	throw lang::NoSupportException(); // TODO:
297*cdf0e10cSrcweir #endif
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 	OSL_ENSURE( aObjectInfo.Object.is(), "No object was created!\n" );
300*cdf0e10cSrcweir 	if ( !aObjectInfo.Object.is() )
301*cdf0e10cSrcweir 		throw uno::RuntimeException();
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 	return aObjectInfo;
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir //-------------------------------------------------------------------------
307*cdf0e10cSrcweir embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceInitFromClipboard(
308*cdf0e10cSrcweir 				const uno::Reference< embed::XStorage >& xStorage,
309*cdf0e10cSrcweir 				const ::rtl::OUString& sEntryName,
310*cdf0e10cSrcweir 				const uno::Sequence< beans::PropertyValue >& aObjectArgs )
311*cdf0e10cSrcweir 		throw ( lang::IllegalArgumentException,
312*cdf0e10cSrcweir 				io::IOException,
313*cdf0e10cSrcweir 				uno::Exception,
314*cdf0e10cSrcweir 				uno::RuntimeException )
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	embed::InsertedObjectInfo aObjectInfo;
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir #ifdef WNT
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	if ( !xStorage.is() )
321*cdf0e10cSrcweir 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
322*cdf0e10cSrcweir 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
323*cdf0e10cSrcweir 											1 );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	if ( !sEntryName.getLength() )
326*cdf0e10cSrcweir 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
327*cdf0e10cSrcweir 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
328*cdf0e10cSrcweir 											2 );
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 	uno::Reference< embed::XEmbeddedObject > xResult(
331*cdf0e10cSrcweir 					static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory ) ),
332*cdf0e10cSrcweir 					uno::UNO_QUERY );
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 	uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 	if ( !xPersist.is() )
337*cdf0e10cSrcweir 		throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 	xPersist->setPersistentEntry( xStorage,
340*cdf0e10cSrcweir 									sEntryName,
341*cdf0e10cSrcweir 									embed::EntryInitModes::DEFAULT_INIT,
342*cdf0e10cSrcweir 									uno::Sequence< beans::PropertyValue >(),
343*cdf0e10cSrcweir 									aObjectArgs );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 	aObjectInfo.Object = xResult;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	// TODO/LATER: in case of iconifie object the icon should be stored in aObjectInfo
348*cdf0e10cSrcweir #else
349*cdf0e10cSrcweir 	throw lang::NoSupportException(); // TODO:
350*cdf0e10cSrcweir #endif
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	OSL_ENSURE( aObjectInfo.Object.is(), "No object was created!\n" );
353*cdf0e10cSrcweir 	if ( !aObjectInfo.Object.is() )
354*cdf0e10cSrcweir 		throw uno::RuntimeException();
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	return aObjectInfo;
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir //-------------------------------------------------------------------------
360*cdf0e10cSrcweir ::rtl::OUString SAL_CALL MSOLEDialogObjectCreator::getImplementationName()
361*cdf0e10cSrcweir 	throw ( uno::RuntimeException )
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir 	return impl_staticGetImplementationName();
364*cdf0e10cSrcweir }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir //-------------------------------------------------------------------------
367*cdf0e10cSrcweir sal_Bool SAL_CALL MSOLEDialogObjectCreator::supportsService( const ::rtl::OUString& ServiceName )
368*cdf0e10cSrcweir 	throw ( uno::RuntimeException )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 	for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
373*cdf0e10cSrcweir     	if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
374*cdf0e10cSrcweir         	return sal_True;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 	return sal_False;
377*cdf0e10cSrcweir }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir //-------------------------------------------------------------------------
380*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL MSOLEDialogObjectCreator::getSupportedServiceNames()
381*cdf0e10cSrcweir 	throw ( uno::RuntimeException )
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir 	return impl_staticGetSupportedServiceNames();
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir 
386