officecfg/registry/schema/org/openoffice/Office/Writer.xcs |    7 +
 sw/inc/viewopt.hxx                                         |    2 
 sw/source/ui/config/optpage.cxx                            |   18 +++
 sw/source/uibase/config/viewopt.cxx                        |    8 +
 sw/source/uibase/docvw/edtdd.cxx                           |    3 
 sw/source/uibase/inc/optpage.hxx                           |    4 
 sw/uiconfig/swriter/ui/optformataidspage.ui                |   71 +++++++++++++
 7 files changed, 112 insertions(+), 1 deletion(-)

New commits:
commit a2e3d9389182b5f06b80ebc73b832d1df9700bef
Author:     Heiko Tietze <[email protected]>
AuthorDate: Wed Oct 22 16:16:58 2025 +0200
Commit:     Heiko Tietze <[email protected]>
CommitDate: Thu Oct 23 09:56:35 2025 +0200

    Resolves tdf#100998 - Add option to suppress drag'n drop of text selection
    
    Change-Id: Ib8c352fc5c51610a7bb2323c94eaa3e00585f67b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192857
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <[email protected]>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index 6d3efca6330a..054e7434e89c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -2182,6 +2182,13 @@
           </info>
           <value>false</value>
         </prop>
+        <prop oor:name="AllowDragDrop" oor:type="xs:boolean" 
oor:nillable="false">
+          <info>
+            <desc>Specifies whether drag'n drop of selected text is possible 
in editengine.</desc>
+            <label>Allow drag'n drop</label>
+          </info>
+          <value>true</value>
+        </prop>
       </group>
     </group>
     <group oor:name="FmtAidsAutocomplete">
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 9b62e330963f..ff93ba1540c7 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -610,6 +610,8 @@ public:
 
     static bool IsIgnoreProtectedArea();
 
+    static bool IsAllowDragDropText();
+
     bool IsPDFExport() const
         {return bool(m_nCore2Options & ViewOptCoreFlags2::PdfExport); }
 
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 214a0852c70e..8c919093c13d 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1742,6 +1742,9 @@ 
SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, w
     , 
m_xFmtAidsAutoComplFrame(m_xBuilder->weld_frame(u"fmtaidsautocompleteframe"_ustr))
     , 
m_xEncloseWithCharactersCB(m_xBuilder->weld_check_button(u"enclosewithcharacters"_ustr))
     , 
m_xEncloseWithCharactersImg(m_xBuilder->weld_widget(u"lockenclosewithcharacters"_ustr))
+    , m_xDragDropFrame(m_xBuilder->weld_frame(u"frmDragDrop"_ustr))
+    , m_xDragDropCB(m_xBuilder->weld_check_button(u"allowdragdrop"_ustr))
+    , m_xDragDropImg(m_xBuilder->weld_widget(u"lockallowdragdrop"_ustr))
     , 
m_xTextBoundariesCB(m_xBuilder->weld_check_button(u"cbTextBoundaries"_ustr))
     , 
m_xSectionBoundariesCB(m_xBuilder->weld_check_button(u"cbSectionBoundaries"_ustr))
     , 
m_xTableBoundariesCB(m_xBuilder->weld_check_button(u"cbTableBoundaries"_ustr))
@@ -1866,6 +1869,14 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( 
SfxItemSet* rSet )
         bRet = true;
     }
 
+    if( m_xDragDropCB->get_state_changed_from_saved())
+    {
+        std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
+            comphelper::ConfigurationChanges::create());
+        
officecfg::Office::Writer::Cursor::Option::AllowDragDrop::set(m_xDragDropCB->get_active(),
 xChanges);
+        xChanges->commit();
+    }
+
     SwFmtAidsAutoComplItem aFmtAidsAutoComplOpt;
     
