sw/source/uibase/docvw/edtwin.cxx   |   69 +++++++++++++++++++-----------------
 sw/source/uibase/shells/textfld.cxx |    2 -
 2 files changed, 39 insertions(+), 32 deletions(-)

New commits:
commit db44d68191e0d10d0a6c24f18c6d013693acbfae
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Wed Mar 26 08:10:18 2025 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Mar 27 05:08:11 2025 +0100

    tdf#164318 Call copy field dialog on double click
    
    In read only documents a double click on a field executes the
    copy field dialog if the field contains text to be copied.
    
    Change-Id: I83042a95c4320f7fa94b04e53f880d0bc5af92a1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183346
    Tested-by: allotropia jenkins <jenk...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 60e4ac078ec7..536192b33375 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -3548,45 +3548,52 @@ void SwEditWin::MouseButtonDown(const MouseEvent& 
_rMEvt)
                         if ((!g_bValidCursorPos || rSh.IsFrameSelected()) && 
!comphelper::LibreOfficeKit::isActive())
                             return;
 
-                        SwField *pField;
+                        SwField *pField = rSh.GetCurField(true);
                         bool bFootnote = false;
 
-                        if( !bIsViewReadOnly &&
-                            (nullptr != (pField = rSh.GetCurField(true)) ||
-                              ( bFootnote = rSh.GetCurFootnote() )        ) )
+                        if( nullptr != pField ||
+                              ( bFootnote = rSh.GetCurFootnote() ))
                         {
-                            ResetMouseButtonDownFlags();
-                            if( bFootnote )
-                                
GetView().GetViewFrame().GetBindings().Execute( FN_EDIT_FOOTNOTE );
-                            else
+                            if (!bIsViewReadOnly)
                             {
-                                SwFieldTypesEnum nTypeId = pField->GetTypeId();
-                                SfxViewFrame& rVFrame = 
GetView().GetViewFrame();
-                                switch( nTypeId )
-                                {
-                                case SwFieldTypesEnum::Postit:
-                                case SwFieldTypesEnum::Script:
+                                ResetMouseButtonDownFlags();
+                                if( bFootnote )
+                                    
GetView().GetViewFrame().GetBindings().Execute( FN_EDIT_FOOTNOTE );
+                                else
                                 {
-                                    // if it's a Readonly region, status has 
to be enabled
-                                    sal_uInt16 nSlot = 
SwFieldTypesEnum::Postit == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
-                                    SfxBoolItem aItem(nSlot, true);
-                                    rVFrame.GetBindings().SetState(aItem);
-                                    rVFrame.GetBindings().Execute(nSlot);
-                                    break;
-                                }
-                                case SwFieldTypesEnum::Authority :
-                                    
rVFrame.GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
-                                break;
-                                case SwFieldTypesEnum::Input:
-                                case SwFieldTypesEnum::Dropdown:
-                                case SwFieldTypesEnum::SetInput:
-                                    
rVFrame.GetBindings().Execute(FN_UPDATE_INPUTFIELDS);
+                                    SwFieldTypesEnum nTypeId = 
pField->GetTypeId();
+                                    SfxViewFrame& rVFrame = 
GetView().GetViewFrame();
+                                    switch( nTypeId )
+                                    {
+                                    case SwFieldTypesEnum::Postit:
+                                    case SwFieldTypesEnum::Script:
+                                    {
+                                        // if it's a Readonly region, status 
has to be enabled
+                                        sal_uInt16 nSlot = 
SwFieldTypesEnum::Postit == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
+                                        SfxBoolItem aItem(nSlot, true);
+                                        rVFrame.GetBindings().SetState(aItem);
+                                        rVFrame.GetBindings().Execute(nSlot);
+                                        break;
+                                    }
+                                    case SwFieldTypesEnum::Authority :
+                                        
rVFrame.GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
                                     break;
-                                default:
-                                    
rVFrame.GetBindings().Execute(FN_EDIT_FIELD);
+                                    case SwFieldTypesEnum::Input:
+                                    case SwFieldTypesEnum::Dropdown:
+                                    case SwFieldTypesEnum::SetInput:
+                                        
rVFrame.GetBindings().Execute(FN_UPDATE_INPUTFIELDS);
+                                        break;
+                                    default:
+                                        
rVFrame.GetBindings().Execute(FN_EDIT_FIELD);
+                                    }
                                 }
+                                return;
+                            }
+                            else if (pField && pField->ExpandField(true, 
nullptr).getLength())
+                            {
+                                ResetMouseButtonDownFlags();
+                                
GetView().GetViewFrame().GetBindings().Execute(FN_COPY_FIELD);
                             }
-                            return;
                         }
                         // in extended mode double and triple
                         // click has no effect.
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index 90462903093f..cad6bd558d1a 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -182,7 +182,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
         {
             //call copy field dialog with field string - if there is any!
             SwField* pField = rSh.GetCurField(true);
-            if( pField && pField->GetFieldName().getLength())
+            if( pField && pField->ExpandField(true, nullptr).getLength())
             {
                 SwAbstractDialogFactory* pFact = 
SwAbstractDialogFactory::Create();
                 VclPtr<VclAbstractDialog> pDlg(pFact->CreateCopyFieldDlg(

Reply via email to