Kaydet (Commit) be8bbd29 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:flatten (clang-cl, embeddedobj)

Change-Id: Ic870347b3dc0ce6b7ad223c47a36b54843a26613
üst 3d1b53a0
...@@ -1563,19 +1563,17 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor& ...@@ -1563,19 +1563,17 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor&
uno::Reference< io::XOutputStream > xTempOutStream = xTempFileStream->getOutputStream(); uno::Reference< io::XOutputStream > xTempOutStream = xTempFileStream->getOutputStream();
uno::Reference< io::XInputStream > xTempInStream = xTempFileStream->getInputStream(); uno::Reference< io::XInputStream > xTempInStream = xTempFileStream->getInputStream();
if ( xTempOutStream.is() && xTempInStream.is() ) if ( !(xTempOutStream.is() && xTempInStream.is()) )
{ throw io::IOException(); // TODO:
OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" );
if ( !m_pUnoOleObject )
throw uno::RuntimeException();
m_pUnoOleObject->StoreObjectToStream( xTempOutStream ); OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" );
if ( !m_pUnoOleObject )
throw uno::RuntimeException();
xTempOutStream->closeOutput(); m_pUnoOleObject->StoreObjectToStream( xTempOutStream );
xTempOutStream.clear();
} xTempOutStream->closeOutput();
else xTempOutStream.clear();
throw io::IOException(); // TODO:
aResult <<= xTempInStream; aResult <<= xTempInStream;
} }
......
...@@ -176,92 +176,90 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia ...@@ -176,92 +176,90 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia
uTemp=pInsertFct(&io); uTemp=pInsertFct(&io);
if ( OLEUI_OK == uTemp ) if ( OLEUI_OK != uTemp )
throw ucb::CommandAbortedException();
if (io.dwFlags & IOF_SELECTCREATENEW)
{ {
if (io.dwFlags & IOF_SELECTCREATENEW) uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator = embed::EmbeddedObjectCreator::create( comphelper::getComponentContext(m_xFactory) );
{
uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator = embed::EmbeddedObjectCreator::create( comphelper::getComponentContext(m_xFactory) ); uno::Sequence< sal_Int8 > aClassID = MimeConfigurationHelper::GetSequenceClassID( io.clsid.Data1,
io.clsid.Data2,
uno::Sequence< sal_Int8 > aClassID = MimeConfigurationHelper::GetSequenceClassID( io.clsid.Data1, io.clsid.Data3,
io.clsid.Data2, io.clsid.Data4[0],
io.clsid.Data3, io.clsid.Data4[1],
io.clsid.Data4[0], io.clsid.Data4[2],
io.clsid.Data4[1], io.clsid.Data4[3],
io.clsid.Data4[2], io.clsid.Data4[4],
io.clsid.Data4[3], io.clsid.Data4[5],
io.clsid.Data4[4], io.clsid.Data4[6],
io.clsid.Data4[5], io.clsid.Data4[7] );
io.clsid.Data4[6],
io.clsid.Data4[7] ); aClassID = GetRelatedInternalID_Impl( aClassID );
aClassID = GetRelatedInternalID_Impl( aClassID ); //TODO: retrieve ClassName
aObjectInfo.Object.set( xEmbCreator->createInstanceInitNew( aClassID, OUString(), xStorage, sEntName, aObjArgs ),
//TODO: retrieve ClassName uno::UNO_QUERY );
aObjectInfo.Object.set( xEmbCreator->createInstanceInitNew( aClassID, OUString(), xStorage, sEntName, aObjArgs ), }
uno::UNO_QUERY ); else
} {
else OUString aFileName = OStringToOUString( OString( szFile ), osl_getThreadTextEncoding() );
{ OUString aFileURL;
OUString aFileName = OStringToOUString( OString( szFile ), osl_getThreadTextEncoding() ); if ( osl::FileBase::getFileURLFromSystemPath( aFileName, aFileURL ) != osl::FileBase::E_None )
OUString aFileURL; throw uno::RuntimeException();
if ( osl::FileBase::getFileURLFromSystemPath( aFileName, aFileURL ) != osl::FileBase::E_None )
throw uno::RuntimeException();
uno::Sequence< beans::PropertyValue > aMediaDescr( 1 ); uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
aMediaDescr[0].Name = "URL"; aMediaDescr[0].Name = "URL";
aMediaDescr[0].Value <<= aFileURL; aMediaDescr[0].Value <<= aFileURL;
// TODO: use config helper for type detection // TODO: use config helper for type detection
uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator; uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator;
::comphelper::MimeConfigurationHelper aHelper( comphelper::getComponentContext(m_xFactory) ); ::comphelper::MimeConfigurationHelper aHelper( comphelper::getComponentContext(m_xFactory) );
if ( aHelper.AddFilterNameCheckOwnFile( aMediaDescr ) ) if ( aHelper.AddFilterNameCheckOwnFile( aMediaDescr ) )
xEmbCreator = embed::EmbeddedObjectCreator::create( comphelper::getComponentContext(m_xFactory) ); xEmbCreator = embed::EmbeddedObjectCreator::create( comphelper::getComponentContext(m_xFactory) );
else else
xEmbCreator = embed::OLEEmbeddedObjectFactory::create( comphelper::getComponentContext(m_xFactory) ); xEmbCreator = embed::OLEEmbeddedObjectFactory::create( comphelper::getComponentContext(m_xFactory) );
if ( !xEmbCreator.is() ) if ( !xEmbCreator.is() )
throw uno::RuntimeException(); throw uno::RuntimeException();
aObjectInfo.Object.set( xEmbCreator->createInstanceInitFromMediaDescriptor( xStorage, sEntName, aMediaDescr, aObjArgs ), aObjectInfo.Object.set( xEmbCreator->createInstanceInitFromMediaDescriptor( xStorage, sEntName, aMediaDescr, aObjArgs ),
uno::UNO_QUERY ); uno::UNO_QUERY );
} }
if ( ( io.dwFlags & IOF_CHECKDISPLAYASICON) && io.hMetaPict != nullptr ) if ( ( io.dwFlags & IOF_CHECKDISPLAYASICON) && io.hMetaPict != nullptr )
{
METAFILEPICT* pMF = static_cast<METAFILEPICT*>(GlobalLock( io.hMetaPict ));
if ( pMF )
{ {
METAFILEPICT* pMF = static_cast<METAFILEPICT*>(GlobalLock( io.hMetaPict )); sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, nullptr );
if ( pMF ) uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 );
sal_Int8* pBuf = aMetafile.getArray();
*reinterpret_cast<long*>( pBuf ) = 0x9ac6cdd7L;
*reinterpret_cast<short*>( pBuf+6 ) = ( SHORT ) 0;
*reinterpret_cast<short*>( pBuf+8 ) = ( SHORT ) 0;
*reinterpret_cast<short*>( pBuf+10 ) = ( SHORT ) pMF->xExt;
*reinterpret_cast<short*>( pBuf+12 ) = ( SHORT ) pMF->yExt;
*reinterpret_cast<short*>( pBuf+14 ) = ( USHORT ) 2540;
if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) )
{ {
sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, nullptr ); datatransfer::DataFlavor aFlavor(
uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 ); "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"",
sal_Int8* pBuf = aMetafile.getArray(); "Image WMF",
*reinterpret_cast<long*>( pBuf ) = 0x9ac6cdd7L; cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
*reinterpret_cast<short*>( pBuf+6 ) = ( SHORT ) 0;
*reinterpret_cast<short*>( pBuf+8 ) = ( SHORT ) 0; aObjectInfo.Options.realloc( 2 );
*reinterpret_cast<short*>( pBuf+10 ) = ( SHORT ) pMF->xExt; aObjectInfo.Options[0].Name = "Icon";
*reinterpret_cast<short*>( pBuf+12 ) = ( SHORT ) pMF->yExt; aObjectInfo.Options[0].Value <<= aMetafile;
*reinterpret_cast<short*>( pBuf+14 ) = ( USHORT ) 2540; aObjectInfo.Options[1].Name = "IconFormat";
aObjectInfo.Options[1].Value <<= aFlavor;
if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) )
{
datatransfer::DataFlavor aFlavor(
"application/x-openoffice-wmf;windows_formatname=\"Image WMF\"",
"Image WMF",
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
aObjectInfo.Options.realloc( 2 );
aObjectInfo.Options[0].Name = "Icon";
aObjectInfo.Options[0].Value <<= aMetafile;
aObjectInfo.Options[1].Name = "IconFormat";
aObjectInfo.Options[1].Value <<= aFlavor;
}
GlobalUnlock( io.hMetaPict );
} }
GlobalUnlock( io.hMetaPict );
} }
} }
else
throw ucb::CommandAbortedException();
OSL_ENSURE( aObjectInfo.Object.is(), "No object was created!" ); OSL_ENSURE( aObjectInfo.Object.is(), "No object was created!" );
if ( !aObjectInfo.Object.is() ) if ( !aObjectInfo.Object.is() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment