diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-19 12:47:45 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-19 13:49:29 +0100 |
commit | 27c6b8586d5d2cd1fa5425b4969d915a0b739475 (patch) | |
tree | 71000886985f479c3c4668a884353a1a0bae9784 /svtools | |
parent | f731ecfd7bd3c703455e07447e9bb593e7b6e059 (diff) |
svtools: implement clipboard import of JPEG files
With this, lok::Document::paste("image/jpeg", "...") as invoked by
gtktiledviewer results in a Writer image just like the previously
already working PNG variant.
Change-Id: I9e7b94043519db4ccf3c9ad32474a15275896dd4
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/misc/transfer.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 0371ea8276eb..ccad405e1fce 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -60,6 +60,7 @@ #include <vcl/dibtools.hxx> #include <vcl/pngread.hxx> #include <vcl/pngwrite.hxx> +#include <vcl/graphicfilter.hxx> #include <memory> // - Namespaces - @@ -1628,11 +1629,19 @@ bool TransferableDataHelper::GetBitmapEx( const DataFlavor& rFlavor, BitmapEx& r DataFlavor aSubstFlavor; bool bRet(GetSotStorageStream(rFlavor, xStm)); bool bSuppressPNG(false); // #122982# If PNG stream not accessed, but BMP one, suppress trying to load PNG + bool bSuppressJPEG(false); if(!bRet && HasFormat(SotClipboardFormatId::PNG) && SotExchange::GetFormatDataFlavor(SotClipboardFormatId::PNG, aSubstFlavor)) { // when no direct success, try if PNG is available bRet = GetSotStorageStream(aSubstFlavor, xStm); + bSuppressJPEG = bRet; + } + + if(!bRet && HasFormat(SotClipboardFormatId::JPEG) && SotExchange::GetFormatDataFlavor(SotClipboardFormatId::JPEG, aSubstFlavor)) + { + bRet = GetSotStorageStream(aSubstFlavor, xStm); + bSuppressPNG = bRet; } if(!bRet && HasFormat(SotClipboardFormatId::BMP) && SotExchange::GetFormatDataFlavor(SotClipboardFormatId::BMP, aSubstFlavor)) @@ -1640,6 +1649,7 @@ bool TransferableDataHelper::GetBitmapEx( const DataFlavor& rFlavor, BitmapEx& r // when no direct success, try if BMP is available bRet = GetSotStorageStream(aSubstFlavor, xStm); bSuppressPNG = bRet; + bSuppressJPEG = bRet; } if(bRet) @@ -1651,6 +1661,14 @@ bool TransferableDataHelper::GetBitmapEx( const DataFlavor& rFlavor, BitmapEx& r rBmpEx = aPNGReader.Read(); } + else if(!bSuppressJPEG && rFlavor.MimeType.equalsIgnoreAsciiCase("image/jpeg")) + { + // it's a JPEG, import to BitmapEx + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); + Graphic aGraphic; + if (rFilter.ImportGraphic(aGraphic, "", *xStm) == GRFILTER_OK) + rBmpEx = aGraphic.GetBitmapEx(); + } if(rBmpEx.IsEmpty()) { @@ -1800,6 +1818,13 @@ bool TransferableDataHelper::GetGraphic( const css::datatransfer::DataFlavor& rF if( ( bRet = GetBitmapEx( aFlavor, aBmpEx ) ) ) rGraphic = aBmpEx; } + else if (SotExchange::GetFormatDataFlavor(SotClipboardFormatId::JPEG, aFlavor) && TransferableDataHelper::IsEqual(aFlavor, rFlavor)) + { + BitmapEx aBitmapEx; + + if ((bRet = GetBitmapEx(aFlavor, aBitmapEx))) + rGraphic = aBitmapEx; + } else if(SotExchange::GetFormatDataFlavor( SotClipboardFormatId::BITMAP, aFlavor ) && TransferableDataHelper::IsEqual( aFlavor, rFlavor ) ) { |