diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-04-13 16:58:49 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-04-16 02:52:02 +0200 |
commit | 9fb7aaf570c03c8a26d763f1205fb8c890e8211a (patch) | |
tree | 8f4466b24d9fcae2da5043479a57fabc662a2c43 /sfx2 | |
parent | ba69036c8e889237da4bb312d7c5c94066abbfd3 (diff) |
Make linked graphic register into LinkedManager again
Change-Id: I16b162f86d6221d120f6355f9a52c1abfcd0ac73
Reviewed-on: https://gerrit.libreoffice.org/52911
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/fileobj.cxx | 100 | ||||
-rw-r--r-- | sfx2/source/appl/linkmgr2.cxx | 27 |
2 files changed, 26 insertions, 101 deletions
diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx index f19e7f9acc72..371d8839f75a 100644 --- a/sfx2/source/appl/fileobj.cxx +++ b/sfx2/source/appl/fileobj.cxx @@ -76,7 +76,7 @@ SvFileObject::~SvFileObject() bool SvFileObject::GetData( css::uno::Any & rData, const OUString & rMimeType, - bool bGetSynchron ) + bool /*bGetSynchron*/ ) { SotClipboardFormatId nFmt = SotExchange::RegisterFormatMimeType( rMimeType ); switch( nType ) @@ -92,101 +92,11 @@ bool SvFileObject::GetData( css::uno::Any & rData, break; case FILETYPE_GRF: - if( !bLoadError ) + if (SotClipboardFormatId::GDIMETAFILE == nFmt + || SotClipboardFormatId::BITMAP == nFmt + || SotClipboardFormatId::SVXB == nFmt) { - tools::SvRef<SfxMedium> xTmpMed; - - if( SotClipboardFormatId::GDIMETAFILE == nFmt || SotClipboardFormatId::BITMAP == nFmt || - SotClipboardFormatId::SVXB == nFmt ) - { - Graphic aGrf; - - // If the native format is requested, has to be reset at the - // end of the flag. Is solely in the sw/ndgrf.cxx used when - // the link is removed form GraphicNode. - bool bOldNativFormat = bNativFormat; - - // If about to print, waiting for the data to be available - if( bGetSynchron ) - { - // call a LoadFile every second time to test the loading - if( !xMed.is() ) - LoadFile_Impl(); - - if( !bInCallDownload ) - { - xTmpMed = xMed; - while( bWaitForData ) - Application::Reschedule(); - - xMed = xTmpMed; - bClearMedium = true; - } - } - - if( !bWaitForData && ( xMed.is() || // was loaded as URL - ( bSynchron && LoadFile_Impl() && xMed.is() ) ) ) - { - // If it was loaded from the Internet, do not retry - if( !bGetSynchron ) - bLoadAgain = !xMed->IsRemote(); - bLoadError = !GetGraphic_Impl( aGrf, xMed->GetInStream() ); - } - else if( !LoadFile_Impl() || - !GetGraphic_Impl( aGrf, xMed.is() ? xMed->GetInStream() : nullptr )) - { - if( !xMed.is() ) - break; - aGrf.SetDefaultType(); - } - - if( SotClipboardFormatId::SVXB != nFmt ) - nFmt = (bLoadError || GraphicType::Bitmap == aGrf.GetType()) - ? SotClipboardFormatId::BITMAP - : SotClipboardFormatId::GDIMETAFILE; - - SvMemoryStream aMemStm( 0, 65535 ); - switch ( nFmt ) - { - case SotClipboardFormatId::SVXB: - if( GraphicType::NONE != aGrf.GetType() ) - { - aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 ); - WriteGraphic( aMemStm, aGrf ); - } - break; - - case SotClipboardFormatId::BITMAP: - { - const Bitmap aBitmap(aGrf.GetBitmap()); - - if(!aBitmap.IsEmpty()) - { - WriteDIB(aBitmap, aMemStm, false, true); - } - - break; - } - - default: - if( aGrf.GetGDIMetaFile().GetActionSize() ) - { - GDIMetaFile aMeta( aGrf.GetGDIMetaFile() ); - aMeta.Write( aMemStm ); - } - } - rData <<= css::uno::Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMemStm.GetData()), - aMemStm.Seek( STREAM_SEEK_TO_END ) ); - - bNativFormat = bOldNativFormat; - - // Everything ready? - if( xMed.is() && !bSynchron && bClearMedium ) - { - xMed.clear(); - bClearMedium = false; - } - } + rData <<= sFileNm; } break; case FILETYPE_OBJECT: diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 9ca22e8256e1..64e89a927f12 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -40,6 +40,7 @@ #include <sfx2/request.hxx> #include <vcl/dibtools.hxx> #include <unotools/charclass.hxx> +#include <vcl/GraphicLoader.hxx> #include "fileobj.hxx" #include "impldde.hxx" @@ -498,12 +499,26 @@ SotClipboardFormatId LinkManager::RegisterStatusInfoId() bool LinkManager::GetGraphicFromAny( const OUString& rMimeType, const css::uno::Any & rValue, - Graphic& rGrf ) + Graphic& rGraphic ) { bool bRet = false; - css::uno::Sequence< sal_Int8 > aSeq; - if( rValue.hasValue() && ( rValue >>= aSeq ) ) + + if (!rValue.hasValue()) + return bRet; + + if (rValue.has<OUString>()) { + OUString sURL = rValue.get<OUString>(); + rGraphic = vcl::graphic::loadFromURL(sURL); + if (!rGraphic) + rGraphic.SetDefaultType(); + rGraphic.setOriginURL(sURL); + return true; + } + else if (rValue.has<css::uno::Sequence<sal_Int8>>()) + { + auto aSeq = rValue.get<css::uno::Sequence<sal_Int8>>(); + SvMemoryStream aMemStm( const_cast<sal_Int8 *>(aSeq.getConstArray()), aSeq.getLength(), StreamMode::READ ); aMemStm.Seek( 0 ); @@ -512,7 +527,7 @@ bool LinkManager::GetGraphicFromAny( const OUString& rMimeType, { case SotClipboardFormatId::SVXB: { - ReadGraphic( aMemStm, rGrf ); + ReadGraphic( aMemStm, rGraphic ); bRet = true; } break; @@ -520,7 +535,7 @@ bool LinkManager::GetGraphicFromAny( const OUString& rMimeType, { GDIMetaFile aMtf; aMtf.Read( aMemStm ); - rGrf = aMtf; + rGraphic = aMtf; bRet = true; } break; @@ -528,7 +543,7 @@ bool LinkManager::GetGraphicFromAny( const OUString& rMimeType, { Bitmap aBmp; ReadDIB(aBmp, aMemStm, true); - rGrf = aBmp; + rGraphic = aBmp; bRet = true; } break; |