Correct indentation of try block

Change-Id: I32ca961ebb4393e483bab12a6c69ab4c2016cc3f
This commit is contained in:
Tor Lillqvist 2017-03-01 14:59:22 +02:00
parent 79d93c7d11
commit 7dae589b0c

View File

@ -2200,84 +2200,85 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
if ( xLoader.is() ) if ( xLoader.is() )
{ {
// it happens that xLoader does not support xImporter! // it happens that xLoader does not support xImporter!
try{ try
uno::Reference< lang::XComponent > xComp( GetModel(), uno::UNO_QUERY_THROW );
uno::Reference< document::XImporter > xImporter( xLoader, uno::UNO_QUERY_THROW );
xImporter->setTargetDocument( xComp );
uno::Sequence < beans::PropertyValue > lDescriptor;
rMedium.GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, rMedium.GetName() ) );
TransformItems( SID_OPENDOC, *rMedium.GetItemSet(), lDescriptor );
css::uno::Sequence < css::beans::PropertyValue > aArgs ( lDescriptor.getLength() );
css::beans::PropertyValue * pNewValue = aArgs.getArray();
const css::beans::PropertyValue * pOldValue = lDescriptor.getConstArray();
const OUString sInputStream ( "InputStream" );
bool bHasInputStream = false;
bool bHasBaseURL = false;
sal_Int32 i;
sal_Int32 nEnd = lDescriptor.getLength();
for ( i = 0; i < nEnd; i++ )
{ {
pNewValue[i] = pOldValue[i]; uno::Reference< lang::XComponent > xComp( GetModel(), uno::UNO_QUERY_THROW );
if ( pOldValue [i].Name == sInputStream ) uno::Reference< document::XImporter > xImporter( xLoader, uno::UNO_QUERY_THROW );
bHasInputStream = true; xImporter->setTargetDocument( xComp );
else if ( pOldValue[i].Name == "DocumentBaseURL" )
bHasBaseURL = true;
}
if ( !bHasInputStream ) uno::Sequence < beans::PropertyValue > lDescriptor;
{ rMedium.GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, rMedium.GetName() ) );
aArgs.realloc ( ++nEnd ); TransformItems( SID_OPENDOC, *rMedium.GetItemSet(), lDescriptor );
aArgs[nEnd-1].Name = sInputStream;
aArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XInputStream > ( new utl::OSeekableInputStreamWrapper ( *rMedium.GetInStream() ) );
}
if ( !bHasBaseURL ) css::uno::Sequence < css::beans::PropertyValue > aArgs ( lDescriptor.getLength() );
{ css::beans::PropertyValue * pNewValue = aArgs.getArray();
aArgs.realloc ( ++nEnd ); const css::beans::PropertyValue * pOldValue = lDescriptor.getConstArray();
aArgs[nEnd-1].Name = "DocumentBaseURL"; const OUString sInputStream ( "InputStream" );
aArgs[nEnd-1].Value <<= rMedium.GetBaseURL();
}
if (xInsertPosition.is()) { bool bHasInputStream = false;
aArgs.realloc( ++nEnd ); bool bHasBaseURL = false;
aArgs[nEnd-1].Name = "InsertMode"; sal_Int32 i;
aArgs[nEnd-1].Value <<= true; sal_Int32 nEnd = lDescriptor.getLength();
aArgs.realloc( ++nEnd );
aArgs[nEnd-1].Name = "TextInsertModeRange";
aArgs[nEnd-1].Value <<= xInsertPosition;
}
// #i119492# During loading, some OLE objects like chart will be set for ( i = 0; i < nEnd; i++ )
// modified flag, so needs to reset the flag to false after loading
bool bRtn = xLoader->filter( aArgs );
uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
for ( sal_Int32 n = 0; n < aNames.getLength(); ++n )
{
OUString aName = aNames[n];
uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aName );
OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!\n" );
if ( xObj.is() )
{ {
sal_Int32 nState = xObj->getCurrentState(); pNewValue[i] = pOldValue[i];
if ( nState == embed::EmbedStates::LOADED || nState == embed::EmbedStates::RUNNING ) // means that the object is not active if ( pOldValue [i].Name == sInputStream )
bHasInputStream = true;
else if ( pOldValue[i].Name == "DocumentBaseURL" )
bHasBaseURL = true;
}
if ( !bHasInputStream )
{
aArgs.realloc ( ++nEnd );
aArgs[nEnd-1].Name = sInputStream;
aArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XInputStream > ( new utl::OSeekableInputStreamWrapper ( *rMedium.GetInStream() ) );
}
if ( !bHasBaseURL )
{
aArgs.realloc ( ++nEnd );
aArgs[nEnd-1].Name = "DocumentBaseURL";
aArgs[nEnd-1].Value <<= rMedium.GetBaseURL();
}
if (xInsertPosition.is()) {
aArgs.realloc( ++nEnd );
aArgs[nEnd-1].Name = "InsertMode";
aArgs[nEnd-1].Value <<= true;
aArgs.realloc( ++nEnd );
aArgs[nEnd-1].Name = "TextInsertModeRange";
aArgs[nEnd-1].Value <<= xInsertPosition;
}
// #i119492# During loading, some OLE objects like chart will be set
// modified flag, so needs to reset the flag to false after loading
bool bRtn = xLoader->filter( aArgs );
uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
for ( sal_Int32 n = 0; n < aNames.getLength(); ++n )
{
OUString aName = aNames[n];
uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aName );
OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!\n" );
if ( xObj.is() )
{ {
uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY ); sal_Int32 nState = xObj->getCurrentState();
if (xModifiable.is() && xModifiable->isModified()) if ( nState == embed::EmbedStates::LOADED || nState == embed::EmbedStates::RUNNING ) // means that the object is not active
{ {
uno::Reference<embed::XEmbedPersist> const xPers(xObj, uno::UNO_QUERY); uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
assert(xPers.is() && "Modified object without persistence!"); if (xModifiable.is() && xModifiable->isModified())
// store it before resetting modified! {
xPers->storeOwn(); uno::Reference<embed::XEmbedPersist> const xPers(xObj, uno::UNO_QUERY);
xModifiable->setModified(false); assert(xPers.is() && "Modified object without persistence!");
// store it before resetting modified!
xPers->storeOwn();
xModifiable->setModified(false);
}
} }
} }
} }
} return bRtn;
return bRtn;
} }
catch (const packages::zip::ZipIOException&) catch (const packages::zip::ZipIOException&)
{ {