From 8daa13abb5ebec4d0b867f1d56ebc8516ae3bb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 9 May 2017 13:27:06 +0100 Subject: [PATCH 2/2] Resolves: tdf#62702 allow ole objects to be inserted as icons under windows on "create new", "further objects" you get the native windows insert object dialog which has the "Display As Icon" option, but on Linux etc (or using our own dialog) there isn't that option so add a "Display as icon" checkbox in our own dialog and generate an icon through SvFileInformationManager::GetImage Change-Id: I0a400189031900bd1e387465ec4ba57847cb5394 (cherry picked from commit f505f95d466d4d3348f41dfd93e5c243d15c6c71) --- cui/source/dialogs/insdlg.cxx | 16 +++++ cui/source/inc/insdlg.hxx | 1 + cui/uiconfig/ui/insertoleobject.ui | 131 +++++++++++++++++++++---------------- 3 files changed, 90 insertions(+), 58 deletions(-) diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx index 47af495..ac404bb 100644 --- a/cui/source/dialogs/insdlg.cxx +++ b/cui/source/dialogs/insdlg.cxx @@ -34,6 +34,7 @@ #include "insdlg.hxx" #include +#include #include #include @@ -164,6 +165,7 @@ SvInsertOleDlg::SvInsertOleDlg get(m_pEdFilepath, "urled"); get(m_pBtnFilepath, "urlbtn"); get(m_pCbFilelink, "linktofile"); + get(m_pCbAsIcon, "asicon"); m_pLbObjecttype->SetDoubleClickHdl( LINK( this, SvInsertOleDlg, DoubleClickHdl ) ); m_pBtnFilepath->SetClickHdl( LINK( this, SvInsertOleDlg, BrowseHdl ) ); Link aLink( LINK( this, SvInsertOleDlg, RadioHdl ) ); @@ -188,6 +190,7 @@ void SvInsertOleDlg::dispose() m_pEdFilepath.clear(); m_pBtnFilepath.clear(); m_pCbFilelink.clear(); + m_pCbAsIcon.clear(); InsertObjectDialog_Impl::dispose(); } @@ -328,6 +331,19 @@ short SvInsertOleDlg::Execute() aErr = aErr.replaceFirst( "%", aFileName ); ScopedVclPtrInstance(this, aErr)->Execute(); } + else + { + if (m_pCbAsIcon->IsChecked()) + { + //something nice here I guess would be to write the filename into + //the image with this icon above it + Image aImage = SvFileInformationManager::GetImage(aURL, true); + SvMemoryStream aTemp; + WriteDIBBitmapEx(aImage.GetBitmapEx(), aTemp); + m_aIconMetaFile = Sequence(static_cast(aTemp.GetData()), aTemp.Seek(STREAM_SEEK_TO_END)); + m_aIconMediaType = "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\""; + } + } } } diff --git a/cui/source/inc/insdlg.hxx b/cui/source/inc/insdlg.hxx index cd6a45a..4b42774 100644 --- a/cui/source/inc/insdlg.hxx +++ b/cui/source/inc/insdlg.hxx @@ -64,6 +64,7 @@ class SvInsertOleDlg : public InsertObjectDialog_Impl VclPtr m_pEdFilepath; VclPtr m_pBtnFilepath; VclPtr m_pCbFilelink; + VclPtr m_pCbAsIcon; const SvObjectServerList* m_pServers; css::uno::Sequence< sal_Int8 > m_aIconMetaFile; diff --git a/cui/uiconfig/ui/insertoleobject.ui b/cui/uiconfig/ui/insertoleobject.ui index 5ddf229..1aaeecb 100644 --- a/cui/uiconfig/ui/insertoleobject.ui +++ b/cui/uiconfig/ui/insertoleobject.ui @@ -1,5 +1,5 @@ - + @@ -12,6 +12,63 @@ False vertical 12 + + + False + end + + + gtk-ok + True + True + True + True + True + True + + + False + True + 0 + + + + + gtk-cancel + True + True + True + True + + + False + True + 1 + + + + + gtk-help + True + True + True + True + + + False + True + 2 + True + + + + + False + True + end + 1 + + 400 @@ -162,6 +219,21 @@ 1 + + + Display as icon + True + True + False + 0 + True + + + 0 + 2 + 2 + + @@ -191,63 +263,6 @@ 0 - - - False - end - - - gtk-ok - True - True - True - True - True - True - - - False - True - 0 - - - - - gtk-cancel - True - True - True - True - - - False - True - 1 - - - - - gtk-help - True - True - True - True - - - False - True - 2 - True - - - - - False - True - end - 1 - - -- 2.9.3