tdf#169913 - Add option to suppress typing replaces text selection

Change-Id: Iee202a64314be7def38cffd95f4cac7fe083080e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206276
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
This commit is contained in:
Andreas Heinisch
2026-06-11 18:41:21 +02:00
parent 7708f32604
commit ac0fe92185
7 changed files with 119 additions and 0 deletions
@@ -2202,6 +2202,13 @@
</info>
<value>true</value>
</prop>
<prop oor:name="TypingReplacesSelection" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies whether typing replaces the selected text.</desc>
<label>Typing replaces selection</label>
</info>
<value>true</value>
</prop>
</group>
</group>
<group oor:name="FmtAidsAutocomplete">
+2
View File
@@ -641,6 +641,8 @@ public:
static bool IsAllowDragDropText();
static bool IsTypingReplacesSelection();
bool IsPDFExport() const
{return bool(m_nCore2Options & ViewOptCoreFlags2::PdfExport); }
+19
View File
@@ -1749,6 +1749,8 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, w
, 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_xTypingReplacesSelectionCB(m_xBuilder->weld_check_button(u"typingreplacesselection"_ustr))
, m_xTypingReplacesSelectionImg(m_xBuilder->weld_widget(u"locktypingreplacesselection"_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))
@@ -1881,6 +1883,15 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* rSet )
xChanges->commit();
}
if (m_xTypingReplacesSelectionCB->get_state_changed_from_saved())
{
std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
comphelper::ConfigurationChanges::create());
officecfg::Office::Writer::Cursor::Option::TypingReplacesSelection::set(
m_xTypingReplacesSelectionCB->get_active(), xChanges);
xChanges->commit();
}
SwFmtAidsAutoComplItem aFmtAidsAutoComplOpt;
aFmtAidsAutoComplOpt.SetEncloseWithCharactersOn(m_xEncloseWithCharactersCB->get_active());
if (const SwFmtAidsAutoComplItem* pFmtAidsAutoComplItem
@@ -1973,6 +1984,14 @@ void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
m_xDragDropImg->set_visible(bReadOnly);
m_xDragDropCB->save_state();
const bool bTypingReplacesSelection
= officecfg::Office::Writer::Cursor::Option::TypingReplacesSelection::get();
m_xTypingReplacesSelectionCB->set_active(bTypingReplacesSelection);
bReadOnly = officecfg::Office::Writer::Cursor::Option::TypingReplacesSelection::isReadOnly();
m_xTypingReplacesSelectionCB->set_sensitive(!bReadOnly);
m_xTypingReplacesSelectionImg->set_visible(bReadOnly);
m_xTypingReplacesSelectionCB->save_state();
const SwDocDisplayItem* pDocDisplayAttr = rSet->GetItemIfSet( FN_PARAM_DOCDISP, false );
if(pDocDisplayAttr)
{
+9
View File
@@ -602,6 +602,15 @@ bool SwViewOption::IsAllowDragDropText()
return gAllowDragDrop.get();
}
bool SwViewOption::IsTypingReplacesSelection()
{
if (comphelper::IsFuzzing())
return true;
static comphelper::ConfigurationListenerProperty<bool> gTypingReplacesSelection(
getWCOptionListener(), u"TypingReplacesSelection"_ustr);
return gTypingReplacesSelection.get();
}
void SwViewOption::SyncLayoutRelatedViewOptions(const SwViewOption& rOpt)
{
SetFieldName(rOpt.IsFieldName());
+3
View File
@@ -346,6 +346,9 @@ class SwShdwCursorOptionsTabPage final : public SfxTabPage
std::unique_ptr<weld::CheckButton> m_xDragDropCB;
std::unique_ptr<weld::Widget> m_xDragDropImg;
std::unique_ptr<weld::CheckButton> m_xTypingReplacesSelectionCB;
std::unique_ptr<weld::Widget> m_xTypingReplacesSelectionImg;
std::unique_ptr<weld::CheckButton> m_xTextBoundariesCB;
std::unique_ptr<weld::CheckButton> m_xSectionBoundariesCB;
std::unique_ptr<weld::CheckButton> m_xTableBoundariesCB;
+8
View File
@@ -249,6 +249,14 @@ void SwWrtShell::Insert( const OUString &rStr )
bCallIns = m_bIns /*|| bHasSel*/;
bool bDeleted = false;
// tdf#169913 - insert at cursor position without overwriting the selection
if (bHasSel && !SwViewOption::IsTypingReplacesSelection())
{
NormalizePam(false);
ClearMark();
bHasSel = false;
}
if( bHasSel || ( !m_bIns && IsInHiddenRange(/*bSelect=*/true) ) )
{
// Only here parenthesizing, because the normal
@@ -904,6 +904,77 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frmTyping">
<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="grid8">
<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="typingreplacesselection">
<property name="label" translatable="yes" context="optformataidspage|typingreplacesselection">Typing replaces selection</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="typingreplacesselection-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|typingreplacesselection">Specifies whether typing replaces the selected text.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="locktypingreplacesselection">
<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="locktypingreplacesselection-atkobject">
<property name="AtkObject::accessible-description">Specifies whether typing replaces the selected text.</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="lbTyping">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="optformataidspage|lbTyping">Typing</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>