sw/source/uibase/dochdl/swdtflvr.cxx |    9 +++++++--
 sw/source/uibase/docvw/edtdd.cxx     |    4 +---
 sw/source/uibase/inc/navicont.hxx    |    2 +-
 sw/source/uibase/utlui/content.cxx   |    4 +++-
 4 files changed, 12 insertions(+), 7 deletions(-)

New commits:
commit c6b404c39569b6bc972b821a13f6bba0a68d8d9d
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sun Jul 16 22:22:18 2023 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Sun Jul 23 06:48:13 2023 +0200

    tdf#156111 SwNavigator hyperlink dnd enhancement
    
    Enhancement to use the selected document text dropped on as the
    hyperlink name for hyperlinks created by drag-and-drop from the
    Navigator.
    
    Change-Id: I6c458b24574cae28ab390644b8a3e1982675c4c3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154508
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 201b7fa1b5d2..0974a424e921 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1724,7 +1724,12 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
     if( pPt )
     {
         // external Drop
-        if( bPasteSelection ? !pMod->m_pXSelection : !pMod->m_pDragDrop )
+        if ((bPasteSelection ? !pMod->m_pXSelection : !pMod->m_pDragDrop) &&
+                // The following condition is used for tdf#156111 to prevent a 
selection from being
+                // cleared by the default case of the nDestination switch.
+                !(rSh.GetCursorCnt() == 1 && rSh.TestCurrPam(*pPt) &&
+                nDestination == SotExchangeDest::SWDOC_FREE_AREA &&
+                nFormat == SotClipboardFormatId::SONLK))
         {
             switch( nDestination )
             {
@@ -1929,7 +1934,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
                 if( pPt )
                 {
                     NaviContentBookmark aBkmk;
-                    if( aBkmk.Paste( rData ) )
+                    if (aBkmk.Paste(rData, rSh.GetSelText()))
                     {
                         if(bIsDefault)
                         {
diff --git a/sw/source/uibase/docvw/edtdd.cxx b/sw/source/uibase/docvw/edtdd.cxx
index bf23cc24391e..287d2969f632 100644
--- a/sw/source/uibase/docvw/edtdd.cxx
+++ b/sw/source/uibase/docvw/edtdd.cxx
@@ -260,9 +260,7 @@ SotExchangeDest SwEditWin::GetDropDestination( const Point& 
rPixPnt, SdrObject *
 {
     SwWrtShell &rSh = m_rView.GetWrtShell();
     const Point aDocPt( PixelToLogic( rPixPnt ) );
-    if( rSh.TestCurrPam( aDocPt )
-        || rSh.IsOverReadOnlyPos( aDocPt )
-        || rSh.DocPtInsideInputField( aDocPt ) )
+    if (rSh.IsOverReadOnlyPos(aDocPt) || rSh.DocPtInsideInputField(aDocPt))
         return SotExchangeDest::NONE;
 
     SdrObject *pObj = nullptr;
diff --git a/sw/source/uibase/inc/navicont.hxx 
b/sw/source/uibase/inc/navicont.hxx
index f8c81ae3dcef..604c1c982c76 100644
--- a/sw/source/uibase/inc/navicont.hxx
+++ b/sw/source/uibase/inc/navicont.hxx
@@ -48,7 +48,7 @@ public:
     const OUString& GetDescription() const      { return m_aDescription; }
     RegionMode      GetDefaultDragType() const  { return m_nDefaultDrag; }
     void            Copy( TransferDataContainer& rData ) const;
-    bool            Paste( const TransferableDataHelper& rData );
+    bool            Paste( const TransferableDataHelper& rData, const 
OUString& rsDesc );
 };
 
 #endif
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index c2af6a16304d..a57df3fd0630 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -5553,7 +5553,7 @@ void NaviContentBookmark::Copy( TransferDataContainer& 
rData ) const
     rData.CopyByteString(SotClipboardFormatId::SONLK, sStrBuf);
 }
 
-bool NaviContentBookmark::Paste( const TransferableDataHelper& rData )
+bool NaviContentBookmark::Paste( const TransferableDataHelper& rData, const 
OUString& rsDesc )
 {
     OUString sStr;
     bool bRet = rData.GetString( SotClipboardFormatId::SONLK, sStr );
@@ -5564,6 +5564,8 @@ bool NaviContentBookmark::Paste( const 
TransferableDataHelper& rData )
         m_aDescription  = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
         m_nDefaultDrag= static_cast<RegionMode>( 
o3tl::toInt32(o3tl::getToken(sStr, 0, NAVI_BOOKMARK_DELIM, nPos )) );
         m_nDocSh  = o3tl::toInt32(o3tl::getToken(sStr, 0, NAVI_BOOKMARK_DELIM, 
nPos ));
+        if (!rsDesc.isEmpty())
+            m_aDescription = rsDesc;
     }
     return bRet;
 }

Reply via email to