Hi!

I already made a patch for this bug, but this is a better solution ( at least i 
think :) )
I added a 'Copy to Clipboard' button to MessBox, so error messages are now 
copyable.

Here's the bug (there's a screenshot of the patch as well):
https://bugs.freedesktop.org/show_bug.cgi?id=46193

Szabolcs
                                          
From e2564587defc9631694d13adf1e92746b2e09253 Mon Sep 17 00:00:00 2001
From: Szabolcs Dezsi <[email protected]>
Date: Thu, 1 Mar 2012 20:13:21 +0100
Subject: [PATCH] Added 'Copy to Clipboard button to errordialogs

---
 tools/inc/tools/wintypes.hxx |    1 +
 vcl/inc/svids.hrc            |    1 +
 vcl/inc/vcl/msgbox.hxx       |    4 ++++
 vcl/source/src/btntext.src   |    5 +++++
 vcl/source/window/msgbox.cxx |   26 ++++++++++++++++++++------
 5 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/tools/inc/tools/wintypes.hxx b/tools/inc/tools/wintypes.hxx
index e4f0a0d..7820669 100644
--- a/tools/inc/tools/wintypes.hxx
+++ b/tools/inc/tools/wintypes.hxx
@@ -336,6 +336,7 @@ typedef sal_uInt16 StandardButtonType;
 #define BUTTON_ABORT        ((StandardButtonType)9)
 #define BUTTON_LESS         ((StandardButtonType)10)
 #define BUTTON_COUNT        11
+#define BUTTON_COPY	    12
 
 // --------------------------------------------
 // - prominent place for ListBox window types -
diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc
index 5eba318..e337bc7 100644
--- a/vcl/inc/svids.hrc
+++ b/vcl/inc/svids.hrc
@@ -183,6 +183,7 @@
 #define SV_BUTTONTEXT_IGNORE                10108
 #define SV_BUTTONTEXT_ABORT             10109
 #define SV_BUTTONTEXT_LESS                  10110
+#define SV_BUTTONTEXT_COPY		    10111
 
 #define SV_STDTEXT_FIRST                    SV_STDTEXT_SERVICENOTAVAILABLE
 #define SV_STDTEXT_SERVICENOTAVAILABLE      10200
diff --git a/vcl/inc/vcl/msgbox.hxx b/vcl/inc/vcl/msgbox.hxx
index fb960b8..1c1dcee 100644
--- a/vcl/inc/vcl/msgbox.hxx
+++ b/vcl/inc/vcl/msgbox.hxx
@@ -34,6 +34,8 @@
 #include <vcl/btndlg.hxx>
 #include <vcl/image.hxx>
 #include <vcl/bitmap.hxx>
+#include <vcl/button.hxx>
+
 class FixedText;
 class FixedImage;
 class CheckBox;
@@ -104,6 +106,8 @@ public:
     sal_Bool                GetCheckBoxState() const;
 
     virtual Size        GetOptimalSize(WindowSizeType eType) const;
+
+    DECL_LINK( ClickHdl, Button* );
 };
 
 // -----------
diff --git a/vcl/source/src/btntext.src b/vcl/source/src/btntext.src
index c0303aa..6762f08 100644
--- a/vcl/source/src/btntext.src
+++ b/vcl/source/src/btntext.src
@@ -69,6 +69,11 @@ String SV_BUTTONTEXT_LESS
     Text [ en-US ] = "~Less";
 };
 
+String SV_BUTTONTEXT_COPY
+{
+    Text [ en-US ] = "Copy to Clipboard";
+};
+
 String SV_BUTTONTEXT_IGNORE
 {
     Text [ en-US ] = "~Ignore";
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index 4e5e796..14d5363 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -34,6 +34,7 @@
 #include <brdwin.hxx>
 #include <window.h>
 
+#include <vcl/edit.hxx>
 #include <vcl/metric.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/wrkwin.hxx>
@@ -67,12 +68,12 @@ static void ImplInitMsgBoxImageList()
 
 void MessBox::ImplInitMessBoxData()
 {
-    mpFixedText         = NULL;
-    mpFixedImage        = NULL;
-    mnSoundType         = 0;
-    mbHelpBtn           = sal_False;
-    mpCheckBox          = NULL;
-    mbCheck             = sal_False;
+    mpFixedText          = NULL;
+    mpFixedImage         = NULL;
+    mnSoundType          = 0;
+    mbHelpBtn            = sal_False;
+    mpCheckBox           = NULL;
+    mbCheck              = sal_False;
 }
 
 // -----------------------------------------------------------------------
@@ -399,6 +400,10 @@ void MessBox::ImplPosControls()
         mpCheckBox->Show();
     }
 
+    AddButton( String( ResId( SV_BUTTONTEXT_COPY, *ImplGetResMgr() ) ), BUTTON_COPY, 0 );
+    Button* pCopyBtn = GetPushButton( BUTTON_COPY );
+    pCopyBtn->SetClickHdl( LINK( this, MessBox, ClickHdl ) );
+
     mpFixedText = new FixedText( this, nWinStyle );
     if( mpFixedText->GetStyle() & WB_EXTRAOFFSET ) // TODO: use CalcMinimumSize() instead
         aFixedSize.Width() += 2;
@@ -408,6 +413,15 @@ void MessBox::ImplPosControls()
     SetPageSizePixel( aPageSize );
 }
 
+IMPL_LINK( MessBox, ClickHdl, Button*, pBtn )
+{
+    Edit aCopyHelper( this );
+    aCopyHelper.SetText( maMessText, Selection( 0, maMessText.Len() ) );
+    aCopyHelper.Copy();
+
+    return 0;
+}
+
 // -----------------------------------------------------------------------
 
 void MessBox::StateChanged( StateChangedType nType )
-- 
1.7.7

_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to