[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - dbaccess/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 14 10:18:30 UTC 2019


 dbaccess/source/ui/control/FieldDescControl.cxx |   37 ++++++++++++++----------
 dbaccess/source/ui/inc/FieldDescControl.hxx     |    2 +
 2 files changed, 24 insertions(+), 15 deletions(-)

New commits:
commit e840a7d5707c598378a4ff0a47bd6fc31e85b7e0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Nov 14 09:22:09 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Nov 14 11:17:44 2019 +0100

    Resolves: tdf#128788 crash in autovalue
    
    Change-Id: Ifeb3b3fcb464e1d6db7e1a4a557b34b3ee30c82a
    Reviewed-on: https://gerrit.libreoffice.org/82653
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
index 222cfe3808f9..5d9d90834dbb 100644
--- a/dbaccess/source/ui/control/FieldDescControl.cxx
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -1197,14 +1197,29 @@ void OFieldDescControl::LoseFocus()
     TabPage::LoseFocus();
 }
 
+bool OFieldDescControl::IsFocusInEditableWidget() const
+{
+    if (m_xDefault && m_pActFocusWindow == m_xDefault->GetWidget())
+        return true;
+    if (m_xFormatSample && m_pActFocusWindow == m_xFormatSample->GetWidget())
+        return true;
+    if (m_xTextLen && m_pActFocusWindow == m_xTextLen->GetWidget())
+        return true;
+    if (m_xLength && m_pActFocusWindow == m_xLength->GetWidget())
+        return true;
+    if (m_xScale && m_pActFocusWindow == m_xScale->GetWidget())
+        return true;
+    if (m_xColumnName && m_pActFocusWindow == m_xColumnName->GetWidget())
+        return true;
+    if (m_xAutoIncrementValue && m_pActFocusWindow == m_xAutoIncrementValue->GetWidget())
+        return true;
+    return false;
+}
+
 bool OFieldDescControl::isCopyAllowed() const
 {
     int nStartPos, nEndPos;
-    bool bAllowed = (m_pActFocusWindow != nullptr) &&
-                        (m_pActFocusWindow == m_xDefault->GetWidget() || m_pActFocusWindow == m_xFormatSample->GetWidget() ||
-                        m_pActFocusWindow == m_xTextLen->GetWidget() || m_pActFocusWindow == m_xLength->GetWidget() ||
-                        m_pActFocusWindow == m_xScale->GetWidget() || m_pActFocusWindow == m_xColumnName->GetWidget() ||
-                        m_pActFocusWindow == m_xAutoIncrementValue->GetWidget()) &&
+    bool bAllowed = (m_pActFocusWindow != nullptr) && IsFocusInEditableWidget() &&
                         dynamic_cast<weld::Entry&>(*m_pActFocusWindow).get_selection_bounds(nStartPos, nEndPos);
     return bAllowed;
 }
@@ -1212,22 +1227,14 @@ bool OFieldDescControl::isCopyAllowed() const
 bool OFieldDescControl::isCutAllowed() const
 {
     int nStartPos, nEndPos;
-    bool bAllowed = (m_pActFocusWindow != nullptr) &&
-                        (m_pActFocusWindow == m_xDefault->GetWidget() || m_pActFocusWindow == m_xFormatSample->GetWidget() ||
-                        m_pActFocusWindow == m_xTextLen->GetWidget() || m_pActFocusWindow == m_xLength->GetWidget() ||
-                        m_pActFocusWindow == m_xScale->GetWidget() || m_pActFocusWindow == m_xColumnName->GetWidget() ||
-                        m_pActFocusWindow == m_xAutoIncrementValue->GetWidget()) &&
+    bool bAllowed = (m_pActFocusWindow != nullptr) && IsFocusInEditableWidget() &&
                         dynamic_cast<weld::Entry&>(*m_pActFocusWindow).get_selection_bounds(nStartPos, nEndPos);
     return bAllowed;
 }
 
 bool OFieldDescControl::isPasteAllowed() const
 {
-    bool bAllowed = (m_pActFocusWindow != nullptr) &&
-                        (m_pActFocusWindow == m_xDefault->GetWidget() || m_pActFocusWindow == m_xFormatSample->GetWidget() ||
-                        m_pActFocusWindow == m_xTextLen->GetWidget() || m_pActFocusWindow == m_xLength->GetWidget() ||
-                        m_pActFocusWindow == m_xScale->GetWidget() || m_pActFocusWindow == m_xColumnName->GetWidget() ||
-                        m_pActFocusWindow == m_xAutoIncrementValue->GetWidget());
+    bool bAllowed = (m_pActFocusWindow != nullptr) && IsFocusInEditableWidget();
     if ( bAllowed )
     {
         TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx
index 5c9e17215529..24cdedc7da27 100644
--- a/dbaccess/source/ui/inc/FieldDescControl.hxx
+++ b/dbaccess/source/ui/inc/FieldDescControl.hxx
@@ -128,6 +128,8 @@ namespace dbaui
         void                InitializeControl(weld::Widget* _pControl,const OString& _sHelpId);
         void                InitializeControl(OPropListBoxCtrl* _pControl,const OString& _sHelpId,bool _bAddChangeHandler);
 
+        bool                IsFocusInEditableWidget() const;
+
     protected:
         void                saveCurrentFieldDescData() { SaveData( pActFieldDescr ); }
         OFieldDescription*  getCurrentFieldDescData() { return pActFieldDescr; }


More information about the Libreoffice-commits mailing list