sw/UIConfig_swriter.mk                            |    1 
 sw/inc/bitmaps.hlst                               |    2 
 sw/inc/strings.hrc                                |    6 
 sw/source/uibase/dochdl/swdtflvr.cxx              |   18 -
 sw/source/uibase/inc/conttree.hxx                 |    3 
 sw/source/uibase/inc/navicfg.hxx                  |   10 
 sw/source/uibase/inc/navicont.hxx                 |   12 -
 sw/source/uibase/inc/navipi.hxx                   |    8 
 sw/source/uibase/inc/swcont.hxx                   |   10 
 sw/source/uibase/inc/wrtsh.hxx                    |    3 
 sw/source/uibase/utlui/content.cxx                |  254 ++++++++++++----------
 sw/source/uibase/utlui/navicfg.cxx                |   42 +--
 sw/source/uibase/utlui/navipi.cxx                 |   61 -----
 sw/source/uibase/wrtsh/wrtsh2.cxx                 |  208 +++++++++++++++++-
 sw/uiconfig/swriter/ui/navigatorcontextmenu.ui    |   14 -
 sw/uiconfig/swriter/ui/navigatordraginsertmenu.ui |    9 
 sw/uiconfig/swriter/ui/navigatorpanel.ui          |   61 -----
 17 files changed, 388 insertions(+), 334 deletions(-)

New commits:
commit 95d1e7f0873a2bbb9ab4b0aa171fec29d36c3f55
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Thu Dec 28 15:13:52 2023 -0900
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Sun Jan 28 21:46:57 2024 +0100

    tdf#36310 Insert cross reference from Navigator by DnD
    
    This enhancement provides the ability to insert cross-references by
    drag and drop from the Navigator. It replaces the 'drag mode' way of
    inserting a hyperlink, section link, and section copy with a popup
    menu on drop that shows insert-as kinds available for the dragged
    content type.
    
    There is an oddity with X11 that on drop the mouse pointer does not
    change from a drag pointer to a menu item select pointer for
    approximately 5 seconds and during that time the popup menu items
    can't be selected.
    
    Change-Id: Id72cbdbd81106fc0e70784fcba7f1dd3a43ad81e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161575
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index a371b4928ea5..43ab167dd197 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -243,6 +243,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
        sw/uiconfig/swriter/ui/mmsendmails \
        sw/uiconfig/swriter/ui/mmsalutationpage \
        sw/uiconfig/swriter/ui/navigatorcontextmenu \
+       sw/uiconfig/swriter/ui/navigatordraginsertmenu \
        sw/uiconfig/swriter/ui/navigatorpanel \
        sw/uiconfig/swriter/ui/notebookbar \
        sw/uiconfig/swriter/ui/notebookbar_compact \
diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst
index b1f30b0932f1..80ab4eb3b17a 100644
--- a/sw/inc/bitmaps.hlst
+++ b/sw/inc/bitmaps.hlst
@@ -97,8 +97,6 @@ inline constexpr OUString RID_BMP_NAVI_TEXTFIELD = 
u"sw/res/nc20005.png"_ustr;
 inline constexpr OUString RID_BMP_NAVI_FOOTNOTE = u"sw/res/nc20012.png"_ustr;
 inline constexpr OUString RID_BMP_NAVI_ENDNOTE = u"sw/res/nc20013.png"_ustr;
 inline constexpr OUString RID_BMP_DROP_REGION = u"sw/res/sc20235.png"_ustr;
-inline constexpr OUString RID_BMP_DROP_LINK = u"sw/res/sc20238.png"_ustr;
-inline constexpr OUString RID_BMP_DROP_COPY = u"sw/res/sc20239.png"_ustr;
 
 inline constexpr OUString RID_BMP_WRAP_RIGHT = u"sw/res/wr03.png"_ustr;
 inline constexpr OUString RID_BMP_WRAP_CONTOUR_RIGHT = u"sw/res/wr09.png"_ustr;
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 2986e03b9a85..9e0cf978aa3b 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -421,6 +421,9 @@
 #define STR_HIDDEN_CHANGES_DETAIL3              
NC_("STR_HIDDEN_CHANGES_DETAIL3", "Document contains tracked changes.")
 #define STR_FLDREF_FOOTNOTE                     NC_("STR_FLDREF_FOOTNOTE", 
"Footnote")
 #define STR_FLDREF_ENDNOTE                      NC_("STR_FLDREF_ENDNOTE", 
"Endnote")
+#define STR_HYPERLINK                           NC_("STR_HYPERLINK", 
"Hyperlink")
+#define STR_SECTIONLINK                         NC_("STR_SECTIONLINK", 
"Section Link")
+#define STR_SECTIONCOPY                         NC_("STR_SECTIONCOPY", 
"Section Copy")
 
 // Undo
 #define STR_CANT_UNDO                           NC_("STR_CANT_UNDO", "not 
possible")
@@ -699,9 +702,6 @@
 
 #define STR_EXPANDALL                           NC_("STR_EXPANDALL", "Expand 
All")
 #define STR_COLLAPSEALL                         NC_("STR_COLLAPSEALL", 
"Collapse All")
-#define STR_HYPERLINK                           NC_("STR_HYPERLINK", "Insert 
as Hyperlink")
-#define STR_LINK_REGION                         NC_("STR_LINK_REGION", "Insert 
as Link")
-#define STR_COPY_REGION                         NC_("STR_COPY_REGION", "Insert 
as Copy")
 #define STR_DISPLAY                             NC_("STR_DISPLAY", "Display")
 #define STR_ACTIVE_VIEW                         NC_("STR_ACTIVE_VIEW", "Active 
Window")
 #define STR_HIDDEN                              NC_("STR_HIDDEN", "hidden")
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 15a225e1997c..0a6d9f5cadba 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1692,7 +1692,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
                             SwWrtShell& rSh, sal_uInt8 nAction, 
SotExchangeActionFlags nActionFlags,
                             SotClipboardFormatId nFormat,
                             SotExchangeDest nDestination, bool bIsPasteFormat,
-                            bool bIsDefault,
+                            [[maybe_unused]] bool bIsDefault,
                             const Point* pPt, sal_Int8 nDropAction,
                             bool bPasteSelection, RndStdIds nAnchorType,
                             bool bIgnoreComments,
@@ -1731,7 +1731,11 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
                 break;
 
             default:
+                bool bLockView = rSh.IsViewLocked();
+                if (nFormat == SotClipboardFormatId::SONLK)
+                    rSh.LockView(true); // prevent view jump
                 SwTransferable::SetSelInShell( rSh, false, pPt );
+                rSh.LockView(bLockView);
                 break;
             }
         }
@@ -1921,16 +1925,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
                     NaviContentBookmark aBkmk;
                     if (aBkmk.Paste(rData, rSh.GetSelText()))
                     {
-                        if(bIsDefault)
-                        {
-                            switch(aBkmk.GetDefaultDragType())
-                            {
-                                case RegionMode::NONE: nAction = 
EXCHG_IN_ACTION_COPY; break;
-                                case RegionMode::EMBEDDED: nAction = 
EXCHG_IN_ACTION_MOVE; break;
-                                case RegionMode::LINK: nAction = 
EXCHG_IN_ACTION_LINK; break;
-                            }
-                        }
-                        rSh.NavigatorPaste( aBkmk, nAction );
+                        aWait.~SwWait(); // end the wait pointer, X11 only 
annoyance
+                        rSh.NavigatorPaste(aBkmk);
                         bRet = true;
                     }
                 }
