Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index



Hello!

I created a new class in cui/. : CopyableWarningBox (copywarnbox.hxx and
copywarnbox.cxx). This class gets instantiated in
cui/source/dialogs/scriptdlg.cxx (last method).

I couldn't manage to do the sizing dynamically, so it creates a fix (500*300)
dialog.

To test the dialog run ./soffice. Tools/Macros/Run Macro...
Expand LibreOffice Macros/Gimmicks/GetTexts and run GetCellTexts.

Szabolcs
                                          
From 1c0c3a082e65b1cab77dc6a86c3849b98b3b9f7a Mon Sep 17 00:00:00 2001
From: Szabolcs Dezsi <dezsiszabi@hotmail.com>
Date: Tue, 28 Feb 2012 19:40:14 +0100
Subject: [PATCH] Selectable text in error dialogs (when macros fail etc.)

---
 cui/Library_cui.mk                 |    1 +
 cui/source/dialogs/copywarnbox.cxx |   53 ++++++++++++++++++++++++++++++++++++
 cui/source/dialogs/scriptdlg.cxx   |   10 +++---
 cui/source/inc/copywarnbox.hxx     |   51 ++++++++++++++++++++++++++++++++++
 4 files changed, 110 insertions(+), 5 deletions(-)
 create mode 100644 cui/source/dialogs/copywarnbox.cxx
 create mode 100644 cui/source/inc/copywarnbox.hxx

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 516c68c..e17e009 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -93,6 +93,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
     cui/source/dialogs/about \
     cui/source/dialogs/colorpicker \
     cui/source/dialogs/commonlingui \
+    cui/source/dialogs/copywarnbox \
     cui/source/dialogs/cuicharmap \
     cui/source/dialogs/cuifmsearch \
     cui/source/dialogs/cuigaldlg \
diff --git a/cui/source/dialogs/copywarnbox.cxx b/cui/source/dialogs/copywarnbox.cxx
new file mode 100644
index 0000000..46e3525
--- /dev/null
+++ b/cui/source/dialogs/copywarnbox.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// include ---------------------------------------------------------------
+
+#include "copywarnbox.hxx"
+
+CopyableWarningBox::CopyableWarningBox( Window* pParent, const XubString& title, const XubString& 
rMessage ) :
+    SfxModalDialog  ( pParent,  0 ),
+    aMessage        ( this, WB_NOBORDER | WB_AUTOVSCROLL | WB_WORDBREAK ),
+    aOKButton       ( this, BUTTON_OK )
+{
+    SetText( title );
+
+    aMessage.SetPaintTransparent( sal_True );
+    aMessage.SetReadOnly();
+    aMessage.SetText( rMessage );
+    aMessage.SetPosPixel( Point( 10, 10 ) );
+    aMessage.SetSizePixel( Size( 500, 300 ) );
+
+    SetSizePixel( Size( aMessage.GetSizePixel().Width() + 20, aMessage.GetSizePixel().Height() + 
60 ) );
+    aOKButton.SetPosSizePixel( Point( (GetSizePixel().Width() / 2) - 25, 
aMessage.GetSizePixel().Height() + 10 ), Size( 50, 30 ) );
+
+    aMessage.Show();
+    aOKButton.Show();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index 0970951..2f37ddd 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -67,6 +67,8 @@
 #include <vector>
 #include <algorithm>
 
+#include "copywarnbox.hxx"
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::script;
@@ -1574,11 +1576,9 @@ IMPL_LINK( SvxScriptErrorDialog, ShowDialog, ::rtl::OUString*, pMessage )
         message = String( CUI_RES( RID_SVXSTR_ERROR_TITLE ) );
     }
 
-    MessBox* pBox = new WarningBox( NULL, WB_OK, message );
-    pBox->SetText( CUI_RES( RID_SVXSTR_ERROR_TITLE ) );
-    pBox->Execute();
-
-    delete pBox;
+    Dialog* pDlg = new CopyableWarningBox( NULL, CUI_RES( RID_SVXSTR_ERROR_TITLE ), message );
+    pDlg->Execute();
+    delete pDlg;
     delete pMessage;
 
     return 0;
diff --git a/cui/source/inc/copywarnbox.hxx b/cui/source/inc/copywarnbox.hxx
new file mode 100644
index 0000000..9ffc635
--- /dev/null
+++ b/cui/source/inc/copywarnbox.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COPYWARNBOX_HXX
+#define _COPYWARNBOX_HXX
+
+// include ---------------------------------------------------------------
+
+#include <vcl/button.hxx>
+#include <svtools/svmedit.hxx>
+#include <sfx2/basedlgs.hxx>
+
+// class CopyableWarningBox ----------------------------------------------
+
+class CopyableWarningBox : public SfxModalDialog
+{
+private:
+    MultiLineEdit       aMessage;
+    OKButton           aOKButton;
+
+public:
+  CopyableWarningBox( Window* pParent, const XubString& title, const XubString& rMessage );
+};
+
+#endif // #ifndef _COPYWARNBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.