diff options
Diffstat (limited to 'forms/source/component/ImageControl.cxx')
-rw-r--r-- | forms/source/component/ImageControl.cxx | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index 9f56265bee00..0f48eecf5496 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -44,14 +44,14 @@ #include <tools/urlobj.hxx> #include <tools/stream.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/graph.hxx> #include <vcl/svapp.hxx> -#include <unotools/streamhelper.hxx> #include <comphelper/guarding.hxx> #include <comphelper/property.hxx> #include <comphelper/types.hxx> #include <cppuhelper/queryinterface.hxx> +#include <unotools/streamwrap.hxx> #include <unotools/ucbstreamhelper.hxx> #include <svl/urihelper.hxx> @@ -129,7 +129,7 @@ Sequence<Type> OImageControlModel::_getTypes() OImageControlModel::OImageControlModel(const Reference<XComponentContext>& _rxFactory) :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_IMAGECONTROL, FRM_SUN_CONTROL_IMAGECONTROL, false, false, false ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons ,m_bExternalGraphic( true ) ,m_bReadOnly( false ) { @@ -142,7 +142,7 @@ OImageControlModel::OImageControlModel(const Reference<XComponentContext>& _rxFa OImageControlModel::OImageControlModel( const OImageControlModel* _pOriginal, const Reference< XComponentContext >& _rxFactory ) :OBoundControlModel( _pOriginal, _rxFactory ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons ,m_bExternalGraphic( true ) ,m_bReadOnly( _pOriginal->m_bReadOnly ) ,m_sImageURL( _pOriginal->m_sImageURL ) @@ -399,7 +399,6 @@ void OImageControlModel::read(const Reference<XObjectInputStream>& _rxInStream) bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator ) { // create a stream for the image specified by the URL - std::unique_ptr< SvStream > pImageStream; Reference< XInputStream > xImageStream; if ( ::svt::GraphicAccess::isSupportedURL( _rURL ) ) @@ -408,19 +407,11 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, Val } else { - pImageStream = ::utl::UcbStreamHelper::CreateStream( _rURL, StreamMode::READ ); + std::unique_ptr< SvStream > pImageStream = ::utl::UcbStreamHelper::CreateStream( _rURL, StreamMode::READ ); bool bSetNull = (pImageStream == nullptr) || (ERRCODE_NONE != pImageStream->GetErrorCode()); if ( !bSetNull ) - { - // get the size of the stream - sal_uInt64 const nSize = pImageStream->remainingSize(); - if (pImageStream->GetBufferSize() < 8192) - pImageStream->SetBufferSize(8192); - pImageStream->Seek(STREAM_SEEK_TO_BEGIN); - - xImageStream = new ::utl::OInputStreamHelper( new SvLockBytes( pImageStream.get(), false ), nSize ); - } + xImageStream = new ::utl::OInputStreamWrapper( std::move(pImageStream) ); } if ( xImageStream.is() ) @@ -428,7 +419,7 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, Val if ( m_xColumnUpdate.is() ) m_xColumnUpdate->updateBinaryStream( xImageStream, xImageStream->available() ); else - setControlValue( makeAny( xImageStream ), _eInstigator ); + setControlValue( Any( xImageStream ), _eInstigator ); xImageStream->closeInput(); return true; } @@ -549,14 +540,14 @@ Any OImageControlModel::translateDbColumnToControlValue() Reference< XInputStream > xImageStream( m_xColumn->getBinaryStream() ); if ( m_xColumn->wasNull() ) xImageStream.clear(); - return makeAny( xImageStream ); + return Any( xImageStream ); } case ImageStoreLink: { OUString sImageLink( m_xColumn->getString() ); if ( !m_sDocumentURL.isEmpty() ) sImageLink = INetURLObject::GetAbsURL( m_sDocumentURL, sImageLink ); - return makeAny( sImageLink ); + return Any( sImageLink ); } case ImageStoreInvalid: OSL_FAIL( "OImageControlModel::translateDbColumnToControlValue: invalid field type!" ); @@ -568,7 +559,7 @@ Any OImageControlModel::translateDbColumnToControlValue() Any OImageControlModel::getControlValue( ) const { - return makeAny( m_sImageURL ); + return Any( m_sImageURL ); } @@ -657,7 +648,7 @@ IMPL_LINK( OImageControlModel, OnImageImportDone, ::Graphic*, i_pGraphic, void ) m_bExternalGraphic = false; try { - setPropertyValue( PROPERTY_GRAPHIC, makeAny( xGraphic ) ); + setPropertyValue( PROPERTY_GRAPHIC, Any( xGraphic ) ); } catch ( const Exception& ) { @@ -761,12 +752,12 @@ void OImageControlControl::implClearGraphics( bool _bForce ) if ( sOldImageURL.isEmpty() ) // the ImageURL is already empty, so simply setting a new empty one would not suffice // (since it would be ignored) - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString( "private:emptyImage" ) ) ); + xSet->setPropertyValue( PROPERTY_IMAGE_URL, Any( OUString( "private:emptyImage" ) ) ); // (the concrete URL we're passing here doesn't matter. It's important that // the model cannot resolve it to a valid resource describing an image stream } - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString() ) ); + xSet->setPropertyValue( PROPERTY_IMAGE_URL, Any( OUString() ) ); } @@ -805,7 +796,7 @@ bool OImageControlControl::implInsertGraphics() OSL_VERIFY( xBoundField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType ); bImageIsLinked = ( lcl_getImageStoreType( nFieldType ) == ImageStoreLink ); } - xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny( bImageIsLinked ) ); + xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, Any( bImageIsLinked ) ); if ( ERRCODE_NONE == aDialog.Execute() ) { @@ -823,10 +814,10 @@ bool OImageControlControl::implInsertGraphics() { Graphic aGraphic; aDialog.GetGraphic( aGraphic ); - xSet->setPropertyValue( PROPERTY_GRAPHIC, makeAny( aGraphic.GetXGraphic() ) ); + xSet->setPropertyValue( PROPERTY_GRAPHIC, Any( aGraphic.GetXGraphic() ) ); } else - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( aDialog.GetPath() ) ); + xSet->setPropertyValue( PROPERTY_IMAGE_URL, Any( aDialog.GetPath() ) ); return true; } |