diff --git a/sw/source/uibase/inc/conttree.hxx 
b/sw/source/uibase/inc/conttree.hxx
index b693a7da97a4..9a67d986f55f 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -172,8 +172,7 @@ class SwContentTree final : public SfxListener
 
     SwNavigationPI* GetParentWindow();
 
-    bool        FillTransferData( TransferDataContainer& rTransfer,
-                                            sal_Int8& rDragMode );
+    bool FillTransferData(TransferDataContainer& rTransfer);
 
     /** Check if the displayed content is valid. */
     bool            HasContentChanged();
diff --git a/sw/source/uibase/inc/navicfg.hxx b/sw/source/uibase/inc/navicfg.hxx
index b39614f9f63f..ac1c6299c838 100644
--- a/sw/source/uibase/inc/navicfg.hxx
+++ b/sw/source/uibase/inc/navicfg.hxx
@@ -28,7 +28,6 @@ class SwNavigationConfig final : public utl::ConfigItem
     ContentTypeId  m_nRootType;      //RootType
     sal_Int32      m_nSelectedPos;   //SelectedPosition
     sal_Int32      m_nOutlineLevel;  //OutlineLevel
-    RegionMode     m_nRegionMode;    //InsertMode
     sal_Int32      m_nActiveBlock;   //ActiveBlock//Expand/CollapsState
     bool           m_bIsSmall;       //ShowListBox
     bool           m_bIsGlobalActive; //GlobalDocMode// global view for 
GlobalDoc valid?
@@ -68,15 +67,6 @@ public:
                         }
                     }
 
