2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-09-27 13:52:10 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
#include <oleembobj.hxx>
|
|
|
|
#include <com/sun/star/embed/EmbedStates.hpp>
|
|
|
|
#include <com/sun/star/embed/EmbedVerbs.hpp>
|
2017-02-06 17:08:38 +01:00
|
|
|
#include <com/sun/star/embed/UnreachableStateException.hpp>
|
2003-11-13 16:01:50 +00:00
|
|
|
#include <com/sun/star/embed/XStorage.hpp>
|
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
|
|
|
#include <com/sun/star/embed/EmbedUpdateModes.hpp>
|
|
|
|
#include <com/sun/star/embed/NeedsRunningStateException.hpp>
|
2005-02-25 08:22:02 +00:00
|
|
|
#include <com/sun/star/embed/StateChangeInProgressException.hpp>
|
2006-02-01 18:06:01 +00:00
|
|
|
#include <com/sun/star/embed/EmbedMisc.hpp>
|
2008-07-22 13:39:09 +00:00
|
|
|
#include <com/sun/star/embed/XEmbedObjectCreator.hpp>
|
2012-08-23 17:23:26 +02:00
|
|
|
#include <com/sun/star/io/TempFile.hpp>
|
2005-01-18 14:10:21 +00:00
|
|
|
#include <com/sun/star/io/XSeekable.hpp>
|
2003-11-13 16:01:50 +00:00
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
2018-05-24 15:47:30 +02:00
|
|
|
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
|
2008-07-22 13:39:09 +00:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/frame/XLoadable.hpp>
|
|
|
|
#include <com/sun/star/document/XStorageBasedDocument.hpp>
|
2012-05-29 17:17:28 +02:00
|
|
|
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
|
2010-05-26 15:38:21 +02:00
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
2012-08-29 07:45:05 +02:00
|
|
|
#include <com/sun/star/system/SystemShellExecute.hpp>
|
2010-05-26 15:38:21 +02:00
|
|
|
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2018-05-24 15:47:30 +02:00
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2008-07-22 13:39:09 +00:00
|
|
|
#include <cppuhelper/interfacecontainer.h>
|
2012-09-19 13:15:15 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2008-07-22 13:39:09 +00:00
|
|
|
#include <comphelper/mimeconfighelper.hxx>
|
2018-07-27 09:42:16 +02:00
|
|
|
#include <sal/log.hxx>
|
2019-06-14 15:30:08 +02:00
|
|
|
#include <tools/diagnose_ex.h>
|
2006-01-20 08:51:56 +00:00
|
|
|
|
|
|
|
|
2005-02-25 08:22:02 +00:00
|
|
|
#include <targetstatecontrol.hxx>
|
|
|
|
|
2005-01-18 14:10:21 +00:00
|
|
|
#include "ownview.hxx"
|
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#if defined(_WIN32)
|
2017-10-27 19:27:08 +02:00
|
|
|
#include "olecomponent.hxx"
|
2014-02-27 12:51:43 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
void OleEmbeddedObject::SwitchComponentToRunningState_Impl()
|
|
|
|
{
|
2017-09-30 22:43:59 +02:00
|
|
|
if ( !m_pOleComponent )
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
2017-09-30 22:43:59 +02:00
|
|
|
throw embed::UnreachableStateException();
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
2017-09-30 22:43:59 +02:00
|
|
|
try
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
2017-09-30 22:43:59 +02:00
|
|
|
m_pOleComponent->RunObject();
|
|
|
|
}
|
|
|
|
catch( const embed::UnreachableStateException& )
|
|
|
|
{
|
|
|
|
GetRidOfComponent();
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch( const embed::WrongStateException& )
|
|
|
|
{
|
|
|
|
GetRidOfComponent();
|
|
|
|
throw;
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
uno::Sequence< sal_Int32 > OleEmbeddedObject::GetReachableStatesList_Impl(
|
2004-05-10 16:53:50 +00:00
|
|
|
const uno::Sequence< embed::VerbDescriptor >& aVerbList )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2003-12-12 11:50:52 +00:00
|
|
|
uno::Sequence< sal_Int32 > aStates(2);
|
2004-05-10 16:53:50 +00:00
|
|
|
aStates[0] = embed::EmbedStates::LOADED;
|
|
|
|
aStates[1] = embed::EmbedStates::RUNNING;
|
2003-12-12 11:50:52 +00:00
|
|
|
for ( sal_Int32 nInd = 0; nInd < aVerbList.getLength(); nInd++ )
|
|
|
|
if ( aVerbList[nInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN )
|
|
|
|
{
|
|
|
|
aStates.realloc(3);
|
2004-05-10 16:53:50 +00:00
|
|
|
aStates[2] = embed::EmbedStates::ACTIVE;
|
2003-12-12 11:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return aStates;
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
uno::Sequence< sal_Int32 > OleEmbeddedObject::GetIntermediateVerbsSequence_Impl( sal_Int32 nNewState )
|
|
|
|
{
|
2013-05-27 00:22:20 +03:00
|
|
|
SAL_WARN_IF( m_nObjectState == embed::EmbedStates::LOADED, "embeddedobj.ole", "Loaded object is switched to running state without verbs using!" );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
// actually there will be only one verb
|
2004-05-10 16:53:50 +00:00
|
|
|
if ( m_nObjectState == embed::EmbedStates::RUNNING && nNewState == embed::EmbedStates::ACTIVE )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
|
|
|
uno::Sequence< sal_Int32 > aVerbs( 1 );
|
|
|
|
aVerbs[0] = embed::EmbedVerbs::MS_OLEVERB_OPEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
return uno::Sequence< sal_Int32 >();
|
|
|
|
}
|
2008-06-20 06:08:04 +00:00
|
|
|
#endif
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2008-07-22 13:39:09 +00:00
|
|
|
void OleEmbeddedObject::MoveListeners()
|
|
|
|
{
|
|
|
|
if ( m_pInterfaceContainer )
|
|
|
|
{
|
|
|
|
// move state change listeners
|
|
|
|
{
|
|
|
|
::cppu::OInterfaceContainerHelper* pStateChangeContainer =
|
2014-05-17 00:23:39 +02:00
|
|
|
m_pInterfaceContainer->getContainer( cppu::UnoType<embed::XStateChangeListener>::get());
|
2015-11-10 10:14:40 +01:00
|
|
|
if ( pStateChangeContainer != nullptr )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2019-07-19 14:05:10 +02:00
|
|
|
if ( m_xWrappedObject.is() )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
::cppu::OInterfaceIteratorHelper pIterator( *pStateChangeContainer );
|
|
|
|
while ( pIterator.hasMoreElements() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-07-19 14:05:10 +02:00
|
|
|
m_xWrappedObject->addStateChangeListener( static_cast<embed::XStateChangeListener*>(pIterator.next()) );
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch( const uno::RuntimeException& )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
pIterator.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// move event listeners
|
|
|
|
{
|
|
|
|
::cppu::OInterfaceContainerHelper* pEventContainer =
|
2014-05-17 00:23:39 +02:00
|
|
|
m_pInterfaceContainer->getContainer( cppu::UnoType<document::XEventListener>::get());
|
2015-11-10 10:14:40 +01:00
|
|
|
if ( pEventContainer != nullptr )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2019-07-19 14:05:10 +02:00
|
|
|
if ( m_xWrappedObject.is() )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
::cppu::OInterfaceIteratorHelper pIterator( *pEventContainer );
|
|
|
|
while ( pIterator.hasMoreElements() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-07-19 14:05:10 +02:00
|
|
|
m_xWrappedObject->addEventListener( static_cast<document::XEventListener*>(pIterator.next()) );
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch( const uno::RuntimeException& )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
pIterator.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// move close listeners
|
|
|
|
{
|
|
|
|
::cppu::OInterfaceContainerHelper* pCloseContainer =
|
2014-05-17 00:23:39 +02:00
|
|
|
m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get());
|
2015-11-10 10:14:40 +01:00
|
|
|
if ( pCloseContainer != nullptr )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2019-07-19 14:05:10 +02:00
|
|
|
if ( m_xWrappedObject.is() )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
::cppu::OInterfaceIteratorHelper pIterator( *pCloseContainer );
|
|
|
|
while ( pIterator.hasMoreElements() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-07-19 14:05:10 +02:00
|
|
|
m_xWrappedObject->addCloseListener( static_cast<util::XCloseListener*>(pIterator.next()) );
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch( const uno::RuntimeException& )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
pIterator.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-03 17:01:55 +02:00
|
|
|
m_pInterfaceContainer.reset();
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
uno::Reference< embed::XStorage > OleEmbeddedObject::CreateTemporarySubstorage( OUString& o_aStorageName )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
uno::Reference< embed::XStorage > xResult;
|
|
|
|
|
|
|
|
for ( sal_Int32 nInd = 0; nInd < 32000 && !xResult.is(); nInd++ )
|
|
|
|
{
|
2013-11-15 11:05:19 +02:00
|
|
|
OUString aName = OUString::number( nInd ) + "TMPSTOR" + m_aEntryName;
|
2008-07-22 13:39:09 +00:00
|
|
|
if ( !m_xParentStorage->hasByName( aName ) )
|
|
|
|
{
|
|
|
|
xResult = m_xParentStorage->openStorageElement( aName, embed::ElementModes::READWRITE );
|
|
|
|
o_aStorageName = aName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !xResult.is() )
|
|
|
|
{
|
2014-11-12 14:24:10 +05:30
|
|
|
o_aStorageName.clear();
|
2008-07-22 13:39:09 +00:00
|
|
|
throw uno::RuntimeException();
|
|
|
|
}
|
|
|
|
|
|
|
|
return xResult;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString OleEmbeddedObject::MoveToTemporarySubstream()
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aResult;
|
2011-12-21 19:54:11 -02:00
|
|
|
for ( sal_Int32 nInd = 0; nInd < 32000 && aResult.isEmpty(); nInd++ )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2013-11-15 11:05:19 +02:00
|
|
|
OUString aName = OUString::number( nInd ) + "TMPSTREAM" + m_aEntryName;
|
2008-07-22 13:39:09 +00:00
|
|
|
if ( !m_xParentStorage->hasByName( aName ) )
|
|
|
|
{
|
|
|
|
m_xParentStorage->renameElement( m_aEntryName, aName );
|
|
|
|
aResult = aName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-21 19:54:11 -02:00
|
|
|
if ( aResult.isEmpty() )
|
2008-07-22 13:39:09 +00:00
|
|
|
throw uno::RuntimeException();
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-07-10 18:47:49 +02:00
|
|
|
bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >& xStream )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2014-04-17 11:39:18 +02:00
|
|
|
bool bResult = false;
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aStorageName;
|
|
|
|
OUString aTmpStreamName;
|
2008-07-22 13:39:09 +00:00
|
|
|
sal_Int32 nStep = 0;
|
|
|
|
|
|
|
|
if ( m_pOleComponent || m_bReadOnly )
|
2014-04-17 11:39:18 +02:00
|
|
|
return false;
|
2008-07-22 13:39:09 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
changeState( embed::EmbedStates::LOADED );
|
|
|
|
|
|
|
|
// the stream must be seekable
|
2017-07-10 18:47:49 +02:00
|
|
|
uno::Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY_THROW );
|
2008-07-22 13:39:09 +00:00
|
|
|
xSeekable->seek( 0 );
|
2017-07-10 18:47:49 +02:00
|
|
|
m_aFilterName = OwnView_Impl::GetFilterNameFromExtentionAndInStream( m_xFactory, OUString(), xStream->getInputStream() );
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2014-08-27 14:29:43 +03:00
|
|
|
if ( !m_aFilterName.isEmpty()
|
2017-07-12 12:17:03 +02:00
|
|
|
&& ( m_aFilterName == "Calc MS Excel 2007 XML" || m_aFilterName == "Impress MS PowerPoint 2007 XML" || m_aFilterName == "MS Word 2007 XML"
|
|
|
|
|| m_aFilterName == "MS Excel 97 Vorlage/Template" || m_aFilterName == "MS Word 97 Vorlage" ) )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xFilterFactory(
|
2013-06-29 21:24:12 +02:00
|
|
|
m_xFactory->createInstance("com.sun.star.document.FilterFactory"),
|
2008-07-22 13:39:09 +00:00
|
|
|
uno::UNO_QUERY_THROW );
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aDocServiceName;
|
2014-08-27 14:29:43 +03:00
|
|
|
uno::Any aFilterAnyData = xFilterFactory->getByName( m_aFilterName );
|
2008-07-22 13:39:09 +00:00
|
|
|
uno::Sequence< beans::PropertyValue > aFilterData;
|
|
|
|
if ( aFilterAnyData >>= aFilterData )
|
|
|
|
{
|
|
|
|
for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ )
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( aFilterData[nInd].Name == "DocumentService" )
|
2008-07-22 13:39:09 +00:00
|
|
|
aFilterData[nInd].Value >>= aDocServiceName;
|
|
|
|
}
|
|
|
|
|
2011-12-21 19:54:11 -02:00
|
|
|
if ( !aDocServiceName.isEmpty() )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
// create the model
|
|
|
|
uno::Sequence< uno::Any > aArguments(1);
|
2017-01-30 16:38:54 +02:00
|
|
|
aArguments[0] <<= beans::NamedValue( "EmbeddedObject", uno::makeAny( true ));
|
2008-07-22 13:39:09 +00:00
|
|
|
|
|
|
|
uno::Reference< util::XCloseable > xDocument( m_xFactory->createInstanceWithArguments( aDocServiceName, aArguments ), uno::UNO_QUERY_THROW );
|
|
|
|
uno::Reference< frame::XLoadable > xLoadable( xDocument, uno::UNO_QUERY_THROW );
|
|
|
|
uno::Reference< document::XStorageBasedDocument > xStorDoc( xDocument, uno::UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
// let the model behave as embedded one
|
|
|
|
uno::Reference< frame::XModel > xModel( xDocument, uno::UNO_QUERY_THROW );
|
|
|
|
uno::Sequence< beans::PropertyValue > aSeq( 1 );
|
2013-11-15 11:05:19 +02:00
|
|
|
aSeq[0].Name = "SetEmbedded";
|
2016-04-20 17:16:42 +02:00
|
|
|
aSeq[0].Value <<= true;
|
2013-04-07 12:06:47 +02:00
|
|
|
xModel->attachResource( OUString(), aSeq );
|
2008-07-22 13:39:09 +00:00
|
|
|
|
|
|
|
// load the model from the stream
|
|
|
|
uno::Sequence< beans::PropertyValue > aArgs( 5 );
|
2013-11-15 11:05:19 +02:00
|
|
|
aArgs[0].Name = "HierarchicalDocumentName";
|
2008-07-22 13:39:09 +00:00
|
|
|
aArgs[0].Value <<= m_aEntryName;
|
2013-11-15 11:05:19 +02:00
|
|
|
aArgs[1].Name = "ReadOnly";
|
2016-04-20 17:16:42 +02:00
|
|
|
aArgs[1].Value <<= true;
|
2013-11-15 11:05:19 +02:00
|
|
|
aArgs[2].Name = "FilterName";
|
2014-08-27 14:29:43 +03:00
|
|
|
aArgs[2].Value <<= m_aFilterName;
|
2013-11-15 11:05:19 +02:00
|
|
|
aArgs[3].Name = "URL";
|
2013-04-07 12:06:47 +02:00
|
|
|
aArgs[3].Value <<= OUString( "private:stream" );
|
2013-11-15 11:05:19 +02:00
|
|
|
aArgs[4].Name = "InputStream";
|
2017-07-10 18:47:49 +02:00
|
|
|
aArgs[4].Value <<= xStream->getInputStream();
|
2008-07-22 13:39:09 +00:00
|
|
|
|
|
|
|
xSeekable->seek( 0 );
|
|
|
|
xLoadable->load( aArgs );
|
|
|
|
|
2013-03-03 17:11:39 +01:00
|
|
|
// the model is successfully loaded, create a new storage and store the model to the storage
|
2008-07-22 13:39:09 +00:00
|
|
|
uno::Reference< embed::XStorage > xTmpStorage = CreateTemporarySubstorage( aStorageName );
|
|
|
|
xStorDoc->storeToStorage( xTmpStorage, uno::Sequence< beans::PropertyValue >() );
|
2016-04-20 17:16:42 +02:00
|
|
|
xDocument->close( true );
|
2008-07-22 13:39:09 +00:00
|
|
|
uno::Reference< beans::XPropertySet > xStorProps( xTmpStorage, uno::UNO_QUERY_THROW );
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aMediaType;
|
2013-06-29 21:24:12 +02:00
|
|
|
xStorProps->getPropertyValue("MediaType") >>= aMediaType;
|
2008-07-22 13:39:09 +00:00
|
|
|
xTmpStorage->dispose();
|
|
|
|
|
|
|
|
// look for the related embedded object factory
|
2013-01-08 15:29:57 +02:00
|
|
|
::comphelper::MimeConfigurationHelper aConfigHelper( comphelper::getComponentContext(m_xFactory) );
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aEmbedFactory;
|
2011-12-21 19:54:11 -02:00
|
|
|
if ( !aMediaType.isEmpty() )
|
2008-07-22 13:39:09 +00:00
|
|
|
aEmbedFactory = aConfigHelper.GetFactoryNameByMediaType( aMediaType );
|
|
|
|
|
2011-12-21 19:54:11 -02:00
|
|
|
if ( aEmbedFactory.isEmpty() )
|
2008-07-22 13:39:09 +00:00
|
|
|
throw uno::RuntimeException();
|
|
|
|
|
|
|
|
uno::Reference< uno::XInterface > xFact = m_xFactory->createInstance( aEmbedFactory );
|
|
|
|
|
|
|
|
uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
// now the object should be adjusted to become the wrapper
|
|
|
|
nStep = 1;
|
|
|
|
uno::Reference< lang::XComponent > xComp( m_xObjectStream, uno::UNO_QUERY_THROW );
|
|
|
|
xComp->dispose();
|
2015-10-30 14:22:53 +02:00
|
|
|
m_xObjectStream.clear();
|
2008-07-22 13:39:09 +00:00
|
|
|
m_nObjectState = -1;
|
|
|
|
|
|
|
|
nStep = 2;
|
|
|
|
aTmpStreamName = MoveToTemporarySubstream();
|
|
|
|
|
|
|
|
nStep = 3;
|
|
|
|
m_xParentStorage->renameElement( aStorageName, m_aEntryName );
|
|
|
|
|
|
|
|
nStep = 4;
|
|
|
|
m_xWrappedObject.set( xEmbCreator->createInstanceInitFromEntry( m_xParentStorage, m_aEntryName, uno::Sequence< beans::PropertyValue >(), uno::Sequence< beans::PropertyValue >() ), uno::UNO_QUERY_THROW );
|
|
|
|
|
2017-07-11 17:56:23 +02:00
|
|
|
// remember parent document name to show in the title bar
|
|
|
|
m_xWrappedObject->setContainerName( m_aContainerName );
|
|
|
|
|
2014-04-17 11:39:18 +02:00
|
|
|
bResult = true; // the change is no more revertable
|
2008-07-22 13:39:09 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_xParentStorage->removeElement( aTmpStreamName );
|
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch( const uno::Exception& )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
// the success of the removing is not so important
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch( const uno::Exception& )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
|
|
|
// repair the object if necessary
|
|
|
|
switch( nStep )
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
case 3:
|
2011-12-21 19:54:11 -02:00
|
|
|
if ( !aTmpStreamName.isEmpty() && aTmpStreamName != m_aEntryName )
|
2008-07-22 13:39:09 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( m_xParentStorage->hasByName( m_aEntryName ) )
|
|
|
|
m_xParentStorage->removeElement( m_aEntryName );
|
|
|
|
m_xParentStorage->renameElement( aTmpStreamName, m_aEntryName );
|
|
|
|
}
|
2018-05-24 15:47:30 +02:00
|
|
|
catch ( const uno::Exception& ex )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2018-05-24 15:47:30 +02:00
|
|
|
css::uno::Any anyEx = cppu::getCaughtException();
|
2008-07-22 13:39:09 +00:00
|
|
|
try {
|
2016-04-20 17:16:42 +02:00
|
|
|
close( true );
|
2011-12-09 02:56:30 +09:00
|
|
|
} catch( const uno::Exception& ) {}
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2014-04-29 19:05:05 +00:00
|
|
|
m_xParentStorage->dispose(); // ??? the storage has information loss, it should be closed without committing!
|
2018-05-24 15:47:30 +02:00
|
|
|
throw css::lang::WrappedTargetRuntimeException( ex.Message,
|
|
|
|
nullptr, anyEx ); // the repairing is not possible
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
2018-12-08 09:46:01 +01:00
|
|
|
[[fallthrough]];
|
2008-07-22 13:39:09 +00:00
|
|
|
case 2:
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_xObjectStream = m_xParentStorage->openStreamElement( m_aEntryName, m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE );
|
|
|
|
m_nObjectState = embed::EmbedStates::LOADED;
|
|
|
|
}
|
2018-05-24 15:47:30 +02:00
|
|
|
catch( const uno::Exception& ex )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2018-05-24 15:47:30 +02:00
|
|
|
css::uno::Any anyEx = cppu::getCaughtException();
|
2008-07-22 13:39:09 +00:00
|
|
|
try {
|
2016-04-20 17:16:42 +02:00
|
|
|
close( true );
|
2011-12-09 02:56:30 +09:00
|
|
|
} catch( const uno::Exception& ) {}
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2018-05-24 15:47:30 +02:00
|
|
|
throw css::lang::WrappedTargetRuntimeException( ex.Message,
|
|
|
|
nullptr, anyEx ); // the repairing is not possible
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
2018-12-08 09:46:01 +01:00
|
|
|
[[fallthrough]];
|
2008-07-22 13:39:09 +00:00
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 0:
|
2011-12-21 19:54:11 -02:00
|
|
|
if ( !aStorageName.isEmpty() )
|
2008-07-22 13:39:09 +00:00
|
|
|
try {
|
|
|
|
m_xParentStorage->removeElement( aStorageName );
|
2013-05-27 00:22:20 +03:00
|
|
|
} catch( const uno::Exception& ) { SAL_WARN( "embeddedobj.ole", "Can not remove temporary storage!" ); }
|
2008-07-22 13:39:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bResult )
|
|
|
|
{
|
2013-03-03 17:11:39 +01:00
|
|
|
// the conversion was done successfully, now the additional initializations should happen
|
2008-07-22 13:39:09 +00:00
|
|
|
|
|
|
|
MoveListeners();
|
|
|
|
m_xWrappedObject->setClientSite( m_xClientSite );
|
|
|
|
if ( m_xParent.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< container::XChild > xChild( m_xWrappedObject, uno::UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( m_xParent );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
xWrappedObject->changeState( nNewState );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2005-03-15 10:38:59 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( m_aMutex );
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
// in case the object is already in requested state
|
|
|
|
if ( m_nObjectState == nNewState )
|
|
|
|
return;
|
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_pOleComponent )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2005-02-25 08:22:02 +00:00
|
|
|
if ( m_nTargetState != -1 )
|
|
|
|
{
|
|
|
|
// means that the object is currently trying to reach the target state
|
2013-04-07 12:06:47 +02:00
|
|
|
throw embed::StateChangeInProgressException( OUString(),
|
2005-02-25 08:22:02 +00:00
|
|
|
uno::Reference< uno::XInterface >(),
|
|
|
|
m_nTargetState );
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetStateControl_Impl aControl( m_nTargetState, nNewState );
|
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
// TODO: additional verbs can be a problem, since nobody knows how the object
|
|
|
|
// will behave after activation
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
sal_Int32 nOldState = m_nObjectState;
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2016-10-14 16:56:42 +02:00
|
|
|
StateChangeNotification_Impl( true, nOldState, nNewState );
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
try
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( nNewState == embed::EmbedStates::LOADED )
|
|
|
|
{
|
|
|
|
// This means just closing of the current object
|
|
|
|
// If component can not be closed the object stays in loaded state
|
|
|
|
// and it holds reference to "incomplete" component
|
|
|
|
// If the object is switched to running state later
|
|
|
|
// the component will become "complete"
|
2006-12-19 13:04:30 +00:00
|
|
|
|
2007-01-23 06:33:40 +00:00
|
|
|
// the loaded state must be set before, because of notifications!
|
|
|
|
m_nObjectState = nNewState;
|
|
|
|
|
2006-12-19 13:04:30 +00:00
|
|
|
{
|
|
|
|
VerbExecutionControllerGuard aVerbGuard( m_aVerbExecutionController );
|
|
|
|
m_pOleComponent->CloseObject();
|
|
|
|
}
|
|
|
|
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2016-10-14 16:56:42 +02:00
|
|
|
StateChangeNotification_Impl( false, nOldState, m_nObjectState );
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
|
|
|
else if ( nNewState == embed::EmbedStates::RUNNING || nNewState == embed::EmbedStates::ACTIVE )
|
|
|
|
{
|
|
|
|
if ( m_nObjectState == embed::EmbedStates::LOADED )
|
|
|
|
{
|
|
|
|
// if the target object is in loaded state and a different state is specified
|
|
|
|
// as a new one the object first must be switched to running state.
|
|
|
|
|
|
|
|
// the component can exist already in nonrunning state
|
|
|
|
// it can be created during loading to detect type of object
|
|
|
|
CreateOleComponentAndLoad_Impl( m_pOleComponent );
|
|
|
|
|
|
|
|
SwitchComponentToRunningState_Impl();
|
|
|
|
m_nObjectState = embed::EmbedStates::RUNNING;
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2016-10-14 16:56:42 +02:00
|
|
|
StateChangeNotification_Impl( false, nOldState, m_nObjectState );
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2005-01-31 08:02:47 +00:00
|
|
|
|
|
|
|
if ( m_pOleComponent && m_bHasSizeToSet )
|
|
|
|
{
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2005-01-31 08:02:47 +00:00
|
|
|
try {
|
2006-02-01 18:06:01 +00:00
|
|
|
m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet );
|
2016-10-14 16:56:42 +02:00
|
|
|
m_bHasSizeToSet = false;
|
2005-01-31 08:02:47 +00:00
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch( const uno::Exception& ) {}
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2005-01-31 08:02:47 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_nObjectState == nNewState )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-16 19:37:57 +01:00
|
|
|
// so now the object is either switched from Active to Running state or viceversa
|
2004-10-04 18:55:06 +00:00
|
|
|
// the notification about object state change will be done asynchronously
|
|
|
|
if ( m_nObjectState == embed::EmbedStates::RUNNING && nNewState == embed::EmbedStates::ACTIVE )
|
|
|
|
{
|
|
|
|
// execute OPEN verb, if object does not reach active state it is an object's problem
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2004-10-04 18:55:06 +00:00
|
|
|
m_pOleComponent->ExecuteVerb( embed::EmbedVerbs::MS_OLEVERB_OPEN );
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2005-01-31 08:02:47 +00:00
|
|
|
|
|
|
|
// some objects do not allow to set the size even in running state
|
|
|
|
if ( m_pOleComponent && m_bHasSizeToSet )
|
|
|
|
{
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2005-01-31 08:02:47 +00:00
|
|
|
try {
|
2006-02-01 18:06:01 +00:00
|
|
|
m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet );
|
2016-10-14 16:56:42 +02:00
|
|
|
m_bHasSizeToSet = false;
|
2005-01-31 08:02:47 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception& ) {}
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2005-01-31 08:02:47 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
m_nObjectState = nNewState;
|
|
|
|
}
|
|
|
|
else if ( m_nObjectState == embed::EmbedStates::ACTIVE && nNewState == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2004-10-04 18:55:06 +00:00
|
|
|
m_pOleComponent->CloseObject();
|
|
|
|
m_pOleComponent->RunObject(); // Should not fail, the object already was active
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.reset();
|
2004-10-04 18:55:06 +00:00
|
|
|
m_nObjectState = nNewState;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw embed::UnreachableStateException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw embed::UnreachableStateException();
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
2004-10-04 18:55:06 +00:00
|
|
|
catch( uno::Exception& )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2016-10-14 16:56:42 +02:00
|
|
|
StateChangeNotification_Impl( false, nOldState, m_nObjectState );
|
2004-10-04 18:55:06 +00:00
|
|
|
throw;
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
2003-12-15 14:37:44 +00:00
|
|
|
else
|
|
|
|
#endif
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
2003-12-15 14:37:44 +00:00
|
|
|
throw embed::UnreachableStateException();
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
uno::Sequence< sal_Int32 > SAL_CALL OleEmbeddedObject::getReachableStates()
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
return xWrappedObject->getReachableStates();
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_pOleComponent )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_nObjectState == embed::EmbedStates::LOADED )
|
|
|
|
{
|
|
|
|
// the list of supported verbs can be retrieved only when object is in running state
|
|
|
|
throw embed::NeedsRunningStateException(); // TODO:
|
|
|
|
}
|
2003-12-15 14:37:44 +00:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
// the list of states can only be guessed based on standard verbs,
|
|
|
|
// since there is no way to detect what additional verbs do
|
|
|
|
return GetReachableStatesList_Impl( m_pOleComponent->GetVerbList() );
|
|
|
|
}
|
|
|
|
else
|
2003-12-15 14:37:44 +00:00
|
|
|
#endif
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
|
|
|
return uno::Sequence< sal_Int32 >();
|
|
|
|
}
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
sal_Int32 SAL_CALL OleEmbeddedObject::getCurrentState()
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
return xWrappedObject->getCurrentState();
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
// TODO: Shouldn't we ask object? ( I guess no )
|
|
|
|
return m_nObjectState;
|
|
|
|
}
|
|
|
|
|
2010-05-26 15:38:21 +02:00
|
|
|
namespace
|
|
|
|
{
|
2017-01-12 09:49:36 +00:00
|
|
|
bool lcl_CopyStream(const uno::Reference<io::XInputStream>& xIn, const uno::Reference<io::XOutputStream>& xOut, sal_Int32 nMaxCopy = SAL_MAX_INT32)
|
2010-05-26 15:38:21 +02:00
|
|
|
{
|
2018-07-25 09:09:15 +01:00
|
|
|
if (nMaxCopy <= 0)
|
2017-01-12 09:49:36 +00:00
|
|
|
return false;
|
|
|
|
|
2010-05-26 15:38:21 +02:00
|
|
|
const sal_Int32 nChunkSize = 4096;
|
|
|
|
uno::Sequence< sal_Int8 > aData(nChunkSize);
|
|
|
|
sal_Int32 nTotalRead = 0;
|
|
|
|
sal_Int32 nRead;
|
|
|
|
do
|
|
|
|
{
|
2017-01-12 09:49:36 +00:00
|
|
|
if (nTotalRead + aData.getLength() > nMaxCopy)
|
|
|
|
{
|
|
|
|
aData.realloc(nMaxCopy - nTotalRead);
|
|
|
|
}
|
|
|
|
nRead = xIn->readBytes(aData, aData.getLength());
|
2010-05-26 15:38:21 +02:00
|
|
|
nTotalRead += nRead;
|
|
|
|
xOut->writeBytes(aData);
|
2017-01-12 09:49:36 +00:00
|
|
|
} while (nRead == nChunkSize && nTotalRead <= nMaxCopy);
|
2010-05-26 15:38:21 +02:00
|
|
|
return nTotalRead != 0;
|
|
|
|
}
|
|
|
|
|
2017-07-10 18:47:49 +02:00
|
|
|
uno::Reference < io::XStream > lcl_GetExtractedStream( OUString& rUrl,
|
|
|
|
const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory,
|
|
|
|
const css::uno::Reference< css::io::XStream >& xObjectStream )
|
2010-05-26 15:38:21 +02:00
|
|
|
{
|
|
|
|
uno::Reference <beans::XPropertySet> xNativeTempFile(
|
2012-09-19 13:15:15 +02:00
|
|
|
io::TempFile::create(comphelper::getComponentContext(xFactory)),
|
2012-08-23 17:23:26 +02:00
|
|
|
uno::UNO_QUERY_THROW);
|
2010-05-26 15:38:21 +02:00
|
|
|
uno::Reference < io::XStream > xStream(xNativeTempFile, uno::UNO_QUERY_THROW);
|
|
|
|
|
|
|
|
uno::Sequence< uno::Any > aArgs( 2 );
|
|
|
|
aArgs[0] <<= xObjectStream;
|
2014-04-17 11:39:18 +02:00
|
|
|
aArgs[1] <<= true; // do not create copy
|
2010-05-26 15:38:21 +02:00
|
|
|
uno::Reference< container::XNameContainer > xNameContainer(
|
|
|
|
xFactory->createInstanceWithArguments(
|
2015-10-30 08:40:11 +02:00
|
|
|
"com.sun.star.embed.OLESimpleStorage",
|
2010-05-26 15:38:21 +02:00
|
|
|
aArgs ), uno::UNO_QUERY_THROW );
|
|
|
|
|
2017-05-09 09:32:45 +01:00
|
|
|
//various stream names that can contain the real document contents for
|
|
|
|
//this object in a straightforward direct way
|
2018-10-17 09:31:51 +02:00
|
|
|
static const OUStringLiteral aStreamNames[] =
|
2013-02-10 00:18:46 +01:00
|
|
|
{
|
2017-05-09 09:32:45 +01:00
|
|
|
"CONTENTS",
|
|
|
|
"Package",
|
|
|
|
"EmbeddedOdf",
|
|
|
|
"WordDocument",
|
|
|
|
"Workbook",
|
|
|
|
"PowerPoint Document"
|
|
|
|
};
|
|
|
|
|
|
|
|
bool bCopied = false;
|
|
|
|
for (size_t i = 0; i < SAL_N_ELEMENTS(aStreamNames) && !bCopied; ++i)
|
2013-02-10 00:18:46 +01:00
|
|
|
{
|
2017-05-09 09:32:45 +01:00
|
|
|
uno::Reference<io::XStream> xEmbeddedFile;
|
2017-05-09 09:24:11 +01:00
|
|
|
try
|
|
|
|
{
|
2017-05-09 09:32:45 +01:00
|
|
|
xNameContainer->getByName(aStreamNames[i]) >>= xEmbeddedFile;
|
2017-05-09 09:24:11 +01:00
|
|
|
}
|
2017-05-09 09:32:45 +01:00
|
|
|
catch (const container::NoSuchElementException&)
|
2017-05-09 09:24:11 +01:00
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
2017-05-09 09:32:45 +01:00
|
|
|
bCopied = xEmbeddedFile.is() && lcl_CopyStream(xEmbeddedFile->getInputStream(), xStream->getOutputStream());
|
2017-05-09 09:24:11 +01:00
|
|
|
}
|
2010-05-26 15:38:21 +02:00
|
|
|
|
2017-01-12 09:49:36 +00:00
|
|
|
if (!bCopied)
|
|
|
|
{
|
|
|
|
uno::Reference< io::XStream > xOle10Native;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xNameContainer->getByName("\1Ole10Native") >>= xOle10Native;
|
|
|
|
}
|
|
|
|
catch (container::NoSuchElementException const&)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
if (xOle10Native.is())
|
|
|
|
{
|
|
|
|
const uno::Reference<io::XInputStream> xIn = xOle10Native->getInputStream();
|
|
|
|
xIn->skipBytes(4); //size of the entire stream minus 4 bytes
|
|
|
|
xIn->skipBytes(2); //word that represent the directory type
|
|
|
|
uno::Sequence< sal_Int8 > aData(1);
|
|
|
|
sal_Int32 nRead;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nRead = xIn->readBytes(aData, 1);
|
|
|
|
} while (nRead == 1 && aData[0] != 0); // file name plus extension of the attachment null terminated
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nRead = xIn->readBytes(aData, 1);
|
|
|
|
} while (nRead == 1 && aData[0] != 0); // Fully Qualified File name with extension
|
|
|
|
xIn->skipBytes(1); //single byte
|
|
|
|
xIn->skipBytes(1); //single byte
|
|
|
|
xIn->skipBytes(2); //Word that represent the directory type
|
|
|
|
xIn->skipBytes(4); //len of string
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nRead = xIn->readBytes(aData, 1);
|
|
|
|
} while (nRead == 1 && aData[0] != 0); // Actual string representing the file path
|
|
|
|
uno::Sequence< sal_Int8 > aLenData(4);
|
|
|
|
xIn->readBytes(aLenData, 4); //len of attachment
|
2017-01-23 10:50:10 +00:00
|
|
|
sal_uInt32 nLen = static_cast<sal_uInt32>(
|
|
|
|
(aLenData[0] & 0xFF) |
|
|
|
|
((aLenData[1] & 0xFF) << 8) |
|
|
|
|
((aLenData[2] & 0xFF) << 16) |
|
|
|
|
((aLenData[3] & 0xFF) << 24));
|
2017-01-12 09:49:36 +00:00
|
|
|
|
|
|
|
bCopied = lcl_CopyStream(xIn, xStream->getOutputStream(), nLen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-26 15:38:21 +02:00
|
|
|
uno::Reference< io::XSeekable > xSeekableStor(xObjectStream, uno::UNO_QUERY);
|
|
|
|
if (xSeekableStor.is())
|
|
|
|
xSeekableStor->seek(0);
|
|
|
|
|
|
|
|
if (!bCopied)
|
|
|
|
bCopied = lcl_CopyStream(xObjectStream->getInputStream(), xStream->getOutputStream());
|
|
|
|
|
|
|
|
if (bCopied)
|
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
xNativeTempFile->setPropertyValue("RemoveFile",
|
2016-04-20 17:16:42 +02:00
|
|
|
uno::makeAny(false));
|
2013-06-29 21:24:12 +02:00
|
|
|
uno::Any aUrl = xNativeTempFile->getPropertyValue("Uri");
|
2017-07-10 18:47:49 +02:00
|
|
|
aUrl >>= rUrl;
|
2010-05-26 15:38:21 +02:00
|
|
|
|
2015-10-30 14:22:53 +02:00
|
|
|
xNativeTempFile.clear();
|
2010-05-26 15:38:21 +02:00
|
|
|
|
2012-11-02 17:46:30 +02:00
|
|
|
uno::Reference < ucb::XSimpleFileAccess3 > xSimpleFileAccess(
|
2012-09-19 13:15:15 +02:00
|
|
|
ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) );
|
2010-05-26 15:38:21 +02:00
|
|
|
|
2017-07-10 18:47:49 +02:00
|
|
|
xSimpleFileAccess->setReadOnly(rUrl, true);
|
2010-05-26 15:38:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
xNativeTempFile->setPropertyValue("RemoveFile",
|
2016-04-20 17:16:42 +02:00
|
|
|
uno::makeAny(true));
|
2010-05-26 15:38:21 +02:00
|
|
|
}
|
2017-07-10 18:47:49 +02:00
|
|
|
|
|
|
|
return xStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Dump the objects content to a tempfile, just the "CONTENTS" stream if
|
|
|
|
//there is one for non-compound documents, otherwise the whole content.
|
|
|
|
//On success a file is returned which must be removed by the caller
|
|
|
|
OUString lcl_ExtractObject(const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory,
|
|
|
|
const css::uno::Reference< css::io::XStream >& xObjectStream)
|
|
|
|
{
|
|
|
|
OUString sUrl;
|
|
|
|
|
|
|
|
// the solution is only active for Unix systems
|
|
|
|
#ifndef _WIN32
|
|
|
|
lcl_GetExtractedStream(sUrl, xFactory, xObjectStream);
|
2012-04-15 15:52:16 +02:00
|
|
|
#else
|
|
|
|
(void) xFactory;
|
|
|
|
(void) xObjectStream;
|
2010-05-26 15:38:21 +02:00
|
|
|
#endif
|
|
|
|
return sUrl;
|
|
|
|
}
|
2017-07-10 18:47:49 +02:00
|
|
|
|
|
|
|
uno::Reference < io::XStream > lcl_ExtractObjectStream( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory,
|
|
|
|
const css::uno::Reference< css::io::XStream >& xObjectStream )
|
|
|
|
{
|
|
|
|
OUString sUrl;
|
|
|
|
return lcl_GetExtractedStream( sUrl, xFactory, xObjectStream );
|
|
|
|
}
|
2010-05-26 15:38:21 +02:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
2018-10-19 14:34:17 +01:00
|
|
|
xWrappedObject->doVerb(embed::EmbedVerbs::MS_OLEVERB_OPEN); // open content in the window not in-place
|
2008-07-22 13:39:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2005-03-15 10:38:59 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( m_aMutex );
|
2003-11-13 16:01:50 +00:00
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_pOleComponent )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2004-10-04 18:55:06 +00:00
|
|
|
sal_Int32 nOldState = m_nObjectState;
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
// TODO/LATER detect target state here and do a notification
|
|
|
|
// StateChangeNotification_Impl( sal_True, nOldState, nNewState );
|
|
|
|
if ( m_nObjectState == embed::EmbedStates::LOADED )
|
|
|
|
{
|
|
|
|
// if the target object is in loaded state
|
|
|
|
// it must be switched to running state to execute verb
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
|
|
|
changeState( embed::EmbedStates::RUNNING );
|
|
|
|
aGuard.reset();
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if ( !m_pOleComponent )
|
|
|
|
throw uno::RuntimeException();
|
|
|
|
|
2006-02-01 18:06:01 +00:00
|
|
|
// ==== the STAMPIT related solution =============================
|
|
|
|
m_aVerbExecutionController.StartControlExecution();
|
2014-02-25 18:24:45 +01:00
|
|
|
|
2006-02-01 18:06:01 +00:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
m_pOleComponent->ExecuteVerb( nVerbID );
|
2017-07-07 19:15:11 +02:00
|
|
|
m_pOleComponent->SetHostName( OUString(), m_aContainerName );
|
2006-02-01 18:06:01 +00:00
|
|
|
|
|
|
|
// ==== the STAMPIT related solution =============================
|
2016-10-14 16:56:42 +02:00
|
|
|
bool bModifiedOnExecution = m_aVerbExecutionController.EndControlExecution_WasModified();
|
2006-02-01 18:06:01 +00:00
|
|
|
|
|
|
|
// this workaround is implemented for STAMPIT object
|
|
|
|
// if object was modified during verb execution it is saved here
|
|
|
|
if ( bModifiedOnExecution && m_pOleComponent->IsDirty() )
|
|
|
|
SaveObject_Impl();
|
2014-02-25 18:24:45 +01:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
2006-02-01 18:06:01 +00:00
|
|
|
// ==== the STAMPIT related solution =============================
|
|
|
|
m_aVerbExecutionController.EndControlExecution_WasModified();
|
2014-02-25 18:24:45 +01:00
|
|
|
|
2006-02-01 18:06:01 +00:00
|
|
|
|
2005-03-15 10:38:59 +00:00
|
|
|
aGuard.clear();
|
2016-10-14 16:56:42 +02:00
|
|
|
StateChangeNotification_Impl( false, nOldState, m_nObjectState );
|
2004-10-04 18:55:06 +00:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
2003-12-15 14:37:44 +00:00
|
|
|
#endif
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
2017-09-27 09:11:35 +02:00
|
|
|
if ( nVerbID != -9 )
|
2005-01-18 14:10:21 +00:00
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2017-09-27 09:11:35 +02:00
|
|
|
throw embed::UnreachableStateException();
|
|
|
|
}
|
|
|
|
|
|
|
|
// the workaround verb to show the object in case no server is available
|
|
|
|
|
|
|
|
// if it is possible, the object will be converted to OOo format
|
|
|
|
if ( !m_bTriedConversion )
|
|
|
|
{
|
|
|
|
m_bTriedConversion = true;
|
|
|
|
if ( TryToConvertToOOo( m_xObjectStream ) )
|
2008-07-22 13:39:09 +00:00
|
|
|
{
|
2017-09-27 09:11:35 +02:00
|
|
|
changeState( embed::EmbedStates::ACTIVE );
|
|
|
|
return;
|
2008-07-22 13:39:09 +00:00
|
|
|
}
|
2017-09-27 09:11:35 +02:00
|
|
|
}
|
2008-07-22 13:39:09 +00:00
|
|
|
|
2017-09-27 09:11:35 +02:00
|
|
|
if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName != "Text" )
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY );
|
|
|
|
if ( xSeekable.is() )
|
|
|
|
xSeekable->seek( 0 );
|
2005-01-18 14:10:21 +00:00
|
|
|
|
2017-09-27 09:11:35 +02:00
|
|
|
m_xOwnView = new OwnView_Impl( m_xFactory, m_xObjectStream->getInputStream() );
|
2005-01-18 14:10:21 +00:00
|
|
|
}
|
2017-09-27 09:11:35 +02:00
|
|
|
catch( uno::RuntimeException& )
|
2017-07-10 18:47:49 +02:00
|
|
|
{
|
2017-09-27 09:11:35 +02:00
|
|
|
throw;
|
2017-07-10 18:47:49 +02:00
|
|
|
}
|
2019-06-14 15:30:08 +02:00
|
|
|
catch (uno::Exception const&)
|
2010-05-26 15:38:21 +02:00
|
|
|
{
|
2019-06-14 15:30:08 +02:00
|
|
|
TOOLS_WARN_EXCEPTION("embeddedobj.ole", "OleEmbeddedObject::doVerb: -9 fallback path:");
|
2017-09-27 09:11:35 +02:00
|
|
|
}
|
|
|
|
}
|
2010-05-26 15:38:21 +02:00
|
|
|
|
2017-09-27 09:11:35 +02:00
|
|
|
// it may be the OLE Storage, try to extract stream
|
|
|
|
if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName == "Text" )
|
|
|
|
{
|
|
|
|
uno::Reference< io::XStream > xStream = lcl_ExtractObjectStream( m_xFactory, m_xObjectStream );
|
|
|
|
|
|
|
|
if ( TryToConvertToOOo( xStream ) )
|
|
|
|
{
|
|
|
|
changeState( embed::EmbedStates::ACTIVE );
|
|
|
|
return;
|
2010-05-26 15:38:21 +02:00
|
|
|
}
|
2005-01-18 14:10:21 +00:00
|
|
|
}
|
2017-09-27 09:11:35 +02:00
|
|
|
|
|
|
|
if (!m_xOwnView.is() || !m_xOwnView->Open())
|
2010-05-26 15:38:21 +02:00
|
|
|
{
|
2017-09-27 09:11:35 +02:00
|
|
|
//Make a RO copy and see if the OS can find something to at
|
|
|
|
//least display the content for us
|
|
|
|
if (m_aTempDumpURL.isEmpty())
|
|
|
|
m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream);
|
|
|
|
|
|
|
|
if (m_aTempDumpURL.isEmpty())
|
|
|
|
throw embed::UnreachableStateException();
|
|
|
|
|
|
|
|
uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
|
|
|
|
css::system::SystemShellExecute::create(comphelper::getComponentContext(m_xFactory)) );
|
|
|
|
xSystemShellExecute->execute(m_aTempDumpURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
|
2010-05-26 15:38:21 +02:00
|
|
|
|
|
|
|
}
|
2017-09-27 09:11:35 +02:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2004-05-10 16:53:50 +00:00
|
|
|
uno::Sequence< embed::VerbDescriptor > SAL_CALL OleEmbeddedObject::getSupportedVerbs()
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
return xWrappedObject->getSupportedVerbs();
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_pOleComponent )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2005-01-31 08:02:47 +00:00
|
|
|
// registry could be used in this case
|
|
|
|
// if ( m_nObjectState == embed::EmbedStates::LOADED )
|
|
|
|
// {
|
|
|
|
// // the list of supported verbs can be retrieved only when object is in running state
|
|
|
|
// throw embed::NeedsRunningStateException(); // TODO:
|
|
|
|
// }
|
2003-12-15 14:37:44 +00:00
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
return m_pOleComponent->GetVerbList();
|
|
|
|
}
|
|
|
|
else
|
2003-12-15 14:37:44 +00:00
|
|
|
#endif
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
|
|
|
return uno::Sequence< embed::VerbDescriptor >();
|
|
|
|
}
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
void SAL_CALL OleEmbeddedObject::setClientSite(
|
|
|
|
const uno::Reference< embed::XEmbeddedClient >& xClient )
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
xWrappedObject->setClientSite( xClient );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
2005-11-10 15:12:49 +00:00
|
|
|
if ( m_xClientSite != xClient)
|
|
|
|
{
|
|
|
|
if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
|
|
|
|
throw embed::WrongStateException(
|
2014-05-26 14:29:07 +02:00
|
|
|
"The client site can not be set currently!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2005-11-10 15:12:49 +00:00
|
|
|
m_xClientSite = xClient;
|
|
|
|
}
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
uno::Reference< embed::XEmbeddedClient > SAL_CALL OleEmbeddedObject::getClientSite()
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
return xWrappedObject->getClientSite();
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
return m_xClientSite;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
void SAL_CALL OleEmbeddedObject::update()
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
xWrappedObject->update();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2004-05-10 16:53:50 +00:00
|
|
|
if ( m_nUpdateMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE )
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
|
|
|
// TODO: update view representation
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// the object must be up to date
|
2013-05-27 00:22:20 +03:00
|
|
|
SAL_WARN_IF( m_nUpdateMode != embed::EmbedUpdateModes::ALWAYS_UPDATE, "embeddedobj.ole", "Unknown update mode!" );
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
void SAL_CALL OleEmbeddedObject::setUpdateMode( sal_Int32 nMode )
|
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
xWrappedObject->setUpdateMode( nMode );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object has no persistence!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2004-05-10 16:53:50 +00:00
|
|
|
OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
|
|
|
|
|| nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
|
2017-07-11 15:55:02 +02:00
|
|
|
"Unknown update mode!" );
|
2003-11-13 16:01:50 +00:00
|
|
|
m_nUpdateMode = nMode;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2006-06-19 23:30:15 +00:00
|
|
|
sal_Int64 SAL_CALL OleEmbeddedObject::getStatus( sal_Int64
|
|
|
|
nAspect
|
|
|
|
)
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
return xWrappedObject->getStatus( nAspect );
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
2004-10-04 18:55:06 +00:00
|
|
|
if ( m_nObjectState == -1 )
|
2014-05-26 14:29:07 +02:00
|
|
|
throw embed::WrongStateException( "The object must be in running state!",
|
2014-05-26 15:26:03 +02:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this) );
|
2003-11-13 16:01:50 +00:00
|
|
|
|
2006-02-01 18:06:01 +00:00
|
|
|
sal_Int64 nResult = 0;
|
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2005-01-31 08:02:47 +00:00
|
|
|
if ( m_bGotStatus && m_nStatusAspect == nAspect )
|
2006-02-01 18:06:01 +00:00
|
|
|
nResult = m_nStatus;
|
2005-01-31 08:02:47 +00:00
|
|
|
else if ( m_pOleComponent )
|
2004-10-04 18:55:06 +00:00
|
|
|
{
|
2005-01-31 08:02:47 +00:00
|
|
|
|
|
|
|
m_nStatus = m_pOleComponent->GetMiscStatus( nAspect );
|
|
|
|
m_nStatusAspect = nAspect;
|
2016-10-14 16:56:42 +02:00
|
|
|
m_bGotStatus = true;
|
2006-02-01 18:06:01 +00:00
|
|
|
nResult = m_nStatus;
|
2004-10-04 18:55:06 +00:00
|
|
|
}
|
2003-12-15 14:37:44 +00:00
|
|
|
#endif
|
2006-02-01 18:06:01 +00:00
|
|
|
|
|
|
|
// this implementation needs size to be provided after object loading/creating to work in optimal way
|
|
|
|
return ( nResult | embed::EmbedMisc::EMBED_NEEDSSIZEONLOAD );
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL OleEmbeddedObject::setContainerName( const OUString& sName )
|
2004-05-10 16:53:50 +00:00
|
|
|
{
|
2008-07-22 13:39:09 +00:00
|
|
|
// begin wrapping related part ====================
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
|
|
|
|
if ( xWrappedObject.is() )
|
|
|
|
{
|
|
|
|
// the object was converted to OOo embedded object, the current implementation is now only a wrapper
|
|
|
|
xWrappedObject->setContainerName( sName );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// end wrapping related part ====================
|
|
|
|
|
2004-05-10 16:53:50 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bDisposed )
|
|
|
|
throw lang::DisposedException(); // TODO
|
|
|
|
|
|
|
|
m_aContainerName = sName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|