aFmtAidsAutoComplOpt.SetEncloseWithCharactersOn(m_xEncloseWithCharactersCB->get_active());
     if (const SwFmtAidsAutoComplItem* pFmtAidsAutoComplItem
@@ -1951,6 +1962,13 @@ void SwShdwCursorOptionsTabPage::Reset( const 
SfxItemSet* rSet )
     m_xCursorInProtImg->set_visible(bReadOnly);
     m_xCursorInProtCB->save_state();
 
+    const bool bAllowDragDrop = 
officecfg::Office::Writer::Cursor::Option::AllowDragDrop::get();
+    m_xDragDropCB->set_active(bAllowDragDrop);
+    bReadOnly = 
officecfg::Office::Writer::Cursor::Option::AllowDragDrop::isReadOnly();
+    m_xDragDropCB->set_sensitive(!bReadOnly);
+    m_xDragDropImg->set_visible(bReadOnly);
+    m_xDragDropCB->save_state();
+
     const SwDocDisplayItem* pDocDisplayAttr = rSet->GetItemIfSet( 
FN_PARAM_DOCDISP, false );
     if(pDocDisplayAttr)
     {
diff --git a/sw/source/uibase/config/viewopt.cxx 
b/sw/source/uibase/config/viewopt.cxx
index 5cfd149b1122..5a2b5dcdbe90 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -579,6 +579,14 @@ bool SwViewOption::IsIgnoreProtectedArea()
     return gIgnoreProtectedArea.get();
 }
 
+bool SwViewOption::IsAllowDragDropText()
+{
+    if (comphelper::IsFuzzing())
+        return true;
+    static comphelper::ConfigurationListenerProperty<bool> 
gAllowDragDrop(getWCOptionListener(), u"AllowDragDrop"_ustr);
+    return gAllowDragDrop.get();
+}
+
 void SwViewOption::SyncLayoutRelatedViewOptions(const SwViewOption& rOpt)
 {
     SetFieldName(rOpt.IsFieldName());
diff --git a/sw/source/uibase/docvw/edtdd.cxx b/sw/source/uibase/docvw/edtdd.cxx
index 89f93144919d..c400c7e15a80 100644
--- a/sw/source/uibase/docvw/edtdd.cxx
+++ b/sw/source/uibase/docvw/edtdd.cxx
@@ -64,7 +64,8 @@ void SwEditWin::StopDDTimer(SwWrtShell *pSh, const Point &rPt)
 
 void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel )
 {
-    if (m_rView.GetObjectShell()->isContentExtractionLocked())
+    if (m_rView.GetObjectShell()->isContentExtractionLocked()
+        || !SwViewOption::IsAllowDragDropText())
         return;
 
     SwWrtShell &rSh = m_rView.GetWrtShell();
diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx
index ca60e8f00219..3827ef49b0b2 100644
--- a/sw/source/uibase/inc/optpage.hxx
+++ b/sw/source/uibase/inc/optpage.hxx
@@ -336,6 +336,10 @@ class SwShdwCursorOptionsTabPage final : public SfxTabPage
     std::unique_ptr<weld::CheckButton> m_xEncloseWithCharactersCB;
     std::unique_ptr<weld::Widget> m_xEncloseWithCharactersImg;
 
+    std::unique_ptr<weld::Frame> m_xDragDropFrame;
+    std::unique_ptr<weld::CheckButton> m_xDragDropCB;
+    std::unique_ptr<weld::Widget> m_xDragDropImg;
+
     std::unique_ptr<weld::CheckButton> m_xTextBoundariesCB;
     std::unique_ptr<weld::CheckButton> m_xSectionBoundariesCB;
     std::unique_ptr<weld::CheckButton> m_xTableBoundariesCB;
diff --git a/sw/uiconfig/swriter/ui/optformataidspage.ui 
b/sw/uiconfig/swriter/ui/optformataidspage.ui
index 4d76e6f5b3ad..d9c0e7d075d0 100644
--- a/sw/uiconfig/swriter/ui/optformataidspage.ui
+++ b/sw/uiconfig/swriter/ui/optformataidspage.ui
@@ -827,6 +827,77 @@
                   </object>
                 </child>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frmDragDrop">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="valign">start</property>
+                <property name="label-xalign">0</property>
+                <property name="shadow-type">none</property>
+                <child>
+                  <!-- n-columns=2 n-rows=1 -->
+                  <object class="GtkGrid" id="grid4">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-top">6</property>
+                    <property name="row-spacing">6</property>
+                    <child>
+                      <object class="GtkCheckButton" id="allowdragdrop">
+                        <property name="label" translatable="yes" 
context="optformataidspage|allowdragdrop">Allow text to be dragged and 
dropped</property>
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">False</property>
+                        <property name="use-underline">True</property>
+                        <property name="draw-indicator">True</property>
+                        <child internal-child="accessible">
+                          <object class="AtkObject" 
id="allowdragdrop-atkobject">
+                            <property name="AtkObject::accessible-description" 
translatable="yes" context="extended_tip|enclosewithcharacters">Specifies 
whether dragging and dropping selected text should be possible.</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left-attach">1</property>
+                        <property name="top-attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkImage" id="lockallowdragdrop">
+                        <property name="can-focus">False</property>
+                        <property name="no-show-all">True</property>
+                        <property name="halign">center</property>
+                        <property name="valign">center</property>
+                        <property name="icon-name">res/lock.png</property>
+                        <child internal-child="accessible">
+                          <object class="AtkObject" 
id="lockallowdragdrop-atkobject">
+                            <property 
name="AtkObject::accessible-description">Specifies that you can enclose 
selected text with parentheses, square brackets, curly braces or quotation 
marks when pressing the respective button.</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left-attach">0</property>
+                        <property name="top-attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="lbDragDrop">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="label" translatable="yes" 
context="optformataidspage|lbDragDrop">Drag 'n Drop</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+              </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>

Reply via email to