-    RegionMode  GetRegionMode()const {return m_nRegionMode;}
-    void        SetRegionMode(RegionMode nSet){
-                    if(m_nRegionMode != nSet)
-                    {
-                        SetModified();
-                        m_nRegionMode = nSet;
-                    }
-                }
-
     sal_Int32   GetActiveBlock()const {return m_nActiveBlock;}
     void        SetActiveBlock(sal_Int32 nSet){
                         if(m_nActiveBlock != nSet)
diff --git a/sw/source/uibase/inc/navicont.hxx 
b/sw/source/uibase/inc/navicont.hxx
index 604c1c982c76..03cf763fc2f8 100644
--- a/sw/source/uibase/inc/navicont.hxx
+++ b/sw/source/uibase/inc/navicont.hxx
@@ -26,7 +26,6 @@
 class SwDocShell;
 class TransferDataContainer;
 class TransferableDataHelper;
-enum class RegionMode;
 
 /*
     navigator bookmark for distinct identification in Sw
@@ -34,19 +33,18 @@ enum class RegionMode;
 
 class NaviContentBookmark
 {
-    OUString        m_aUrl;       // URL including jump mark
+    OUString m_sURL; // URL including jump mark
+    OUString m_sCrossRef; // cross-reference
     OUString        m_aDescription;     // description
     tools::Long            m_nDocSh;     // address of DocShell
-    RegionMode      m_nDefaultDrag;   // description contains defaultDragType
 
 public:
     NaviContentBookmark();
-    NaviContentBookmark( OUString aUrl, OUString aDesc,
-                            RegionMode nDragType, const SwDocShell* );
+    NaviContentBookmark(OUString sURL, OUString sCrossRef, OUString aDesc, 
const SwDocShell*);
 
-    const OUString& GetURL() const              { return m_aUrl; }
+    const OUString& GetURL() const { return m_sURL; }
+    const OUString& GetCrossRef() const { return m_sCrossRef; }
     const OUString& GetDescription() const      { return m_aDescription; }
-    RegionMode      GetDefaultDragType() const  { return m_nDefaultDrag; }
     void            Copy( TransferDataContainer& rData ) const;
     bool            Paste( const TransferableDataHelper& rData, const 
OUString& rsDesc );
 };
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index 1d899f15acc5..b47b17e13bc7 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -37,7 +37,6 @@ class SwWrtShell;
 class SfxBindings;
 class SwNavigationConfig;
 class SwView;
-enum class RegionMode;
 class SpinField;
 
 class SwNavigationPI final : public PanelLayout
@@ -60,7 +59,6 @@ class SwNavigationPI final : public PanelLayout
     std::unique_ptr<ToolbarUnoDispatcher> m_xContent2Dispatch;
     std::unique_ptr<ToolbarUnoDispatcher> m_xContent3Dispatch;
     std::unique_ptr<weld::Menu> m_xHeadingsMenu;
-    std::unique_ptr<weld::Menu> m_xDragModeMenu;
     std::unique_ptr<weld::Menu> m_xUpdateMenu;
     std::unique_ptr<weld::Menu> m_xInsertMenu;
     std::unique_ptr<weld::Toolbar> m_xGlobalToolBox;
@@ -84,7 +82,6 @@ class SwNavigationPI final : public PanelLayout
     SwNavigationConfig  *m_pConfig;
     SfxBindings         &m_rBindings;
 
-    RegionMode  m_nRegionMode; // 0 - URL, 1 - region with link 2 - region 
without link
     Size        m_aExpandedSize;
 
     bool    m_bIsZoomedIn : 1;
@@ -102,9 +99,7 @@ class SwNavigationPI final : public PanelLayout
     DECL_LINK( ToolBoxSelectHdl, const OUString&, void );
     DECL_LINK( ToolBoxClickHdl, const OUString&, void );
     DECL_LINK( ToolBox5DropdownClickHdl, const OUString&, void );
-    DECL_LINK( ToolBox6DropdownClickHdl, const OUString&, void );
     DECL_LINK( DoneLink, SfxPoolItem const *, void );
-    DECL_LINK( DropModeMenuSelectHdl, const OUString&, void );
     DECL_LINK( HeadingsMenuSelectHdl, const OUString&, void );
     DECL_LINK( GlobalMenuSelectHdl, const OUString&, void );
     DECL_LINK( ChangePageHdl, Timer*, void );
@@ -150,9 +145,6 @@ public:
     static OUString CreateDropFileName( const TransferableDataHelper& rData );
     static OUString CleanEntry(const OUString& rEntry);
 
-    RegionMode      GetRegionDropMode() const {return m_nRegionMode;}
-    void            SetRegionDropMode(RegionMode nNewMode);
-
     sal_Int8        AcceptDrop();
     sal_Int8        ExecuteDrop( const ExecuteDropEvent& rEvt );
 
diff --git a/sw/source/uibase/inc/swcont.hxx b/sw/source/uibase/inc/swcont.hxx
index b29489f098c3..57908b106834 100644
--- a/sw/source/uibase/inc/swcont.hxx
+++ b/sw/source/uibase/inc/swcont.hxx
@@ -48,17 +48,9 @@ enum class ContentTypeId
 };
 
 // strings for context menus
-#define CONTEXT_COUNT   17
+#define CONTEXT_COUNT 13
 #define GLOBAL_CONTEXT_COUNT 14
 
-// modes for Drag 'n Drop
-enum class RegionMode
-{
-    NONE        = 0,
-    LINK        = 1,
-    EMBEDDED    = 2
-};
-
 //mini rtti
 class SwTypeNumber
 {
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 44a17f96a6ad..8ef98c792324 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -461,8 +461,7 @@ typedef bool (SwWrtShell::*FNSimpleMove)();
     // if a URL-Button is selected, return its URL; otherwise an empty string
     bool GetURLFromButton( OUString& rURL, OUString& rDescr ) const;
 
-    void NavigatorPaste( const NaviContentBookmark& rBkmk,
-                         const sal_uInt16 nAction );
+    void NavigatorPaste(const NaviContentBookmark& rBkmk);
 
     virtual void ApplyViewOptions( const SwViewOption &rOpt ) override;
     virtual void SetReadonlyOption( bool bSet ) override;
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 86e94f754841..2c5cb7f406eb 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -123,6 +123,8 @@
 
 #include <svl/fstathelper.hxx>
 
+#include <expfld.hxx>
+
 #define CTYPE_CNT   0
 #define CTYPE_CTT   1
 
@@ -1058,22 +1060,18 @@ namespace {
 enum STR_CONTEXT_IDX
 {
     IDX_STR_OUTLINE_LEVEL = 0,
-    IDX_STR_DRAGMODE = 1,
-    IDX_STR_HYPERLINK = 2,
-    IDX_STR_LINK_REGION = 3,
-    IDX_STR_COPY_REGION = 4,
-    IDX_STR_DISPLAY = 5,
-    IDX_STR_ACTIVE_VIEW = 6,
-    IDX_STR_HIDDEN = 7,
-    IDX_STR_ACTIVE = 8,
-    IDX_STR_INACTIVE = 9,
-    IDX_STR_EDIT_ENTRY = 10,
-    IDX_STR_DELETE_ENTRY = 11,
-    IDX_STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY = 12,
-    IDX_STR_OUTLINE_TRACKING = 13,
-    IDX_STR_OUTLINE_TRACKING_DEFAULT = 14,
-    IDX_STR_OUTLINE_TRACKING_FOCUS = 15,
-    IDX_STR_OUTLINE_TRACKING_OFF = 16
+    IDX_STR_DISPLAY = 1,
+    IDX_STR_ACTIVE_VIEW = 2,
+    IDX_STR_HIDDEN = 3,
+    IDX_STR_ACTIVE = 4,
+    IDX_STR_INACTIVE = 5,
+    IDX_STR_EDIT_ENTRY = 6,
+    IDX_STR_DELETE_ENTRY = 7,
+    IDX_STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY = 8,
+    IDX_STR_OUTLINE_TRACKING = 9,
+    IDX_STR_OUTLINE_TRACKING_DEFAULT = 10,
+    IDX_STR_OUTLINE_TRACKING_FOCUS = 11,
+    IDX_STR_OUTLINE_TRACKING_OFF = 12
 };
 
 }
@@ -1081,10 +1079,6 @@ enum STR_CONTEXT_IDX
 const TranslateId STR_CONTEXT_ARY[] =
 {
     STR_OUTLINE_LEVEL,
-    STR_DRAGMODE,
-    STR_HYPERLINK,
-    STR_LINK_REGION,
-    STR_COPY_REGION,
     STR_DISPLAY,
     STR_ACTIVE_VIEW,
     STR_HIDDEN,
@@ -1238,12 +1232,6 @@ IMPL_LINK(SwContentTree, DragBeginHdl, bool&, 
rUnsetDragIcon, bool)
         return true; // disallow
     }
 
-    rtl::Reference<TransferDataContainer> xContainer = new 
TransferDataContainer;
-    sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
-
-    if (FillTransferData(*xContainer, nDragMode))
-        bDisallow = false;
-
     if (m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE)
     {
         // Only move drag entry and continuous selected siblings:
@@ -1267,11 +1255,16 @@ IMPL_LINK(SwContentTree, DragBeginHdl, bool&, 
rUnsetDragIcon, bool)
             
m_aDndOutlinesSelected.push_back(m_xTreeView->make_iterator(xEntry.get()));
         }
         while (m_xTreeView->iter_next_sibling(*xEntry) && 
m_xTreeView->is_selected(*xEntry));
+    }
+
+    rtl::Reference<TransferDataContainer> xContainer = new 
TransferDataContainer;
+
+    if (FillTransferData(*xContainer))
+    {
         bDisallow = false;
+        m_xTreeView->enable_drag_source(xContainer, DND_ACTION_COPY);
     }
 
-    if (!bDisallow)
-        m_xTreeView->enable_drag_source(xContainer, nDragMode);
     return bDisallow;
 }
 
@@ -1638,15 +1631,6 @@ IMPL_LINK(SwContentTree, CommandHdl, const 
CommandEvent&, rCEvt, bool)
     }
     xSubPop1->set_active(OUString::number(100 + m_nOutlineLevel), true);
 
-    // Add entries to the Drag Mode submenu
-    for (int i=0; i < 3; ++i)
-    {
-        sId = OUString::number(i + 201);
-        xSubPop2->append_radio(sId, m_aContextStrings[IDX_STR_HYPERLINK + i]);
-        xSubPop2->set_item_help_id(sId, HID_NAV_DRAG_MODE);
-    }
-    xSubPop2->set_active(OUString::number(201 + 
static_cast<int>(GetParentWindow()->GetRegionDropMode())), true);
-
     // Insert the list of the open files in the Display submenu
     {
     sal_uInt16 nId = 301;
@@ -3033,10 +3017,8 @@ void SwContentTree::clear()
     m_xTreeView->thaw();
 }
 
-bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer,
-                                            sal_Int8& rDragMode )
+bool SwContentTree::FillTransferData(TransferDataContainer& rTransfer)
 {
-    bool bRet = false;
     SwWrtShell* pWrtShell = GetWrtShell();
     OSL_ENSURE(pWrtShell, "no Shell!");
 
@@ -3044,15 +3026,18 @@ bool SwContentTree::FillTransferData( 
TransferDataContainer& rTransfer,
     bool bEntry = m_xTreeView->get_cursor(xEntry.get());
     if (!bEntry || lcl_IsContentType(*xEntry, *m_xTreeView) || !pWrtShell)
         return false;
-    OUString sEntry;
     
assert(dynamic_cast<SwContent*>(weld::fromId<SwTypeNumber*>(m_xTreeView->get_id(*xEntry))));
     SwContent* pCnt = weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry));
 
-    const ContentTypeId nActType = pCnt->GetParent()->GetType();
+    OUString sEntry;
     OUString sUrl;
-    bool bOutline = false;
+    OUString sCrossRef;
+    bool bUrl = true;
+    bool bCrossRef = true;
     OUString sOutlineText;
-    switch( nActType )
+
+    const ContentTypeId eActType = pCnt->GetParent()->GetType();
+    switch (eActType)
     {
         case ContentTypeId::OUTLINE:
         {
@@ -3081,62 +3066,67 @@ bool SwContentTree::FillTransferData( 
TransferDataContainer& rTransfer,
                 sEntry += 
pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, 
pWrtShell->GetLayout(), false);
                 sOutlineText = 
pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, 
pWrtShell->GetLayout());
                 m_bIsOutlineMoveable = 
static_cast<SwOutlineContent*>(pCnt)->IsMoveable();
-                bOutline = true;
             }
         }
         break;
+        case ContentTypeId::BOOKMARK:
+            sEntry = m_xTreeView->get_text(*xEntry);
+        break;
+        case ContentTypeId::TABLE:
+        case ContentTypeId::FRAME:
+        case ContentTypeId::REGION:
+            bCrossRef = false;
+            sEntry = m_xTreeView->get_text(*xEntry);
+        break;
+        // content types that cannot be inserted, as URL, section, or reference
         case ContentTypeId::POSTIT:
         case ContentTypeId::INDEX:
-        case ContentTypeId::REFERENCE :
+            return false;
+        // content types than can only be inserted as a cross-reference
+        case ContentTypeId::REFERENCE:
         case ContentTypeId::TEXTFIELD:
         case ContentTypeId::FOOTNOTE:
         case ContentTypeId::ENDNOTE:
-            // cannot be inserted, neither as URL nor as section
+            bUrl = false;
+            sEntry = m_xTreeView->get_text(*xEntry);
         break;
+        // content types tha can only be inserted as a hyperlink
         case ContentTypeId::URLFIELD:
             sUrl = static_cast<SwURLFieldContent*>(pCnt)->GetURL();
             [[fallthrough]];
         case ContentTypeId::OLE:
         case ContentTypeId::GRAPHIC:
-            if(GetParentWindow()->GetRegionDropMode() != RegionMode::NONE)
-                break;
-            else
-                rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
-            [[fallthrough]];
-        default:
+        case ContentTypeId::DRAWOBJECT:
+            bCrossRef = false;
             sEntry = m_xTreeView->get_text(*xEntry);
+        break;
+        default:
+            return false;
     }
 
     if(!sEntry.isEmpty())
     {
         const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
-        if(sUrl.isEmpty())
+        if (bUrl && sUrl.isEmpty())
         {
             if(pDocShell->HasName())
             {
                 SfxMedium* pMedium = pDocShell->GetMedium();
                 sUrl = pMedium->GetURLObject().GetURLNoMark();
-                // only if a primarily link shall be integrated.
-                bRet = true;
             }
-            else if ( nActType == ContentTypeId::REGION || nActType == 
ContentTypeId::BOOKMARK )
-            {
-                // For field and bookmarks a link is also allowed
-                // without a filename into its own document.
-                bRet = true;
-            }
-            else if (State::CONSTANT == m_eState &&
-                    ( !::GetActiveView() ||
-                        m_pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
+            else if (State::CONSTANT == m_eState
+                     && (!::GetActiveView()
+                         || m_pActiveShell != 
::GetActiveView()->GetWrtShellPtr()))
             {
                 // Urls of inactive views cannot dragged without
                 // file names, also.
-                bRet = false;
+                return false;
             }
-            else
+            else if (eActType != ContentTypeId::REGION && eActType != 
ContentTypeId::BOOKMARK)
             {
-                bRet = GetParentWindow()->GetRegionDropMode() == 
RegionMode::NONE;
-                rDragMode = DND_ACTION_MOVE;
+                // For sections and bookmarks a link is also allowed
+                // without a filename into its own document.
+                return false;
             }
 
             const OUString& rToken = pCnt->GetParent()->GetTypeToken();
@@ -3146,32 +3136,93 @@ bool SwContentTree::FillTransferData( 
TransferDataContainer& rTransfer,
                 sUrl += OUStringChar(cMarkSeparator) + rToken;
             }
         }
-        else
-            bRet = true;
 
-        if( bRet )
+        if (bCrossRef)
         {
-            // In Outlines of heading text must match
-            // the real number into the description.
-            if(bOutline)
-                sEntry = sOutlineText;
+            if (eActType == ContentTypeId::TEXTFIELD)
+            {
+                SwTextFieldContent* pTextFieldContent = 
static_cast<SwTextFieldContent*>(pCnt);
+                const SwFormatField* pFormatField = 
pTextFieldContent->GetFormatField();
+                const SwField* pField = pFormatField->GetField();
 
+                if (SwFieldTypesEnum::Sequence != pField->GetTypeId())
+                    return false;
+
+                OUString sVal = pField->ExpandField(true, 
m_pActiveShell->GetLayout());
+                sal_uInt32 nSeqNo = sVal.toUInt32();
+                if (nSeqNo > 0)
+                {
+                    --nSeqNo;
+                    sVal = OUString::number(nSeqNo);
+                }
+                else
+                    return false;
+
+                const OUString& rsFieldTypeName = pField->GetTyp()->GetName();
+                sCrossRef = 
OUString::number(static_cast<int>(REFERENCESUBTYPE::REF_SEQUENCEFLD))
+                        + u"|" + rsFieldTypeName + u"|" + sVal;
+            }
+            else if (eActType == ContentTypeId::REFERENCE)
             {
-                NaviContentBookmark aBmk( sUrl, sEntry,
-                                    GetParentWindow()->GetRegionDropMode(),
-                                    pDocShell);
-                aBmk.Copy( rTransfer );
+                sCrossRef = 
OUString::number(static_cast<int>(REFERENCESUBTYPE::REF_SETREFATTR))
+                        + u"|" + sEntry;
             }
+            else if (eActType == ContentTypeId::BOOKMARK)
+            {
+                sCrossRef = 
OUString::number(static_cast<int>(REFERENCESUBTYPE::REF_BOOKMARK))
+                        + u"|" + sEntry;
+            }
+            else if (eActType == ContentTypeId::FOOTNOTE || eActType == 
ContentTypeId::ENDNOTE)
+            {
+                SeqFieldLstElem aElem(sEntry, 0);
+                SwSeqFieldList aArr;
+                size_t nIdx = 0;
+                OUString sVal;
+
+                if (m_pActiveShell->GetSeqFootnoteList(aArr, eActType == 
ContentTypeId::ENDNOTE)
+                        && aArr.SeekEntry(aElem, &nIdx))
+                    sVal = OUString::number(aArr[nIdx].nSeqNo);
+                else
+                    return false;
 
-            // An INetBookmark must a be delivered to foreign DocShells
-            if( pDocShell->HasName() )
+                REFERENCESUBTYPE eReferenceSubType =
+                        eActType == ContentTypeId::FOOTNOTE ? 
REFERENCESUBTYPE::REF_FOOTNOTE :
+                                                              
REFERENCESUBTYPE::REF_ENDNOTE;
+
+                sCrossRef = 
OUString::number(static_cast<int>(eReferenceSubType)) + u"|"
+                        + sEntry + u"|" + sVal;
+            }
+            else if (eActType == ContentTypeId::OUTLINE)
             {
-                INetBookmark aBkmk( sUrl, sEntry );
-                rTransfer.CopyINetBookmark( aBkmk );
+                sEntry = sOutlineText;
+                const SwOutlineNodes::size_type nPos =
+                        static_cast<SwOutlineContent*>(pCnt)->GetOutlinePos();
+                const SwTextNode* pTextNode =
+                        
pWrtShell->GetNodes().GetOutLineNds()[nPos]->GetTextNode();
+                sw::mark::IMark const * const pMark =
+                        
pWrtShell->getIDocumentMarkAccess()->getMarkForTextNode(
+                            *pTextNode, 
IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK);
+                // REFERENCESUBTYPE_OUTLINE is changed to 
REFERENCESUBTYPE::BOOKMARK in
+                // SwWrtShell::NavigatorPaste. It is used to differentiate 
between a
+                // headings reference and a regular bookmark reference to show 
different
+                // options in the reference mark type popup menu.
+                sCrossRef = 
OUString::number(static_cast<int>(REFERENCESUBTYPE::REF_OUTLINE))
+                        + u"|" + pMark->GetName();
             }
         }
+
+        NaviContentBookmark aBmk(sUrl, sCrossRef, sEntry, pDocShell);
+        aBmk.Copy(rTransfer);
+
+        // An INetBookmark must a be delivered to foreign DocShells
+        if (bUrl && pDocShell->HasName())
+        {
+            INetBookmark aBkmk( sUrl, sEntry );
+            rTransfer.CopyINetBookmark( aBkmk );
+        }
     }
-    return bRet;
+
+    return true;
 }
 
 void SwContentTree::ToggleToRoot()
@@ -5086,11 +5137,6 @@ void SwContentTree::ExecuteContextMenuAction(const 
OUString& rSelectedPopupEntry
             if(m_nOutlineLevel != nSelectedPopupEntry )
                 SetOutlineLevel(static_cast<sal_Int8>(nSelectedPopupEntry));
         break;
-        case 201:
-        case 202:
-        case 203:
-            
GetParentWindow()->SetRegionDropMode(static_cast<RegionMode>(nSelectedPopupEntry
 - 201));
-        break;
         case 401:
         case 402:
             EditEntry(*xFirst, nSelectedPopupEntry == 401 ? 
EditEntryMode::RMV_IDX : EditEntryMode::UPD_IDX);
@@ -5932,32 +5978,26 @@ void SwContentTree::GotoContent(const SwContent* pCnt)
     }
 }
 
-// Now even the matching text::Bookmark
-NaviContentBookmark::NaviContentBookmark()
-    :
-    m_nDocSh(0),
-    m_nDefaultDrag( RegionMode::NONE )
+NaviContentBookmark::NaviContentBookmark() :
+    m_nDocSh(0)
 {
 }
 
-NaviContentBookmark::NaviContentBookmark( OUString aUrl,
-                    OUString aDesc,
-                    RegionMode nDragType,
-                    const SwDocShell* pDocSh ) :
-    m_aUrl(std::move( aUrl )),
+NaviContentBookmark::NaviContentBookmark(OUString sURL, OUString sCrossRef, 
OUString aDesc,
+                    const SwDocShell* pDocSh) :
+    m_sURL(std::move(sURL)),
+    m_sCrossRef(std::move(sCrossRef)),
     m_aDescription(std::move(aDesc)),
-    m_nDocSh(reinterpret_cast<sal_IntPtr>(pDocSh)),
-    m_nDefaultDrag( nDragType )
+    m_nDocSh(reinterpret_cast<sal_IntPtr>(pDocSh))
 {
 }
 
 void NaviContentBookmark::Copy( TransferDataContainer& rData ) const
 {
     rtl_TextEncoding eSysCSet = osl_getThreadTextEncoding();
-
-    OString sStrBuf(OUStringToOString(m_aUrl, eSysCSet) + 
OStringChar(NAVI_BOOKMARK_DELIM) +
+    OString sStrBuf(OUStringToOString(m_sURL, eSysCSet) + 
OStringChar(NAVI_BOOKMARK_DELIM) +
+                    OUStringToOString(m_sCrossRef, eSysCSet) + 
OStringChar(NAVI_BOOKMARK_DELIM) +
                     OUStringToOString(m_aDescription, eSysCSet) + 
OStringChar(NAVI_BOOKMARK_DELIM) +
-                    OString::number(static_cast<int>(m_nDefaultDrag)) + 
OStringChar(NAVI_BOOKMARK_DELIM) +
                     OString::number(m_nDocSh));
     rData.CopyByteString(SotClipboardFormatId::SONLK, sStrBuf);
 }
@@ -5969,9 +6009,9 @@ bool NaviContentBookmark::Paste( const 
TransferableDataHelper& rData, const OUSt
     if( bRet )
     {
         sal_Int32 nPos = 0;
-        m_aUrl    = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
+        m_sURL    = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
+        m_sCrossRef = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos);
         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;
diff --git a/sw/source/uibase/utlui/navicfg.cxx 
b/sw/source/uibase/utlui/navicfg.cxx
index dfda8827292f..7f913946c34c 100644
--- a/sw/source/uibase/utlui/navicfg.cxx
+++ b/sw/source/uibase/utlui/navicfg.cxx
@@ -55,7 +55,6 @@ Sequence<OUString> SwNavigationConfig::GetPropertyNames()
         OUString("RootType"),
         OUString("SelectedPosition"),
         OUString("OutlineLevel"),
-        OUString("InsertMode"),
         OUString("ActiveBlock"),
         OUString("ShowListBox"),
         OUString("GlobalDocMode"),
@@ -83,7 +82,6 @@ SwNavigationConfig::SwNavigationConfig() :
     m_nRootType(ContentTypeId::UNKNOWN),
     m_nSelectedPos(0),
     m_nOutlineLevel(MAXLEVEL),
-    m_nRegionMode(RegionMode::NONE),
     m_nActiveBlock(0),
     m_bIsSmall(false),
     m_bIsGlobalActive(true),
@@ -128,26 +126,19 @@ void SwNavigationConfig::Load()
                 }
                 case 1: pValues[nProp] >>= m_nSelectedPos;   break;
                 case 2: pValues[nProp] >>= m_nOutlineLevel;  break;
-                case 3:
-                {
-                        sal_Int32 nTmp;
-                        if (pValues[nProp] >>= nTmp)
-                            m_nRegionMode = static_cast<RegionMode>(nTmp);
-                        break;
-                }
-                case 4: pValues[nProp] >>= m_nActiveBlock;    break;
-                case 5: m_bIsSmall        = 
*o3tl::doAccess<bool>(pValues[nProp]);  break;
-                case 6: m_bIsGlobalActive = 
*o3tl::doAccess<bool>(pValues[nProp]);  break;
-                case 7: pValues[nProp] >>= m_nOutlineTracking; break;
-                case 8: case 9: case 10: case 11: case 12: case 13: case 14: 
case 15: case 16:
-                case 17: case 18: case 19: case 20: case 21:
+                case 3: pValues[nProp] >>= m_nActiveBlock;    break;
+                case 4: m_bIsSmall        = 
*o3tl::doAccess<bool>(pValues[nProp]);  break;
+                case 5: m_bIsGlobalActive = 
*o3tl::doAccess<bool>(pValues[nProp]);  break;
+                case 6: pValues[nProp] >>= m_nOutlineTracking; break;
+                case 7: case 8: case 9: case 10: case 11: case 12: case 13: 
case 14: case 15:
+                case 16: case 17: case 18: case 19: case 20:
                 {
                     mContentTypeTrack[mPropNameToContentTypeId[aNames[nProp]]] 
=
                             *o3tl::doAccess<bool>(pValues[nProp]);
                     break;
                 }
-                case 22: m_bIsNavigateOnSelect = 
*o3tl::doAccess<bool>(pValues[nProp]); break;
-                case 23: pValues[nProp] >>= m_nSortAlphabeticallyBlock; break;
+                case 21: m_bIsNavigateOnSelect = 
*o3tl::doAccess<bool>(pValues[nProp]); break;
+                case 22: pValues[nProp] >>= m_nSortAlphabeticallyBlock; break;
             }
         }
     }
@@ -170,19 +161,18 @@ void SwNavigationConfig::ImplCommit()
             case 0: pValues[nProp] <<= static_cast<sal_Int32>(m_nRootType);    
 break;
             case 1: pValues[nProp] <<= m_nSelectedPos;  break;
             case 2: pValues[nProp] <<= m_nOutlineLevel; break;
-            case 3: pValues[nProp] <<= static_cast<sal_uInt16>(m_nRegionMode); 
break;
-            case 4: pValues[nProp] <<= m_nActiveBlock;    break;
-            case 5: pValues[nProp] <<= m_bIsSmall; break;
-            case 6: pValues[nProp] <<= m_bIsGlobalActive; break;
-            case 7: pValues[nProp] <<= m_nOutlineTracking; break;
-            case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 
15: case 16:
-            case 17: case 18: case 19: case 20: case 21:
+            case 3: pValues[nProp] <<= m_nActiveBlock;    break;
+            case 4: pValues[nProp] <<= m_bIsSmall; break;
+            case 5: pValues[nProp] <<= m_bIsGlobalActive; break;
+            case 6: pValues[nProp] <<= m_nOutlineTracking; break;
+            case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 
14: case 15:
+            case 16: case 17: case 18: case 19: case 20:
             {
                 pValues[nProp] <<= 
mContentTypeTrack[mPropNameToContentTypeId[aNames[nProp]]];
                 break;
             }
-            case 22: pValues[nProp] <<= m_bIsNavigateOnSelect; break;
-            case 23: pValues[nProp] <<= m_nSortAlphabeticallyBlock; break;
+            case 21: pValues[nProp] <<= m_bIsNavigateOnSelect; break;
+            case 22: pValues[nProp] <<= m_nSortAlphabeticallyBlock; break;
         }
     }
     PutProperties(aNames, aValues);
diff --git a/sw/source/uibase/utlui/navipi.cxx 
b/sw/source/uibase/utlui/navipi.cxx
index c3929875becc..dd3899039a2a 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -345,38 +345,6 @@ IMPL_LINK(SwNavigationPI, ToolBoxClickHdl, const 
OUString&, rCommand, void)
         m_xGlobalTree->TbxMenuHdl(rCommand, *m_xInsertMenu);
 }
 
-IMPL_LINK(SwNavigationPI, ToolBox6DropdownClickHdl, const OUString&, rCommand, 
void)
-{
-    if (!m_xContent6ToolBox->get_menu_item_active(rCommand))
-        return;
-
-    if (rCommand != "dragmode")
-        return;
-
-    switch (m_nRegionMode)
-    {
-        case RegionMode::NONE:
-            m_xDragModeMenu->set_active("hyperlink", true);
-            break;
-        case RegionMode::LINK:
-            m_xDragModeMenu->set_active("link", true);
-            break;
-        case RegionMode::EMBEDDED:
-            m_xDragModeMenu->set_active("copy", true);
-            break;
-    }
-}
-
-IMPL_LINK(SwNavigationPI, DropModeMenuSelectHdl, const OUString&, rIdent, void)
-{
-    if (rIdent == "hyperlink")
-        SetRegionDropMode(RegionMode::NONE);
-    else if (rIdent == "link")
-        SetRegionDropMode(RegionMode::LINK);
-    else if (rIdent == "copy")
-        SetRegionDropMode(RegionMode::EMBEDDED);
-}
-
 IMPL_LINK(SwNavigationPI, GlobalMenuSelectHdl, const OUString&, rIdent, void)
 {
     m_xGlobalTree->ExecuteContextMenuAction(rIdent);
@@ -534,7 +502,6 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
     , m_xContent2Dispatch(new ToolbarUnoDispatcher(*m_xContent2ToolBox, 
*m_xBuilder, rxFrame))
     , m_xContent3Dispatch(new ToolbarUnoDispatcher(*m_xContent3ToolBox, 
*m_xBuilder, rxFrame))
     , m_xHeadingsMenu(m_xBuilder->weld_menu("headingsmenu"))
-    , m_xDragModeMenu(m_xBuilder->weld_menu("dragmodemenu"))
     , m_xUpdateMenu(m_xBuilder->weld_menu("updatemenu"))
     , m_xInsertMenu(m_xBuilder->weld_menu("insertmenu"))
     , m_xGlobalToolBox(m_xBuilder->weld_toolbar("global"))
@@ -552,7 +519,6 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
     , m_pCreateView(nullptr)
     , m_pConfig(SW_MOD()->GetNavigationConfig())
     , m_rBindings(*_pBindings)
-    , m_nRegionMode(RegionMode::NONE)
     , m_bIsZoomedIn(false)
     , m_bGlobalMode(false)
 {
@@ -628,8 +594,6 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
 
     bool bFloatingNavigator = ParentIsFloatingWindow(m_xNavigatorDlg);
 
-    SetRegionDropMode(m_pConfig->GetRegionMode());
-
     m_xContentTree->ShowTree();
     m_xContent6ToolBox->set_item_active("listbox", true);
     m_xContent6ToolBox->set_item_sensitive("listbox", bFloatingNavigator);
@@ -648,9 +612,6 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
     m_xContent5ToolBox->set_item_menu("headings", m_xHeadingsMenu.get());
     m_xHeadingsMenu->connect_activate(LINK(this, SwNavigationPI, 
HeadingsMenuSelectHdl));
     m_xContent5ToolBox->connect_menu_toggled(LINK(this, SwNavigationPI, 
ToolBox5DropdownClickHdl));
-    m_xContent6ToolBox->set_item_menu("dragmode", m_xDragModeMenu.get());
-    m_xDragModeMenu->connect_activate(LINK(this, SwNavigationPI, 
DropModeMenuSelectHdl));
-    m_xContent6ToolBox->connect_menu_toggled(LINK(this, SwNavigationPI, 
ToolBox6DropdownClickHdl));
     m_xGlobalToolBox->set_item_menu("update", m_xUpdateMenu.get());
     m_xUpdateMenu->connect_activate(LINK(this, SwNavigationPI, 
GlobalMenuSelectHdl));
     m_xGlobalToolBox->set_item_menu("insert", m_xInsertMenu.get());
@@ -744,7 +705,6 @@ SwNavigationPI::~SwNavigationPI()
     m_xGlobalToolBox.reset();
     m_xEdit.reset();
     m_xHeadingsMenu.reset();
-    m_xDragModeMenu.reset();
     m_xUpdateMenu.reset();
     m_xInsertMenu.reset();
     m_xContent2Dispatch.reset();
@@ -1048,27 +1008,6 @@ sal_Int8 SwNavigationPI::ExecuteDrop( const 
ExecuteDropEvent& rEvt )
     return nRet;
 }
 
-void SwNavigationPI::SetRegionDropMode(RegionMode nNewMode)
-{
-    m_nRegionMode = nNewMode;
-    m_pConfig->SetRegionMode( m_nRegionMode );
-
-    OUString sImageId;
-    switch (nNewMode)
-    {
-        case RegionMode::NONE:
-            sImageId = RID_BMP_DROP_REGION;
-            break;
-        case RegionMode::LINK:
-            sImageId = RID_BMP_DROP_LINK;
-            break;
-        case RegionMode::EMBEDDED:
-            sImageId = RID_BMP_DROP_COPY;
-            break;
-    }
-    m_xContent6ToolBox->set_item_icon_name("dragmode", sImageId);
-}
-
 void SwNavigationPI::ToggleTree()
 {
     if (comphelper::LibreOfficeKit::isActive())
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx 
b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 3a9e51136fd0..bed67797ea59 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -61,6 +61,11 @@
 #include <sfx2/event.hxx>
 #include <sal/log.hxx>
 
+#include <fldmgr.hxx>
+#include <vcl/weldutils.hxx>
+#include <strings.hrc>
+#include <officecfg/Office/Common.hxx>
+
 bool SwWrtShell::InsertField2(SwField const& rField, SwPaM* pAnnotationRange)
 {
     ResetCursorStack();
@@ -620,18 +625,156 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, 
LoadUrlFlags nFilter,
         ::LoadURL(pSh->GetView(), rURL, nFilter, rTargetFrameName);
 }
 
-void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk,
-                                    const sal_uInt16 nAction )
+void SwWrtShell::NavigatorPaste(const NaviContentBookmark& rBkmk)
 {
-    if( EXCHG_IN_ACTION_COPY == nAction )
+    const OUString& rsCrossRef = rBkmk.GetCrossRef();
+    const OUString& rsURL = rBkmk.GetURL();
+
+    if (rsURL.isEmpty() && rsCrossRef.isEmpty())
+        return;
+
+    bool bSensitiveHyperlinkEntry = false;
+    bool bSensitiveSectionLinkEntry = false;
+    bool bSensitiveSectionCopyEntry = false;
+    bool bSensitiveRefPageEntry = false;
+    bool bSensitiveRefChapterEntry = false;
+    bool bSensitiveRefContentEntry = false;
+    bool bSensitiveRefUpDownEntry = false;
+    bool bSensitiveRefPagePgDscEntry = false;
+    bool bSensitiveRefNumberEntry = false;
+    bool bSensitiveRefNumberNoContextEntry = false;
+    bool bSensitiveRefNumberFullContextEntry = false;
+    bool bSensitiveRefOnlyNumberEntry = false;
+    bool bSensitiveRefOnlyCaptionEntry = false;
+    bool bSensitiveRefOnlySeqNoEntry = false;
+
+    if (!rsURL.isEmpty())
+    {
+        bSensitiveHyperlinkEntry = true;
+
+        OUString sType = rsURL.getToken(1, '|');
+        if (sType == "outline" || sType == "table")
+        {
+            bSensitiveSectionLinkEntry = true;
+            bSensitiveSectionCopyEntry = true;
+        }
+    }
+
+    std::optional<REFERENCESUBTYPE> oeRefSubType;
+    std::optional<OUString> osName;
+    std::optional<OUString> osVal;
+
+    if (!rsCrossRef.isEmpty())
+    {
+        sal_Int32 nPos = 0;
+        oeRefSubType = static_cast<REFERENCESUBTYPE>(
+                    o3tl::toInt32(o3tl::getToken(rsCrossRef, 0, '|', nPos)));
+        osName = rsCrossRef.getToken(0, '|', nPos);
+        if (oeRefSubType == REFERENCESUBTYPE::REF_SEQUENCEFLD
+                || oeRefSubType == REFERENCESUBTYPE::REF_FOOTNOTE
+                || oeRefSubType == REFERENCESUBTYPE::REF_ENDNOTE)
+        {
+            // sequence number
+            osVal = rsCrossRef.getToken(0, '|', nPos);
+        }
+        else
+            osVal = rBkmk.GetDescription();
+
+        bSensitiveRefPageEntry = true;
+        bSensitiveRefChapterEntry = true;
+        bSensitiveRefContentEntry = true;
+        bSensitiveRefUpDownEntry = true;
+        bSensitiveRefPagePgDscEntry = true;
+
+        if (oeRefSubType == REFERENCESUBTYPE::REF_OUTLINE)
+        {
+            bSensitiveRefNumberEntry = true;
+            bSensitiveRefNumberNoContextEntry = true;
+            bSensitiveRefNumberFullContextEntry = true;
+        }
+        if (oeRefSubType == REFERENCESUBTYPE::REF_SEQUENCEFLD)
+        {
+            bSensitiveRefOnlyNumberEntry = true;
+            bSensitiveRefOnlyCaptionEntry = true;
+            bSensitiveRefOnlySeqNoEntry = true;
+        }
+    }
+
+    vcl::Window* pWin = GetWin();
+
+    std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(
+        pWin->GetFrameWeld(), 
"modules/swriter/ui/navigatordraginsertmenu.ui"));
+    std::unique_ptr<weld::Menu> xPop = xBuilder->weld_menu("insertmenu");
+
+    xPop->append("hyperlink", SwResId(STR_HYPERLINK));
+    xPop->append("sectionlink", SwResId(STR_SECTIONLINK));
+    xPop->append("sectioncopy", SwResId(STR_SECTIONCOPY));
+    xPop->append("refpage", SwResId(FMT_REF_PAGE));
+    xPop->append("refchapter", SwResId(FMT_REF_CHAPTER));
+    xPop->append("refcontent", SwResId(FMT_REF_TEXT));
+    xPop->append("refupdown", SwResId(FMT_REF_UPDOWN));
+    xPop->append("refpagepgdsc", SwResId(FMT_REF_PAGE_PGDSC));
+    xPop->append("refnumberentry", SwResId(FMT_REF_NUMBER));
+    xPop->append("refnumbernocontext", SwResId(FMT_REF_NUMBER_NO_CONTEXT));
+    xPop->append("refnumberfullcontext", SwResId(FMT_REF_NUMBER_FULL_CONTEXT));
+    xPop->append("refonlynumber", SwResId(FMT_REF_ONLYNUMBER));
+    xPop->append("refonlycaption", SwResId(FMT_REF_ONLYCAPTION));
+    xPop->append("refonlyseqnoentry", SwResId(FMT_REF_ONLYSEQNO));
+
+    if (!officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get()
+            || 
Application::GetSettings().GetStyleSettings().GetHideDisabledMenuItems())
+    {
+        xPop->set_visible("hyperlink", bSensitiveHyperlinkEntry);
+        xPop->set_visible("sectionlink", bSensitiveSectionLinkEntry);
+        xPop->set_visible("sectioncopy", bSensitiveSectionCopyEntry);
+        xPop->set_visible("refpage", bSensitiveRefPageEntry);
+        xPop->set_visible("refchapter", bSensitiveRefChapterEntry);
+        xPop->set_visible("refcontent", bSensitiveRefContentEntry);
+        xPop->set_visible("refupdown", bSensitiveRefUpDownEntry);
+        xPop->set_visible("refpagepgdsc", bSensitiveRefPagePgDscEntry);
+        xPop->set_visible("refnumberentry", bSensitiveRefNumberEntry);
+        xPop->set_visible("refnumbernocontext", 
bSensitiveRefNumberNoContextEntry);
+        xPop->set_visible("refnumberfullcontext", 
bSensitiveRefNumberFullContextEntry);
+        xPop->set_visible("refonlynumber", bSensitiveRefOnlyNumberEntry);
+        xPop->set_visible("refonlycaption", bSensitiveRefOnlyCaptionEntry);
+        xPop->set_visible("refonlyseqnoentry", bSensitiveRefOnlySeqNoEntry);
+    }
+    else
+    {
+        xPop->set_sensitive("hyperlink", bSensitiveHyperlinkEntry);
+        xPop->set_sensitive("sectionlink", bSensitiveSectionLinkEntry);
+        xPop->set_sensitive("sectioncopy", bSensitiveSectionCopyEntry);
+        xPop->set_sensitive("refpage", bSensitiveRefPageEntry);
+        xPop->set_sensitive("refchapter", bSensitiveRefChapterEntry);
+        xPop->set_sensitive("refcontent", bSensitiveRefContentEntry);
+        xPop->set_sensitive("refupdown", bSensitiveRefUpDownEntry);
+        xPop->set_sensitive("refpagepgdsc", bSensitiveRefPagePgDscEntry);
+        xPop->set_sensitive("refnumberentry", bSensitiveRefNumberEntry);
+        xPop->set_sensitive("refnumbernocontext", 
bSensitiveRefNumberNoContextEntry);
+        xPop->set_sensitive("refnumberfullcontext", 
bSensitiveRefNumberFullContextEntry);
+        xPop->set_sensitive("refonlynumber", bSensitiveRefOnlyNumberEntry);
+        xPop->set_sensitive("refonlycaption", bSensitiveRefOnlyCaptionEntry);
+        xPop->set_sensitive("refonlyseqnoentry", bSensitiveRefOnlySeqNoEntry);
+    }
+
+    tools::Rectangle aRect(pWin->LogicToPixel(GetCursorDocPos()), Size(1, 1));
+    weld::Window* pParent = weld::GetPopupParent(*pWin, aRect);
+
+    OUString sInsert = xPop->popup_at_rect(pParent, aRect);
+
+    if (sInsert.isEmpty())
+        return;
+
+    pWin->GrabFocus();
+
+    if (sInsert == "hyperlink")
     {
-        // Insert
         OUString sURL = rBkmk.GetURL();
         // Is this is a jump within the current Doc?
         const SwDocShell* pDocShell = GetView().GetDocShell();
         if(pDocShell->HasName())
         {
-            const OUString rName = 
pDocShell->GetMedium()->GetURLObject().GetURLNoMark();
+            const OUString& rName = 
pDocShell->GetMedium()->GetURLObject().GetURLNoMark();
 
             if (sURL.startsWith(rName))
             {
@@ -648,17 +791,17 @@ void SwWrtShell::NavigatorPaste( const 
NaviContentBookmark& rBkmk,
         SwFormatINetFormat aFormat( sURL, OUString() );
         InsertURL( aFormat, rBkmk.GetDescription() );
     }
-    else
+    else if (sInsert == "sectionlink" || sInsert == "sectioncopy")
     {
         SwSectionData aSection( SectionType::FileLink, GetUniqueSectionName() 
);
-        OUString aLinkFile = o3tl::getToken(rBkmk.GetURL(), 0, '#')
-            + OUStringChar(sfx2::cTokenSeparator)
-            + OUStringChar(sfx2::cTokenSeparator)
-            + o3tl::getToken(rBkmk.GetURL(), 1, '#');
+        OUString aLinkFile = o3tl::getToken(rsURL, 0, '#')
+                + OUStringChar(sfx2::cTokenSeparator)
+                + OUStringChar(sfx2::cTokenSeparator)
+                + o3tl::getToken(rsURL, 1, '#');
         aSection.SetLinkFileName( aLinkFile );
         aSection.SetProtectFlag( true );
         const SwSection* pIns = InsertSection( aSection );
-        if( EXCHG_IN_ACTION_MOVE == nAction && pIns )
+        if (sInsert == "sectioncopy" && pIns)
         {
             aSection = SwSectionData(*pIns);
             aSection.SetLinkFileName( OUString() );
@@ -681,6 +824,49 @@ void SwWrtShell::NavigatorPaste( const 
NaviContentBookmark& rBkmk,
             DoUndo( bDoesUndo );
         }
     }
+    else // insert is for a reference mark type
+    {
+        REFERENCEMARK eRefMarkType;
+
+        if (sInsert == "refpage")
+            eRefMarkType = REFERENCEMARK::REF_PAGE;
+        else if (sInsert == "refchapter")
+            eRefMarkType = REFERENCEMARK::REF_CHAPTER;
+        else if (sInsert == "refcontent")
+            eRefMarkType = REFERENCEMARK::REF_CONTENT;
+        else if (sInsert == "refupdown")
+            eRefMarkType = REFERENCEMARK::REF_UPDOWN;
+        else if (sInsert == "refpagepgdsc")
+            eRefMarkType = REFERENCEMARK::REF_PAGE_PGDESC;
+        else if (sInsert == "refnumberentry")
+            eRefMarkType = REFERENCEMARK::REF_NUMBER;
+        else if (sInsert == "refnumbernocontext")
+            eRefMarkType = REFERENCEMARK::REF_NUMBER_NO_CONTEXT;
+        else if (sInsert == "refnumberfullcontext")
+            eRefMarkType = REFERENCEMARK::REF_NUMBER_FULL_CONTEXT;
+        else if (sInsert == "refonlynumber")
+            eRefMarkType = REFERENCEMARK::REF_ONLYNUMBER;
+        else if (sInsert == "refonlycaption")
+            eRefMarkType = REFERENCEMARK::REF_ONLYCAPTION;
+        else if (sInsert == "refonlyseqnoentry")
+            eRefMarkType = REFERENCEMARK::REF_ONLYSEQNO;
+        else
+        {
+            assert(!"unknown reference mark type");
+            return;
+        }
+
+        // Change REFERENCESUBTYPE_OUTLINE to REFERENCESUBTYPE::BOOKMARK. It 
is used to show
+        // different options for headings reference and a regular bookmark in 
the reference mark
+        // type popup menu. See related comment in 
SwContentTree::FillTransferData.
+        if (oeRefSubType == REFERENCESUBTYPE::REF_OUTLINE)
+            oeRefSubType = REFERENCESUBTYPE::REF_BOOKMARK;
+
+        SwInsertField_Data aData(SwFieldTypesEnum::GetRef, 
oeRefSubType.value(), osName.value(),
+                                 osVal.value(), eRefMarkType);
+        SwFieldMgr aFieldMgr(this);
+        aFieldMgr.InsertField(aData);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui 
b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui
index 6ec00b4a20ee..d4ab2d105bfa 100644
--- a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui
+++ b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui
@@ -473,20 +473,6 @@
         </child>
       </object>
     </child>
-    <child>
-      <object class="GtkMenuItem" id="2">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="label" translatable="yes" 
context="navigatorcontextmenu|STR_DRAGMODE">Drag Mode</property>
-        <property name="use-underline">True</property>
-        <child type="submenu">
-          <object class="GtkMenu" id="dragmodemenu">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-          </object>
-        </child>
-      </object>
-    </child>
     <child>
       <object class="GtkMenuItem" id="3">
         <property name="visible">True</property>
diff --git a/sw/uiconfig/swriter/ui/navigatordraginsertmenu.ui 
b/sw/uiconfig/swriter/ui/navigatordraginsertmenu.ui
new file mode 100644
index 000000000000..65c67ac1b8c6
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/navigatordraginsertmenu.ui
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.40.0 -->
+<interface domain="sw">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkMenu" id="insertmenu">
+    <property name="visible">True</property>
+    <property name="can-focus">False</property>
+  </object>
+</interface>
diff --git a/sw/uiconfig/swriter/ui/navigatorpanel.ui 
b/sw/uiconfig/swriter/ui/navigatorpanel.ui
index 4b8d45fc41fc..843154620a69 100644
--- a/sw/uiconfig/swriter/ui/navigatorpanel.ui
+++ b/sw/uiconfig/swriter/ui/navigatorpanel.ui
@@ -8,40 +8,6 @@
     <property name="step-increment">1</property>
     <property name="page-increment">10</property>
   </object>
-  <object class="GtkMenu" id="dragmodemenu">
-    <property name="visible">True</property>
-    <property name="can-focus">False</property>
-    <child>
-      <object class="GtkRadioMenuItem" id="hyperlink">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="label" translatable="yes" 
context="navigatorpanel|hyperlink">Insert as Hyperlink</property>
-        <property name="use-underline">True</property>
-        <property name="active">True</property>
-        <property name="draw-as-radio">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkRadioMenuItem" id="link">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="label" translatable="yes" 
context="navigatorpanel|link">Insert as Link</property>
-        <property name="use-underline">True</property>
-        <property name="draw-as-radio">True</property>
-        <property name="group">hyperlink</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkRadioMenuItem" id="copy">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="label" translatable="yes" 
context="navigatorpanel|copy">Insert as Copy</property>
-        <property name="use-underline">True</property>
-        <property name="draw-as-radio">True</property>
-        <property name="group">hyperlink</property>
-      </object>
-    </child>
-  </object>
   <object class="GtkMenu" id="headingsmenu">
     <property name="visible">True</property>
     <property name="can-focus">False</property>
@@ -642,33 +608,6 @@
                         <property name="homogeneous">False</property>
                       </packing>
                     </child>
-                    <child>
-                      <object class="GtkSeparatorToolItem" id="separator1">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="homogeneous">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkMenuToolButton" id="dragmode">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
-                        <property name="tooltip-text" translatable="yes" 
context="navigatorpanel|dragmode|tooltip_text">Drag Mode</property>
-                        <property 
name="icon-name">sw/res/sc20235.png</property>
-                        <child internal-child="accessible">
-                          <object class="AtkObject" id="dragmode-atkobject">
-                            <property name="AtkObject::accessible-description" 
translatable="yes" context="navigatorpanel|extended_tip|dragmode">Sets the drag 
and drop options for inserting items from the Navigator into a document, for 
example, as a hyperlink. Click this icon, and then choose the option that you 
want to use.</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="homogeneous">False</property>
-                      </packing>
-                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>

Reply via email to