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