1bfd08df8SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3bfd08df8SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4bfd08df8SAndrew Rist * or more contributor license agreements. See the NOTICE file
5bfd08df8SAndrew Rist * distributed with this work for additional information
6bfd08df8SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7bfd08df8SAndrew Rist * to you under the Apache License, Version 2.0 (the
8bfd08df8SAndrew Rist * "License"); you may not use this file except in compliance
9bfd08df8SAndrew Rist * with the License. You may obtain a copy of the License at
10bfd08df8SAndrew Rist *
11bfd08df8SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12bfd08df8SAndrew Rist *
13bfd08df8SAndrew Rist * Unless required by applicable law or agreed to in writing,
14bfd08df8SAndrew Rist * software distributed under the License is distributed on an
15bfd08df8SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16bfd08df8SAndrew Rist * KIND, either express or implied. See the License for the
17bfd08df8SAndrew Rist * specific language governing permissions and limitations
18bfd08df8SAndrew Rist * under the License.
19bfd08df8SAndrew Rist *
20bfd08df8SAndrew Rist *************************************************************/
21bfd08df8SAndrew Rist
22bfd08df8SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_embeddedobj.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <oleembobj.hxx>
28cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
29cdf0e10cSrcweir #include <com/sun/star/embed/EmbedVerbs.hpp>
30cdf0e10cSrcweir #include <com/sun/star/embed/EntryInitModes.hpp>
31cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
32cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
33cdf0e10cSrcweir #include <com/sun/star/embed/EmbedUpdateModes.hpp>
34cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp>
35cdf0e10cSrcweir #include <com/sun/star/embed/NeedsRunningStateException.hpp>
36cdf0e10cSrcweir #include <com/sun/star/embed/StateChangeInProgressException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMisc.hpp>
38cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
39cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
40cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
41cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
42cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43cdf0e10cSrcweir #include <com/sun/star/frame/XLoadable.hpp>
44cdf0e10cSrcweir #include <com/sun/star/document/XStorageBasedDocument.hpp>
45cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
46cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
47cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
48*9807c9deSAriel Constenla-Haile #include <com/sun/star/system/SystemShellExecute.hpp>
49cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
50cdf0e10cSrcweir
51cdf0e10cSrcweir #include <rtl/logfile.hxx>
52cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
53cdf0e10cSrcweir #include <comphelper/mimeconfighelper.hxx>
54cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
55*9807c9deSAriel Constenla-Haile #include <comphelper/processfactory.hxx>
56cdf0e10cSrcweir
57cdf0e10cSrcweir #include <targetstatecontrol.hxx>
58cdf0e10cSrcweir
59cdf0e10cSrcweir #include <olecomponent.hxx>
60cdf0e10cSrcweir
61cdf0e10cSrcweir #include "ownview.hxx"
62cdf0e10cSrcweir
63cdf0e10cSrcweir using namespace ::com::sun::star;
64cdf0e10cSrcweir
65cdf0e10cSrcweir #ifdef WNT
66cdf0e10cSrcweir //----------------------------------------------
SwitchComponentToRunningState_Impl()67cdf0e10cSrcweir void OleEmbeddedObject::SwitchComponentToRunningState_Impl()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir if ( m_pOleComponent )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir try
72cdf0e10cSrcweir {
73cdf0e10cSrcweir m_pOleComponent->RunObject();
74cdf0e10cSrcweir }
75cdf0e10cSrcweir catch( embed::UnreachableStateException& )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir GetRidOfComponent();
78cdf0e10cSrcweir throw;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir catch( embed::WrongStateException& )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir GetRidOfComponent();
83cdf0e10cSrcweir throw;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir }
86cdf0e10cSrcweir else
87cdf0e10cSrcweir {
88cdf0e10cSrcweir throw embed::UnreachableStateException();
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir //----------------------------------------------
GetReachableStatesList_Impl(const uno::Sequence<embed::VerbDescriptor> & aVerbList)93cdf0e10cSrcweir uno::Sequence< sal_Int32 > OleEmbeddedObject::GetReachableStatesList_Impl(
94cdf0e10cSrcweir const uno::Sequence< embed::VerbDescriptor >& aVerbList )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir uno::Sequence< sal_Int32 > aStates(2);
97cdf0e10cSrcweir aStates[0] = embed::EmbedStates::LOADED;
98cdf0e10cSrcweir aStates[1] = embed::EmbedStates::RUNNING;
99cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aVerbList.getLength(); nInd++ )
100cdf0e10cSrcweir if ( aVerbList[nInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir aStates.realloc(3);
103cdf0e10cSrcweir aStates[2] = embed::EmbedStates::ACTIVE;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir return aStates;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir //----------------------------------------------
GetIntermediateVerbsSequence_Impl(sal_Int32 nNewState)110cdf0e10cSrcweir uno::Sequence< sal_Int32 > OleEmbeddedObject::GetIntermediateVerbsSequence_Impl( sal_Int32 nNewState )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir OSL_ENSURE( m_nObjectState != embed::EmbedStates::LOADED, "Loaded object is switched to running state without verbs using!" );
113cdf0e10cSrcweir
114cdf0e10cSrcweir // actually there will be only one verb
115cdf0e10cSrcweir if ( m_nObjectState == embed::EmbedStates::RUNNING && nNewState == embed::EmbedStates::ACTIVE )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir uno::Sequence< sal_Int32 > aVerbs( 1 );
118cdf0e10cSrcweir aVerbs[0] = embed::EmbedVerbs::MS_OLEVERB_OPEN;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir return uno::Sequence< sal_Int32 >();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir //----------------------------------------------
MoveListeners()125cdf0e10cSrcweir void OleEmbeddedObject::MoveListeners()
126cdf0e10cSrcweir {
127cdf0e10cSrcweir if ( m_pInterfaceContainer )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir // move state change listeners
130cdf0e10cSrcweir {
131cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pStateChangeContainer =
132cdf0e10cSrcweir m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< embed::XStateChangeListener >*) NULL ) );
133cdf0e10cSrcweir if ( pStateChangeContainer != NULL )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir uno::Reference< embed::XStateChangeBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
136cdf0e10cSrcweir if ( xWrappedObject.is() )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator( *pStateChangeContainer );
139cdf0e10cSrcweir while ( pIterator.hasMoreElements() )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir try
142cdf0e10cSrcweir {
143cdf0e10cSrcweir xWrappedObject->addStateChangeListener( (embed::XStateChangeListener*)pIterator.next() );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir catch( uno::RuntimeException& )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir pIterator.remove();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir // move event listeners
155cdf0e10cSrcweir {
156cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pEventContainer =
157cdf0e10cSrcweir m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< document::XEventListener >*) NULL ) );
158cdf0e10cSrcweir if ( pEventContainer != NULL )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir uno::Reference< document::XEventBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
161cdf0e10cSrcweir if ( xWrappedObject.is() )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator( *pEventContainer );
164cdf0e10cSrcweir while ( pIterator.hasMoreElements() )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir try
167cdf0e10cSrcweir {
168cdf0e10cSrcweir xWrappedObject->addEventListener( (document::XEventListener*)pIterator.next() );
169cdf0e10cSrcweir }
170cdf0e10cSrcweir catch( uno::RuntimeException& )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir pIterator.remove();
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir // move close listeners
180cdf0e10cSrcweir {
181cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pCloseContainer =
182cdf0e10cSrcweir m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
183cdf0e10cSrcweir if ( pCloseContainer != NULL )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir uno::Reference< util::XCloseBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
186cdf0e10cSrcweir if ( xWrappedObject.is() )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator( *pCloseContainer );
189cdf0e10cSrcweir while ( pIterator.hasMoreElements() )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir try
192cdf0e10cSrcweir {
193cdf0e10cSrcweir xWrappedObject->addCloseListener( (util::XCloseListener*)pIterator.next() );
194cdf0e10cSrcweir }
195cdf0e10cSrcweir catch( uno::RuntimeException& )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir pIterator.remove();
198cdf0e10cSrcweir }
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir }
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
204cdf0e10cSrcweir delete m_pInterfaceContainer;
205cdf0e10cSrcweir m_pInterfaceContainer = NULL;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
209cdf0e10cSrcweir //----------------------------------------------
CreateTemporarySubstorage(::rtl::OUString & o_aStorageName)210cdf0e10cSrcweir uno::Reference< embed::XStorage > OleEmbeddedObject::CreateTemporarySubstorage( ::rtl::OUString& o_aStorageName )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir uno::Reference< embed::XStorage > xResult;
213cdf0e10cSrcweir
214cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < 32000 && !xResult.is(); nInd++ )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir ::rtl::OUString aName = ::rtl::OUString::valueOf( nInd );
217cdf0e10cSrcweir aName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TMPSTOR" ) );
218cdf0e10cSrcweir aName += m_aEntryName;
219cdf0e10cSrcweir if ( !m_xParentStorage->hasByName( aName ) )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir xResult = m_xParentStorage->openStorageElement( aName, embed::ElementModes::READWRITE );
222cdf0e10cSrcweir o_aStorageName = aName;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir if ( !xResult.is() )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir o_aStorageName = ::rtl::OUString();
229cdf0e10cSrcweir throw uno::RuntimeException();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir return xResult;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir //----------------------------------------------
MoveToTemporarySubstream()236cdf0e10cSrcweir ::rtl::OUString OleEmbeddedObject::MoveToTemporarySubstream()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir ::rtl::OUString aResult;
239cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < 32000 && !aResult.getLength(); nInd++ )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir ::rtl::OUString aName = ::rtl::OUString::valueOf( nInd );
242cdf0e10cSrcweir aName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TMPSTREAM" ) );
243cdf0e10cSrcweir aName += m_aEntryName;
244cdf0e10cSrcweir if ( !m_xParentStorage->hasByName( aName ) )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir m_xParentStorage->renameElement( m_aEntryName, aName );
247cdf0e10cSrcweir aResult = aName;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
251cdf0e10cSrcweir if ( !aResult.getLength() )
252cdf0e10cSrcweir throw uno::RuntimeException();
253cdf0e10cSrcweir
254cdf0e10cSrcweir return aResult;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
257cdf0e10cSrcweir //----------------------------------------------
TryToConvertToOOo()258cdf0e10cSrcweir sal_Bool OleEmbeddedObject::TryToConvertToOOo()
259cdf0e10cSrcweir {
260cdf0e10cSrcweir sal_Bool bResult = sal_False;
261cdf0e10cSrcweir
262cdf0e10cSrcweir ::rtl::OUString aStorageName;
263cdf0e10cSrcweir ::rtl::OUString aTmpStreamName;
264cdf0e10cSrcweir sal_Int32 nStep = 0;
265cdf0e10cSrcweir
266cdf0e10cSrcweir if ( m_pOleComponent || m_bReadOnly )
267cdf0e10cSrcweir return sal_False;
268cdf0e10cSrcweir
269cdf0e10cSrcweir try
270cdf0e10cSrcweir {
271cdf0e10cSrcweir changeState( embed::EmbedStates::LOADED );
272cdf0e10cSrcweir
273cdf0e10cSrcweir // the stream must be seekable
274cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY_THROW );
275cdf0e10cSrcweir xSeekable->seek( 0 );
276cdf0e10cSrcweir ::rtl::OUString aFilterName = OwnView_Impl::GetFilterNameFromExtentionAndInStream( m_xFactory, ::rtl::OUString(), m_xObjectStream->getInputStream() );
277cdf0e10cSrcweir
278cdf0e10cSrcweir // use the solution only for OOXML format currently
279cdf0e10cSrcweir if ( aFilterName.getLength()
280cdf0e10cSrcweir && ( aFilterName.equals( ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "Calc MS Excel 2007 XML" ) ) )
281cdf0e10cSrcweir || aFilterName.equals( ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "Impress MS PowerPoint 2007 XML" ) ) )
282cdf0e10cSrcweir || aFilterName.equals( ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "MS Word 2007 XML" ) ) ) ) )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir uno::Reference< container::XNameAccess > xFilterFactory(
285cdf0e10cSrcweir m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" ) ),
286cdf0e10cSrcweir uno::UNO_QUERY_THROW );
287cdf0e10cSrcweir
288cdf0e10cSrcweir ::rtl::OUString aDocServiceName;
289cdf0e10cSrcweir uno::Any aFilterAnyData = xFilterFactory->getByName( aFilterName );
290cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aFilterData;
291cdf0e10cSrcweir if ( aFilterAnyData >>= aFilterData )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ )
294cdf0e10cSrcweir if ( aFilterData[nInd].Name.equalsAscii( "DocumentService" ) )
295cdf0e10cSrcweir aFilterData[nInd].Value >>= aDocServiceName;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
298cdf0e10cSrcweir if ( aDocServiceName.getLength() )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir // create the model
301cdf0e10cSrcweir uno::Sequence< uno::Any > aArguments(1);
302cdf0e10cSrcweir aArguments[0] <<= beans::NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EmbeddedObject" ) ), uno::makeAny( (sal_Bool)sal_True ));
303cdf0e10cSrcweir
304cdf0e10cSrcweir uno::Reference< util::XCloseable > xDocument( m_xFactory->createInstanceWithArguments( aDocServiceName, aArguments ), uno::UNO_QUERY_THROW );
305cdf0e10cSrcweir uno::Reference< frame::XLoadable > xLoadable( xDocument, uno::UNO_QUERY_THROW );
306cdf0e10cSrcweir uno::Reference< document::XStorageBasedDocument > xStorDoc( xDocument, uno::UNO_QUERY_THROW );
307cdf0e10cSrcweir
308cdf0e10cSrcweir // let the model behave as embedded one
309cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( xDocument, uno::UNO_QUERY_THROW );
310cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aSeq( 1 );
311cdf0e10cSrcweir aSeq[0].Name = ::rtl::OUString::createFromAscii( "SetEmbedded" );
312cdf0e10cSrcweir aSeq[0].Value <<= sal_True;
313cdf0e10cSrcweir xModel->attachResource( ::rtl::OUString(), aSeq );
314cdf0e10cSrcweir
315cdf0e10cSrcweir // load the model from the stream
316cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs( 5 );
317cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString::createFromAscii( "HierarchicalDocumentName" );
318cdf0e10cSrcweir aArgs[0].Value <<= m_aEntryName;
319cdf0e10cSrcweir aArgs[1].Name = ::rtl::OUString::createFromAscii( "ReadOnly" );
320cdf0e10cSrcweir aArgs[1].Value <<= sal_True;
321cdf0e10cSrcweir aArgs[2].Name = ::rtl::OUString::createFromAscii( "FilterName" );
322cdf0e10cSrcweir aArgs[2].Value <<= aFilterName;
323cdf0e10cSrcweir aArgs[3].Name = ::rtl::OUString::createFromAscii( "URL" );
324cdf0e10cSrcweir aArgs[3].Value <<= ::rtl::OUString::createFromAscii( "private:stream" );
325cdf0e10cSrcweir aArgs[4].Name = ::rtl::OUString::createFromAscii( "InputStream" );
326cdf0e10cSrcweir aArgs[4].Value <<= m_xObjectStream->getInputStream();
327cdf0e10cSrcweir
328cdf0e10cSrcweir xSeekable->seek( 0 );
329cdf0e10cSrcweir xLoadable->load( aArgs );
330cdf0e10cSrcweir
331cdf0e10cSrcweir // the model is successfuly loaded, create a new storage and store the model to the storage
332cdf0e10cSrcweir uno::Reference< embed::XStorage > xTmpStorage = CreateTemporarySubstorage( aStorageName );
333cdf0e10cSrcweir xStorDoc->storeToStorage( xTmpStorage, uno::Sequence< beans::PropertyValue >() );
334cdf0e10cSrcweir xDocument->close( sal_True );
335cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xStorProps( xTmpStorage, uno::UNO_QUERY_THROW );
336cdf0e10cSrcweir ::rtl::OUString aMediaType;
337cdf0e10cSrcweir xStorProps->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) ) >>= aMediaType;
338cdf0e10cSrcweir xTmpStorage->dispose();
339cdf0e10cSrcweir
340cdf0e10cSrcweir // look for the related embedded object factory
341cdf0e10cSrcweir ::comphelper::MimeConfigurationHelper aConfigHelper( m_xFactory );
342cdf0e10cSrcweir ::rtl::OUString aEmbedFactory;
343cdf0e10cSrcweir if ( aMediaType.getLength() )
344cdf0e10cSrcweir aEmbedFactory = aConfigHelper.GetFactoryNameByMediaType( aMediaType );
345cdf0e10cSrcweir
346cdf0e10cSrcweir if ( !aEmbedFactory.getLength() )
347cdf0e10cSrcweir throw uno::RuntimeException();
348cdf0e10cSrcweir
349cdf0e10cSrcweir uno::Reference< uno::XInterface > xFact = m_xFactory->createInstance( aEmbedFactory );
350cdf0e10cSrcweir
351cdf0e10cSrcweir uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY_THROW );
352cdf0e10cSrcweir
353cdf0e10cSrcweir // now the object should be adjusted to become the wrapper
354cdf0e10cSrcweir nStep = 1;
355cdf0e10cSrcweir uno::Reference< lang::XComponent > xComp( m_xObjectStream, uno::UNO_QUERY_THROW );
356cdf0e10cSrcweir xComp->dispose();
357cdf0e10cSrcweir m_xObjectStream = uno::Reference< io::XStream >();
358cdf0e10cSrcweir m_nObjectState = -1;
359cdf0e10cSrcweir
360cdf0e10cSrcweir nStep = 2;
361cdf0e10cSrcweir aTmpStreamName = MoveToTemporarySubstream();
362cdf0e10cSrcweir
363cdf0e10cSrcweir nStep = 3;
364cdf0e10cSrcweir m_xParentStorage->renameElement( aStorageName, m_aEntryName );
365cdf0e10cSrcweir
366cdf0e10cSrcweir nStep = 4;
367cdf0e10cSrcweir m_xWrappedObject.set( xEmbCreator->createInstanceInitFromEntry( m_xParentStorage, m_aEntryName, uno::Sequence< beans::PropertyValue >(), uno::Sequence< beans::PropertyValue >() ), uno::UNO_QUERY_THROW );
368cdf0e10cSrcweir
369cdf0e10cSrcweir bResult = sal_True; // the change is no more revertable
370cdf0e10cSrcweir try
371cdf0e10cSrcweir {
372cdf0e10cSrcweir m_xParentStorage->removeElement( aTmpStreamName );
373cdf0e10cSrcweir }
374cdf0e10cSrcweir catch( uno::Exception& )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir // the success of the removing is not so important
377cdf0e10cSrcweir }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir }
380cdf0e10cSrcweir }
381cdf0e10cSrcweir catch( uno::Exception& )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir // repair the object if necessary
384cdf0e10cSrcweir switch( nStep )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir case 4:
387cdf0e10cSrcweir case 3:
388cdf0e10cSrcweir if ( aTmpStreamName.getLength() && aTmpStreamName != m_aEntryName )
389cdf0e10cSrcweir try
390cdf0e10cSrcweir {
391cdf0e10cSrcweir if ( m_xParentStorage->hasByName( m_aEntryName ) )
392cdf0e10cSrcweir m_xParentStorage->removeElement( m_aEntryName );
393cdf0e10cSrcweir m_xParentStorage->renameElement( aTmpStreamName, m_aEntryName );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir catch ( uno::Exception& )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir try {
398cdf0e10cSrcweir close( sal_True );
399cdf0e10cSrcweir } catch( uno::Exception& ) {}
400cdf0e10cSrcweir
401cdf0e10cSrcweir m_xParentStorage->dispose(); // ??? the storage has information loss, it should be closed without commiting!
402cdf0e10cSrcweir throw uno::RuntimeException(); // the repairing is not possible
403cdf0e10cSrcweir }
404cdf0e10cSrcweir case 2:
405cdf0e10cSrcweir try
406cdf0e10cSrcweir {
407cdf0e10cSrcweir m_xObjectStream = m_xParentStorage->openStreamElement( m_aEntryName, m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE );
408cdf0e10cSrcweir m_nObjectState = embed::EmbedStates::LOADED;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir catch( uno::Exception& )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir try {
413cdf0e10cSrcweir close( sal_True );
414cdf0e10cSrcweir } catch( uno::Exception& ) {}
415cdf0e10cSrcweir
416cdf0e10cSrcweir throw uno::RuntimeException(); // the repairing is not possible
417cdf0e10cSrcweir }
418cdf0e10cSrcweir // no break as designed!
419cdf0e10cSrcweir
420cdf0e10cSrcweir case 1:
421cdf0e10cSrcweir case 0:
422cdf0e10cSrcweir if ( aStorageName.getLength() )
423cdf0e10cSrcweir try {
424cdf0e10cSrcweir m_xParentStorage->removeElement( aStorageName );
425cdf0e10cSrcweir } catch( uno::Exception& ) { OSL_ASSERT( "Can not remove temporary storage!" ); }
426cdf0e10cSrcweir break;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir }
429cdf0e10cSrcweir
430cdf0e10cSrcweir if ( bResult )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir // the conversion was done successfuly, now the additional initializations should happen
433cdf0e10cSrcweir
434cdf0e10cSrcweir MoveListeners();
435cdf0e10cSrcweir m_xWrappedObject->setClientSite( m_xClientSite );
436cdf0e10cSrcweir if ( m_xParent.is() )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir uno::Reference< container::XChild > xChild( m_xWrappedObject, uno::UNO_QUERY );
439cdf0e10cSrcweir if ( xChild.is() )
440cdf0e10cSrcweir xChild->setParent( m_xParent );
441cdf0e10cSrcweir }
442cdf0e10cSrcweir
443cdf0e10cSrcweir }
444cdf0e10cSrcweir
445cdf0e10cSrcweir return bResult;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir //----------------------------------------------
changeState(sal_Int32 nNewState)449cdf0e10cSrcweir void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
450cdf0e10cSrcweir throw ( embed::UnreachableStateException,
451cdf0e10cSrcweir embed::WrongStateException,
452cdf0e10cSrcweir uno::Exception,
453cdf0e10cSrcweir uno::RuntimeException )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OleEmbeddedObject::changeState" );
456cdf0e10cSrcweir
457cdf0e10cSrcweir // begin wrapping related part ====================
458cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
459cdf0e10cSrcweir if ( xWrappedObject.is() )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
462cdf0e10cSrcweir xWrappedObject->changeState( nNewState );
463cdf0e10cSrcweir return;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir // end wrapping related part ====================
466cdf0e10cSrcweir
467cdf0e10cSrcweir ::osl::ResettableMutexGuard aGuard( m_aMutex );
468cdf0e10cSrcweir
469cdf0e10cSrcweir if ( m_bDisposed )
470cdf0e10cSrcweir throw lang::DisposedException(); // TODO
471cdf0e10cSrcweir
472cdf0e10cSrcweir if ( m_nObjectState == -1 )
473cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
474cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
475cdf0e10cSrcweir
476cdf0e10cSrcweir // in case the object is already in requested state
477cdf0e10cSrcweir if ( m_nObjectState == nNewState )
478cdf0e10cSrcweir return;
479cdf0e10cSrcweir
480cdf0e10cSrcweir #ifdef WNT
481cdf0e10cSrcweir if ( m_pOleComponent )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir if ( m_nTargetState != -1 )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir // means that the object is currently trying to reach the target state
486cdf0e10cSrcweir throw embed::StateChangeInProgressException( ::rtl::OUString(),
487cdf0e10cSrcweir uno::Reference< uno::XInterface >(),
488cdf0e10cSrcweir m_nTargetState );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir
491cdf0e10cSrcweir TargetStateControl_Impl aControl( m_nTargetState, nNewState );
492cdf0e10cSrcweir
493cdf0e10cSrcweir // TODO: additional verbs can be a problem, since nobody knows how the object
494cdf0e10cSrcweir // will behave after activation
495cdf0e10cSrcweir
496cdf0e10cSrcweir sal_Int32 nOldState = m_nObjectState;
497cdf0e10cSrcweir aGuard.clear();
498cdf0e10cSrcweir StateChangeNotification_Impl( sal_True, nOldState, nNewState );
499cdf0e10cSrcweir aGuard.reset();
500cdf0e10cSrcweir
501cdf0e10cSrcweir try
502cdf0e10cSrcweir {
503cdf0e10cSrcweir if ( nNewState == embed::EmbedStates::LOADED )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir // This means just closing of the current object
506cdf0e10cSrcweir // If component can not be closed the object stays in loaded state
507cdf0e10cSrcweir // and it holds reference to "incomplete" component
508cdf0e10cSrcweir // If the object is switched to running state later
509cdf0e10cSrcweir // the component will become "complete"
510cdf0e10cSrcweir
511cdf0e10cSrcweir // the loaded state must be set before, because of notifications!
512cdf0e10cSrcweir m_nObjectState = nNewState;
513cdf0e10cSrcweir
514cdf0e10cSrcweir {
515cdf0e10cSrcweir VerbExecutionControllerGuard aVerbGuard( m_aVerbExecutionController );
516cdf0e10cSrcweir m_pOleComponent->CloseObject();
517cdf0e10cSrcweir }
518cdf0e10cSrcweir
519cdf0e10cSrcweir // GetRidOfComponent();
520cdf0e10cSrcweir aGuard.clear();
521cdf0e10cSrcweir StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState );
522cdf0e10cSrcweir aGuard.reset();
523cdf0e10cSrcweir }
524cdf0e10cSrcweir else if ( nNewState == embed::EmbedStates::RUNNING || nNewState == embed::EmbedStates::ACTIVE )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir if ( m_nObjectState == embed::EmbedStates::LOADED )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir // if the target object is in loaded state and a different state is specified
529cdf0e10cSrcweir // as a new one the object first must be switched to running state.
530cdf0e10cSrcweir
531cdf0e10cSrcweir // the component can exist already in nonrunning state
532cdf0e10cSrcweir // it can be created during loading to detect type of object
533cdf0e10cSrcweir CreateOleComponentAndLoad_Impl( m_pOleComponent );
534cdf0e10cSrcweir
535cdf0e10cSrcweir SwitchComponentToRunningState_Impl();
536cdf0e10cSrcweir m_nObjectState = embed::EmbedStates::RUNNING;
537cdf0e10cSrcweir aGuard.clear();
538cdf0e10cSrcweir StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState );
539cdf0e10cSrcweir aGuard.reset();
540cdf0e10cSrcweir
541cdf0e10cSrcweir if ( m_pOleComponent && m_bHasSizeToSet )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir aGuard.clear();
544cdf0e10cSrcweir try {
545cdf0e10cSrcweir m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet );
546cdf0e10cSrcweir m_bHasSizeToSet = sal_False;
547cdf0e10cSrcweir }
548cdf0e10cSrcweir catch( uno::Exception& ) {}
549cdf0e10cSrcweir aGuard.reset();
550cdf0e10cSrcweir }
551cdf0e10cSrcweir
552cdf0e10cSrcweir if ( m_nObjectState == nNewState )
553cdf0e10cSrcweir return;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
556cdf0e10cSrcweir // so now the object is either switched from Active to Running state or vise versa
557cdf0e10cSrcweir // the notification about object state change will be done asynchronously
558cdf0e10cSrcweir if ( m_nObjectState == embed::EmbedStates::RUNNING && nNewState == embed::EmbedStates::ACTIVE )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir // execute OPEN verb, if object does not reach active state it is an object's problem
561cdf0e10cSrcweir aGuard.clear();
562cdf0e10cSrcweir m_pOleComponent->ExecuteVerb( embed::EmbedVerbs::MS_OLEVERB_OPEN );
563cdf0e10cSrcweir aGuard.reset();
564cdf0e10cSrcweir
565cdf0e10cSrcweir // some objects do not allow to set the size even in running state
566cdf0e10cSrcweir if ( m_pOleComponent && m_bHasSizeToSet )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir aGuard.clear();
569cdf0e10cSrcweir try {
570cdf0e10cSrcweir m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet );
571cdf0e10cSrcweir m_bHasSizeToSet = sal_False;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir catch( uno::Exception& ) {}
574cdf0e10cSrcweir aGuard.reset();
575cdf0e10cSrcweir }
576cdf0e10cSrcweir
577cdf0e10cSrcweir m_nObjectState = nNewState;
578cdf0e10cSrcweir }
579cdf0e10cSrcweir else if ( m_nObjectState == embed::EmbedStates::ACTIVE && nNewState == embed::EmbedStates::RUNNING )
580cdf0e10cSrcweir {
581cdf0e10cSrcweir aGuard.clear();
582cdf0e10cSrcweir m_pOleComponent->CloseObject();
583cdf0e10cSrcweir m_pOleComponent->RunObject(); // Should not fail, the object already was active
584cdf0e10cSrcweir aGuard.reset();
585cdf0e10cSrcweir m_nObjectState = nNewState;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir else
588cdf0e10cSrcweir {
589cdf0e10cSrcweir throw embed::UnreachableStateException();
590cdf0e10cSrcweir }
591cdf0e10cSrcweir }
592cdf0e10cSrcweir else
593cdf0e10cSrcweir throw embed::UnreachableStateException();
594cdf0e10cSrcweir }
595cdf0e10cSrcweir catch( uno::Exception& )
596cdf0e10cSrcweir {
597cdf0e10cSrcweir aGuard.clear();
598cdf0e10cSrcweir StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState );
599cdf0e10cSrcweir throw;
600cdf0e10cSrcweir }
601cdf0e10cSrcweir }
602cdf0e10cSrcweir else
603cdf0e10cSrcweir #endif
604cdf0e10cSrcweir {
605cdf0e10cSrcweir throw embed::UnreachableStateException();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir //----------------------------------------------
getReachableStates()610cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL OleEmbeddedObject::getReachableStates()
611cdf0e10cSrcweir throw ( embed::WrongStateException,
612cdf0e10cSrcweir uno::RuntimeException )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OleEmbeddedObject::getReachableStates" );
615cdf0e10cSrcweir
616cdf0e10cSrcweir // begin wrapping related part ====================
617cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
618cdf0e10cSrcweir if ( xWrappedObject.is() )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
621cdf0e10cSrcweir return xWrappedObject->getReachableStates();
622cdf0e10cSrcweir }
623cdf0e10cSrcweir // end wrapping related part ====================
624cdf0e10cSrcweir
625cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
626cdf0e10cSrcweir if ( m_bDisposed )
627cdf0e10cSrcweir throw lang::DisposedException(); // TODO
628cdf0e10cSrcweir
629cdf0e10cSrcweir if ( m_nObjectState == -1 )
630cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
631cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
632cdf0e10cSrcweir
633cdf0e10cSrcweir #ifdef WNT
634cdf0e10cSrcweir if ( m_pOleComponent )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir if ( m_nObjectState == embed::EmbedStates::LOADED )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir // the list of supported verbs can be retrieved only when object is in running state
639cdf0e10cSrcweir throw embed::NeedsRunningStateException(); // TODO:
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
642cdf0e10cSrcweir // the list of states can only be guessed based on standard verbs,
643cdf0e10cSrcweir // since there is no way to detect what additional verbs do
644cdf0e10cSrcweir return GetReachableStatesList_Impl( m_pOleComponent->GetVerbList() );
645cdf0e10cSrcweir }
646cdf0e10cSrcweir else
647cdf0e10cSrcweir #endif
648cdf0e10cSrcweir {
649cdf0e10cSrcweir return uno::Sequence< sal_Int32 >();
650cdf0e10cSrcweir }
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
653cdf0e10cSrcweir //----------------------------------------------
getCurrentState()654cdf0e10cSrcweir sal_Int32 SAL_CALL OleEmbeddedObject::getCurrentState()
655cdf0e10cSrcweir throw ( embed::WrongStateException,
656cdf0e10cSrcweir uno::RuntimeException )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir // begin wrapping related part ====================
659cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
660cdf0e10cSrcweir if ( xWrappedObject.is() )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
663cdf0e10cSrcweir return xWrappedObject->getCurrentState();
664cdf0e10cSrcweir }
665cdf0e10cSrcweir // end wrapping related part ====================
666cdf0e10cSrcweir
667cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
668cdf0e10cSrcweir if ( m_bDisposed )
669cdf0e10cSrcweir throw lang::DisposedException(); // TODO
670cdf0e10cSrcweir
671cdf0e10cSrcweir if ( m_nObjectState == -1 )
672cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
673cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
674cdf0e10cSrcweir
675cdf0e10cSrcweir // TODO: Shouldn't we ask object? ( I guess no )
676cdf0e10cSrcweir return m_nObjectState;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir
679cdf0e10cSrcweir namespace
680cdf0e10cSrcweir {
lcl_CopyStream(uno::Reference<io::XInputStream> xIn,uno::Reference<io::XOutputStream> xOut)681cdf0e10cSrcweir bool lcl_CopyStream(uno::Reference<io::XInputStream> xIn, uno::Reference<io::XOutputStream> xOut)
682cdf0e10cSrcweir {
683cdf0e10cSrcweir const sal_Int32 nChunkSize = 4096;
684cdf0e10cSrcweir uno::Sequence< sal_Int8 > aData(nChunkSize);
685cdf0e10cSrcweir sal_Int32 nTotalRead = 0;
686cdf0e10cSrcweir sal_Int32 nRead;
687cdf0e10cSrcweir do
688cdf0e10cSrcweir {
689cdf0e10cSrcweir nRead = xIn->readBytes(aData, nChunkSize);
690cdf0e10cSrcweir nTotalRead += nRead;
691cdf0e10cSrcweir xOut->writeBytes(aData);
692cdf0e10cSrcweir } while (nRead == nChunkSize);
693cdf0e10cSrcweir return nTotalRead != 0;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
696cdf0e10cSrcweir //Dump the objects content to a tempfile, just the "CONTENTS" stream if
697cdf0e10cSrcweir //there is one for non-compound documents, otherwise the whole content.
698cdf0e10cSrcweir //
699cdf0e10cSrcweir //On success a file is returned which must be removed by the caller
lcl_ExtractObject(::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> xFactory,::com::sun::star::uno::Reference<::com::sun::star::io::XStream> xObjectStream)700cdf0e10cSrcweir rtl::OUString lcl_ExtractObject(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory,
701cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xObjectStream)
702cdf0e10cSrcweir {
703cdf0e10cSrcweir rtl::OUString sUrl;
704cdf0e10cSrcweir
705cdf0e10cSrcweir // the solution is only active for Unix systems
706cdf0e10cSrcweir #ifndef WNT
707cdf0e10cSrcweir uno::Reference <beans::XPropertySet> xNativeTempFile(
708cdf0e10cSrcweir xFactory->createInstance(
709cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile"))), uno::UNO_QUERY_THROW);
710cdf0e10cSrcweir uno::Reference < io::XStream > xStream(xNativeTempFile, uno::UNO_QUERY_THROW);
711cdf0e10cSrcweir
712cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 2 );
713cdf0e10cSrcweir aArgs[0] <<= xObjectStream;
714cdf0e10cSrcweir aArgs[1] <<= (sal_Bool)sal_True; // do not create copy
715cdf0e10cSrcweir uno::Reference< container::XNameContainer > xNameContainer(
716cdf0e10cSrcweir xFactory->createInstanceWithArguments(
717cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.OLESimpleStorage")),
718cdf0e10cSrcweir aArgs ), uno::UNO_QUERY_THROW );
719cdf0e10cSrcweir
720cdf0e10cSrcweir uno::Reference< io::XStream > xCONTENTS;
721cdf0e10cSrcweir xNameContainer->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONTENTS"))) >>= xCONTENTS;
722cdf0e10cSrcweir
723cdf0e10cSrcweir sal_Bool bCopied = xCONTENTS.is() && lcl_CopyStream(xCONTENTS->getInputStream(), xStream->getOutputStream());
724cdf0e10cSrcweir
725cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeekableStor(xObjectStream, uno::UNO_QUERY);
726cdf0e10cSrcweir if (xSeekableStor.is())
727cdf0e10cSrcweir xSeekableStor->seek(0);
728cdf0e10cSrcweir
729cdf0e10cSrcweir if (!bCopied)
730cdf0e10cSrcweir bCopied = lcl_CopyStream(xObjectStream->getInputStream(), xStream->getOutputStream());
731cdf0e10cSrcweir
732cdf0e10cSrcweir if (bCopied)
733cdf0e10cSrcweir {
734cdf0e10cSrcweir xNativeTempFile->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveFile")),
735cdf0e10cSrcweir uno::makeAny(sal_False));
736cdf0e10cSrcweir uno::Any aUrl = xNativeTempFile->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Uri")));
737cdf0e10cSrcweir aUrl >>= sUrl;
738cdf0e10cSrcweir
739cdf0e10cSrcweir xNativeTempFile = uno::Reference<beans::XPropertySet>();
740cdf0e10cSrcweir
741cdf0e10cSrcweir uno::Reference<ucb::XSimpleFileAccess> xSimpleFileAccess(
742cdf0e10cSrcweir xFactory->createInstance(
743cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))),
744cdf0e10cSrcweir uno::UNO_QUERY_THROW);
745cdf0e10cSrcweir
746cdf0e10cSrcweir xSimpleFileAccess->setReadOnly(sUrl, sal_True);
747cdf0e10cSrcweir }
748cdf0e10cSrcweir else
749cdf0e10cSrcweir {
750cdf0e10cSrcweir xNativeTempFile->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveFile")),
751cdf0e10cSrcweir uno::makeAny(sal_True));
752cdf0e10cSrcweir }
753cdf0e10cSrcweir #endif
754cdf0e10cSrcweir return sUrl;
755cdf0e10cSrcweir }
756cdf0e10cSrcweir }
757cdf0e10cSrcweir
758cdf0e10cSrcweir //----------------------------------------------
doVerb(sal_Int32 nVerbID)759cdf0e10cSrcweir void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
760cdf0e10cSrcweir throw ( lang::IllegalArgumentException,
761cdf0e10cSrcweir embed::WrongStateException,
762cdf0e10cSrcweir embed::UnreachableStateException,
763cdf0e10cSrcweir uno::Exception,
764cdf0e10cSrcweir uno::RuntimeException )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OleEmbeddedObject::doVerb" );
767cdf0e10cSrcweir
768cdf0e10cSrcweir // begin wrapping related part ====================
769cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
770cdf0e10cSrcweir if ( xWrappedObject.is() )
771cdf0e10cSrcweir {
772cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
773cdf0e10cSrcweir xWrappedObject->doVerb( nVerbID );
774cdf0e10cSrcweir return;
775cdf0e10cSrcweir }
776cdf0e10cSrcweir // end wrapping related part ====================
777cdf0e10cSrcweir
778cdf0e10cSrcweir ::osl::ResettableMutexGuard aGuard( m_aMutex );
779cdf0e10cSrcweir if ( m_bDisposed )
780cdf0e10cSrcweir throw lang::DisposedException(); // TODO
781cdf0e10cSrcweir
782cdf0e10cSrcweir if ( m_nObjectState == -1 )
783cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
784cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
785cdf0e10cSrcweir
786cdf0e10cSrcweir #ifdef WNT
787cdf0e10cSrcweir if ( m_pOleComponent )
788cdf0e10cSrcweir {
789cdf0e10cSrcweir sal_Int32 nOldState = m_nObjectState;
790cdf0e10cSrcweir
791cdf0e10cSrcweir // TODO/LATER detect target state here and do a notification
792cdf0e10cSrcweir // StateChangeNotification_Impl( sal_True, nOldState, nNewState );
793cdf0e10cSrcweir if ( m_nObjectState == embed::EmbedStates::LOADED )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir // if the target object is in loaded state
796cdf0e10cSrcweir // it must be switched to running state to execute verb
797cdf0e10cSrcweir aGuard.clear();
798cdf0e10cSrcweir changeState( embed::EmbedStates::RUNNING );
799cdf0e10cSrcweir aGuard.reset();
800cdf0e10cSrcweir }
801cdf0e10cSrcweir
802cdf0e10cSrcweir try {
803cdf0e10cSrcweir if ( !m_pOleComponent )
804cdf0e10cSrcweir throw uno::RuntimeException();
805cdf0e10cSrcweir
806cdf0e10cSrcweir // ==== the STAMPIT related solution =============================
807cdf0e10cSrcweir m_aVerbExecutionController.StartControlExecution();
808cdf0e10cSrcweir // ===============================================================
809cdf0e10cSrcweir
810cdf0e10cSrcweir m_pOleComponent->ExecuteVerb( nVerbID );
811cdf0e10cSrcweir
812cdf0e10cSrcweir // ==== the STAMPIT related solution =============================
813cdf0e10cSrcweir sal_Bool bModifiedOnExecution = m_aVerbExecutionController.EndControlExecution_WasModified();
814cdf0e10cSrcweir
815cdf0e10cSrcweir // this workaround is implemented for STAMPIT object
816cdf0e10cSrcweir // if object was modified during verb execution it is saved here
817cdf0e10cSrcweir if ( bModifiedOnExecution && m_pOleComponent->IsDirty() )
818cdf0e10cSrcweir SaveObject_Impl();
819cdf0e10cSrcweir // ===============================================================
820cdf0e10cSrcweir }
821cdf0e10cSrcweir catch( uno::Exception& )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir // ==== the STAMPIT related solution =============================
824cdf0e10cSrcweir m_aVerbExecutionController.EndControlExecution_WasModified();
825cdf0e10cSrcweir // ===============================================================
826cdf0e10cSrcweir
827cdf0e10cSrcweir aGuard.clear();
828cdf0e10cSrcweir StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState );
829cdf0e10cSrcweir throw;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
832cdf0e10cSrcweir // the following notification will be done asynchronously
833cdf0e10cSrcweir // StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState );
834cdf0e10cSrcweir }
835cdf0e10cSrcweir else
836cdf0e10cSrcweir #endif
837cdf0e10cSrcweir {
838cdf0e10cSrcweir if ( nVerbID == -9 )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir // the workaround verb to show the object in case no server is available
841cdf0e10cSrcweir
842cdf0e10cSrcweir // if it is possible, the object will be converted to OOo format
843cdf0e10cSrcweir if ( !m_bTriedConversion )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir m_bTriedConversion = sal_True;
846cdf0e10cSrcweir if ( TryToConvertToOOo() )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir changeState( embed::EmbedStates::UI_ACTIVE );
849cdf0e10cSrcweir return;
850cdf0e10cSrcweir }
851cdf0e10cSrcweir }
852cdf0e10cSrcweir
853cdf0e10cSrcweir if ( !m_pOwnView && m_xObjectStream.is() )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir try {
856cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY );
857cdf0e10cSrcweir if ( xSeekable.is() )
858cdf0e10cSrcweir xSeekable->seek( 0 );
859cdf0e10cSrcweir
860cdf0e10cSrcweir m_pOwnView = new OwnView_Impl( m_xFactory, m_xObjectStream->getInputStream() );
861cdf0e10cSrcweir m_pOwnView->acquire();
862cdf0e10cSrcweir }
863cdf0e10cSrcweir catch( uno::RuntimeException& )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir throw;
866cdf0e10cSrcweir }
867cdf0e10cSrcweir catch( uno::Exception& )
868cdf0e10cSrcweir {
869cdf0e10cSrcweir }
870cdf0e10cSrcweir }
871cdf0e10cSrcweir
872cdf0e10cSrcweir if ( !m_pOwnView || !m_pOwnView->Open() )
873cdf0e10cSrcweir {
874cdf0e10cSrcweir //Make a RO copy and see if the OS can find something to at
875cdf0e10cSrcweir //least display the content for us
876cdf0e10cSrcweir if (!m_aTempDumpURL.getLength())
877cdf0e10cSrcweir m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream);
878cdf0e10cSrcweir
879cdf0e10cSrcweir if (m_aTempDumpURL.getLength())
880cdf0e10cSrcweir {
881*9807c9deSAriel Constenla-Haile uno::Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
882*9807c9deSAriel Constenla-Haile ::com::sun::star::system::SystemShellExecute::create(
883*9807c9deSAriel Constenla-Haile ::comphelper::getProcessComponentContext() ) );
884cdf0e10cSrcweir xSystemShellExecute->execute(m_aTempDumpURL, ::rtl::OUString(), ::com::sun::star::system::SystemShellExecuteFlags::DEFAULTS);
885cdf0e10cSrcweir }
886cdf0e10cSrcweir else
887cdf0e10cSrcweir throw embed::UnreachableStateException();
888cdf0e10cSrcweir }
889cdf0e10cSrcweir }
890cdf0e10cSrcweir else
891cdf0e10cSrcweir {
892cdf0e10cSrcweir
893cdf0e10cSrcweir throw embed::UnreachableStateException();
894cdf0e10cSrcweir }
895cdf0e10cSrcweir }
896cdf0e10cSrcweir }
897cdf0e10cSrcweir
898cdf0e10cSrcweir //----------------------------------------------
getSupportedVerbs()899cdf0e10cSrcweir uno::Sequence< embed::VerbDescriptor > SAL_CALL OleEmbeddedObject::getSupportedVerbs()
900cdf0e10cSrcweir throw ( embed::WrongStateException,
901cdf0e10cSrcweir uno::RuntimeException )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OleEmbeddedObject::getSupportedVerb" );
904cdf0e10cSrcweir
905cdf0e10cSrcweir // begin wrapping related part ====================
906cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
907cdf0e10cSrcweir if ( xWrappedObject.is() )
908cdf0e10cSrcweir {
909cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
910cdf0e10cSrcweir return xWrappedObject->getSupportedVerbs();
911cdf0e10cSrcweir }
912cdf0e10cSrcweir // end wrapping related part ====================
913cdf0e10cSrcweir
914cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
915cdf0e10cSrcweir if ( m_bDisposed )
916cdf0e10cSrcweir throw lang::DisposedException(); // TODO
917cdf0e10cSrcweir
918cdf0e10cSrcweir if ( m_nObjectState == -1 )
919cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
920cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
921cdf0e10cSrcweir #ifdef WNT
922cdf0e10cSrcweir if ( m_pOleComponent )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir // registry could be used in this case
925cdf0e10cSrcweir // if ( m_nObjectState == embed::EmbedStates::LOADED )
926cdf0e10cSrcweir // {
927cdf0e10cSrcweir // // the list of supported verbs can be retrieved only when object is in running state
928cdf0e10cSrcweir // throw embed::NeedsRunningStateException(); // TODO:
929cdf0e10cSrcweir // }
930cdf0e10cSrcweir
931cdf0e10cSrcweir return m_pOleComponent->GetVerbList();
932cdf0e10cSrcweir }
933cdf0e10cSrcweir else
934cdf0e10cSrcweir #endif
935cdf0e10cSrcweir {
936cdf0e10cSrcweir return uno::Sequence< embed::VerbDescriptor >();
937cdf0e10cSrcweir }
938cdf0e10cSrcweir }
939cdf0e10cSrcweir
940cdf0e10cSrcweir //----------------------------------------------
setClientSite(const uno::Reference<embed::XEmbeddedClient> & xClient)941cdf0e10cSrcweir void SAL_CALL OleEmbeddedObject::setClientSite(
942cdf0e10cSrcweir const uno::Reference< embed::XEmbeddedClient >& xClient )
943cdf0e10cSrcweir throw ( embed::WrongStateException,
944cdf0e10cSrcweir uno::RuntimeException )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir // begin wrapping related part ====================
947cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
948cdf0e10cSrcweir if ( xWrappedObject.is() )
949cdf0e10cSrcweir {
950cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
951cdf0e10cSrcweir xWrappedObject->setClientSite( xClient );
952cdf0e10cSrcweir return;
953cdf0e10cSrcweir }
954cdf0e10cSrcweir // end wrapping related part ====================
955cdf0e10cSrcweir
956cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
957cdf0e10cSrcweir if ( m_bDisposed )
958cdf0e10cSrcweir throw lang::DisposedException(); // TODO
959cdf0e10cSrcweir
960cdf0e10cSrcweir if ( m_xClientSite != xClient)
961cdf0e10cSrcweir {
962cdf0e10cSrcweir if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
963cdf0e10cSrcweir throw embed::WrongStateException(
964cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "The client site can not be set currently!\n" ),
965cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
966cdf0e10cSrcweir
967cdf0e10cSrcweir m_xClientSite = xClient;
968cdf0e10cSrcweir }
969cdf0e10cSrcweir }
970cdf0e10cSrcweir
971cdf0e10cSrcweir //----------------------------------------------
getClientSite()972cdf0e10cSrcweir uno::Reference< embed::XEmbeddedClient > SAL_CALL OleEmbeddedObject::getClientSite()
973cdf0e10cSrcweir throw ( embed::WrongStateException,
974cdf0e10cSrcweir uno::RuntimeException )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir // begin wrapping related part ====================
977cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
978cdf0e10cSrcweir if ( xWrappedObject.is() )
979cdf0e10cSrcweir {
980cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
981cdf0e10cSrcweir return xWrappedObject->getClientSite();
982cdf0e10cSrcweir }
983cdf0e10cSrcweir // end wrapping related part ====================
984cdf0e10cSrcweir
985cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
986cdf0e10cSrcweir if ( m_bDisposed )
987cdf0e10cSrcweir throw lang::DisposedException(); // TODO
988cdf0e10cSrcweir
989cdf0e10cSrcweir if ( m_nObjectState == -1 )
990cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
991cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
992cdf0e10cSrcweir
993cdf0e10cSrcweir return m_xClientSite;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir
996cdf0e10cSrcweir //----------------------------------------------
update()997cdf0e10cSrcweir void SAL_CALL OleEmbeddedObject::update()
998cdf0e10cSrcweir throw ( embed::WrongStateException,
999cdf0e10cSrcweir uno::Exception,
1000cdf0e10cSrcweir uno::RuntimeException )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir // begin wrapping related part ====================
1003cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
1004cdf0e10cSrcweir if ( xWrappedObject.is() )
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
1007cdf0e10cSrcweir xWrappedObject->update();
1008cdf0e10cSrcweir return;
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir // end wrapping related part ====================
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
1013cdf0e10cSrcweir if ( m_bDisposed )
1014cdf0e10cSrcweir throw lang::DisposedException(); // TODO
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir if ( m_nObjectState == -1 )
1017cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
1018cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir if ( m_nUpdateMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir // TODO: update view representation
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir else
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir // the object must be up to date
1027cdf0e10cSrcweir OSL_ENSURE( m_nUpdateMode == embed::EmbedUpdateModes::ALWAYS_UPDATE, "Unknown update mode!\n" );
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir //----------------------------------------------
setUpdateMode(sal_Int32 nMode)1032cdf0e10cSrcweir void SAL_CALL OleEmbeddedObject::setUpdateMode( sal_Int32 nMode )
1033cdf0e10cSrcweir throw ( embed::WrongStateException,
1034cdf0e10cSrcweir uno::RuntimeException )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir // begin wrapping related part ====================
1037cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
1038cdf0e10cSrcweir if ( xWrappedObject.is() )
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
1041cdf0e10cSrcweir xWrappedObject->setUpdateMode( nMode );
1042cdf0e10cSrcweir return;
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir // end wrapping related part ====================
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
1047cdf0e10cSrcweir if ( m_bDisposed )
1048cdf0e10cSrcweir throw lang::DisposedException(); // TODO
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir if ( m_nObjectState == -1 )
1051cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
1052cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
1053cdf0e10cSrcweir
1054cdf0e10cSrcweir OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
1055cdf0e10cSrcweir || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
1056cdf0e10cSrcweir "Unknown update mode!\n" );
1057cdf0e10cSrcweir m_nUpdateMode = nMode;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir
1060cdf0e10cSrcweir //----------------------------------------------
getStatus(sal_Int64 nAspect)1061cdf0e10cSrcweir sal_Int64 SAL_CALL OleEmbeddedObject::getStatus( sal_Int64
1062cdf0e10cSrcweir nAspect
1063cdf0e10cSrcweir )
1064cdf0e10cSrcweir throw ( embed::WrongStateException,
1065cdf0e10cSrcweir uno::RuntimeException )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir // begin wrapping related part ====================
1068cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
1069cdf0e10cSrcweir if ( xWrappedObject.is() )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
1072cdf0e10cSrcweir return xWrappedObject->getStatus( nAspect );
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir // end wrapping related part ====================
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
1077cdf0e10cSrcweir if ( m_bDisposed )
1078cdf0e10cSrcweir throw lang::DisposedException(); // TODO
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir if ( m_nObjectState == -1 )
1081cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object must be in running state!\n" ),
1082cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir sal_Int64 nResult = 0;
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir #ifdef WNT
1087cdf0e10cSrcweir if ( m_bGotStatus && m_nStatusAspect == nAspect )
1088cdf0e10cSrcweir nResult = m_nStatus;
1089cdf0e10cSrcweir else if ( m_pOleComponent )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir // OLE should allow to get status even in loaded state
1092cdf0e10cSrcweir // if ( m_nObjectState == embed::EmbedStates::LOADED )
1093cdf0e10cSrcweir // changeState( m_nObjectState == embed::EmbedStates::RUNNING );
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir m_nStatus = m_pOleComponent->GetMiscStatus( nAspect );
1096cdf0e10cSrcweir m_nStatusAspect = nAspect;
1097cdf0e10cSrcweir m_bGotStatus = sal_True;
1098cdf0e10cSrcweir nResult = m_nStatus;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir #endif
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir // this implementation needs size to be provided after object loading/creating to work in optimal way
1103cdf0e10cSrcweir return ( nResult | embed::EmbedMisc::EMBED_NEEDSSIZEONLOAD );
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir //----------------------------------------------
setContainerName(const::rtl::OUString & sName)1107cdf0e10cSrcweir void SAL_CALL OleEmbeddedObject::setContainerName( const ::rtl::OUString& sName )
1108cdf0e10cSrcweir throw ( uno::RuntimeException )
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir // begin wrapping related part ====================
1111cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
1112cdf0e10cSrcweir if ( xWrappedObject.is() )
1113cdf0e10cSrcweir {
1114cdf0e10cSrcweir // the object was converted to OOo embedded object, the current implementation is now only a wrapper
1115cdf0e10cSrcweir xWrappedObject->setContainerName( sName );
1116cdf0e10cSrcweir return;
1117cdf0e10cSrcweir }
1118cdf0e10cSrcweir // end wrapping related part ====================
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
1121cdf0e10cSrcweir if ( m_bDisposed )
1122cdf0e10cSrcweir throw lang::DisposedException(); // TODO
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir m_aContainerName = sName;
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir
1127cdf0e10cSrcweir
1128