A wildcard AutoCorrect entry like ".*->.*" copied that character into
its replacement text, inserting a second FIELDSTART into the node which
crashes FindFieldSep.
Extend the delimiter check to the entire 0x01 ... 0x08 char range
put in the text (CH_TXTATR_BREAKWORD, CH_TXT_ATR_FIELDSEP,
CH_TXT_ATR_INPUTFIELDSTART/END, CH_TXT_ATR_FORMELEMENT,
CH_TXT_ATR_FIELDSTART/END).
Change-Id: Ib58bb7e3c614977082cd9d23722497f77fe9ca8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211447
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
When an apostrophe or quotation mark is typed, autocorrect replaces it
with the matching typographic quote. This was done in two edits: the
typed straight character was inserted first, then replaced with the
typographic one. Since each edit is its own undo step, undoing the
autocorrect first turned the quote back into a straight quote and only a
second undo removed it. In languages that never use straight quotes, for
example French, typing 'un and undoing left a stray straight quote in the
text.
Build the typographic quote with a single edit, so one undo removes the
whole quote.
The change is limited to the quote handling. Autocorrections that insert
a character and then act on something else, such as turning a web or mail
address into a link after a space, keep their existing per-step undo
Change-Id: Ibf47fb8f37d29d5ba180ed692f730d20e9f3e431
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5897
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit e2ba52e1996f81ff3b93fa70ecf625b7709d07fb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207621
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
In the past, weld.hxx used to contain the class
definitions for weld::Widget and all subclasses.
By now, weld::Widget and almost all subclasses have
been moved to separate headers, to make it easier
to keep the overview and to avoid having to
recompile ~all UI code when one class changes.
By now, only weld::Button is left in weld.hxx.
Rename the header to Button.hxx.
Drop weld.hxx includes and instead add Button.hxx
includes (or weld::Button forward declarations) where
weld::Button is used.
(Don't simply replace all weld.hxx includes with
Button.hxx ones, since many of them were for the
use of other widgets that have since been moved
to their own headers.)
Add further includes where needed now that the
(direct or transitive) includes of weld.hxx were removed.
Change-Id: I8ea6201446a418d5e38b46337059dcd517ee29d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205937
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Move the class out of weld.hxx into its own header, in
order to make it easier to keep an overview and to avoid
having to recompile ~all UI code when the class is
modified.
Add missing includes/forward declarations in places
previously depending on transitive includes that
are now dropped.
Change-Id: I3215b358e0fa45ffce08756218c386e1a4d7ebc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205928
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Move the class out of weld.hxx into its own header and
source file, in order to make it easier to keep an overview
and to avoid having to recompile ~all UI code when the class
is modified.
Change-Id: I91bae842e5b18a83db45de12150c21f75e537fb9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205900
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
If bSetNumRule and bSetNumRuleAfterSpace are set then auto formatting is
applied whenever space is pressed on a line with only two characters in
order to convert the two characters to a bullet point if applicable.
However this would also end up running all of the other auto-format
options such as removing trailing spaces. These aren’t designed to be
executed in the middle of editing a paragraph so it would end up
removing the space that the user just tried to type. This patch fixes
that by disabling any unrelated flags in SvxSwAutoFormatFlags before
executing the auto formatting so that only the bullet point formatting
will be applied.
A new method is added to SvxSwAutoFormatFlags to reset all of the flags
to false so that the bullet code can re-enable the relevant ones. In
order to avoid having a long list of assignments that is likely to get
out of sync as new options are added, the flag members of
SvxSwAutoFormatFlags are now declared using a macro that can be reused
to define the assignments.
Change-Id: I33155f45ba6cfd316222ad4d552beeb7979f8f4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205225
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
The autocorrect functions take as arguments an abstract interface to a
document and a string reference containing the text for the paragraph
being updated. The string needs to be a reference to the actual text
used for the document because the functions rely on it being
automatically updated when modifications are made to the paragraph. This
causes problems when redlines are enabled and the text comes from a
MergedPara because some operations can cause the MergedPara to be
recreated. The SvxAutoCorrect::DoAutoCorrect function has many
workarounds to try and fix this problem. The one from the commit below
tries to fix it for the case where a small group of autocorrect
functions can all be run together by making a temporary copy of the
string. This isn’t ideal because the different functions can no longer
see the result of the other functions. This is particularly bad for the
Esperanto hat function that was added after the patch was created. For
example “cxu” at the start of a sentence will be corrected to “Cu”
instead of “Ĉu” beause the word capitaliser can’t see the result of the
esperanto hat function adding the hat so it only capitalises the letter
“c”.
To fix this this patch adds a method to SvxAutoCorrDoc to get the latest
version of the paragraph text. That way each function can query the
string at the start and it won’t matter if it comes from a recreated
MergedPara. Ideally I think we should eventually move all autocorrect
functions to use this method and then remove the rTxt parameter to make
the code a bit more robust.
commit 22baeb9f9e
Author: Andras Timar <andras.timar@collabora.com>
Date: Thu Mar 19 10:19:21 2026 +0100
sw autocorrect: fix use-after-free with track changes enabled
Change-Id: Id407be018bdfa31c6f4642a9503c65e4c9e736d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205235
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
When typing after a period in a document with tracked changes,
AutoCorrect's FnCapitalStartSentence (and other functions) modify
the document via rDoc.Replace. With track changes enabled, this can
cause the text frame's text to be freed and reallocated, making
the rTxt reference passed to DoAutoCorrect a dangling pointer.
Subsequent autocorrect functions (FnCapitalStartWord,
FnChgToEnEmDash) then read from freed memory, causing heap
corruption detected as STATUS_HEAP_CORRUPTION on Windows.
Fix by making a local OUString copy of rTxt before the block of
autocorrect functions that can modify the document, and passing
the copy instead of the potentially-dangling reference.
Confirmed with Valgrind (Invalid read at svxacorr.cxx:590 in
FnChgToEnEmDash, called from DoAutoCorrect line 1717).
Change-Id: I5e3f2c8d4a1b7e9f0c6d3a2b8e4f1a7c9d5b3e6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202151
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 7fac4f1cbf880711f18084600f616aca2b326829)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205196
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
Adds an AutoCorrect option that corrects text like “sxangxigxis” to
“ŝanĝiĝis”. The former is a common alternative way to type the special
Esperanto letters when the user doesn’t have the right software
installed to type them properly.
Change-Id: I822f4239667bf60dad77e60497488e04514d46a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205066
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
After loading the autocorrect config, the code tries to unset all of the
flags that weren’t set in the config. However, it was using a hardcoded
magic number for the mask and this wasn’t updated when the DOI option
was added. This patch changes the magic number to be a constexpr that is
declared next to where the flag enum is declared to increase the
likelihood that future contributors will notice it if any more options
are added.
Change-Id: Ieadeb12613e61e57c02e10167cafdf04d6bbbe07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205042
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Move the class out of weld.hxx into its own header, in
order to make it easier to keep an overview and to avoid
having to recompile ~all UI code when the class is
modified.
Change-Id: I5b23b02151c75bb49831a2bbf8d515eb0b54415e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199068
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Trying to replace the manual management of settings in testTdf151801
with ScopedConfigValue, I found out that it broke other tests there:
C:/lo/core/sw/qa/extras/autocorrect/autocorrect.cxx(64) : error : Assertion
Test name: testTdf38394::TestBody
equality assertion failed
- Expected: l’«
- Actual : l‹ »
C:/lo/core/sw/qa/extras/autocorrect/autocorrect.cxx(45) : error : Assertion
Test name: testTdf92029::TestBody
equality assertion failed
- Expected: Ik ben ’s morgens opgestaan
- Actual : Ik ben ›s morgens opgestaan
It looked like restoring the settings in ScopedConfigValue dtor had
no effect. But manually testing the restored values using officecfg
demonstrated that it worked as expected: the optional value appeared
empty, as before the test.
It turned out, that the problem was in SvxBaseAutoCorrCfg::Load: it
listened to the registry changes, but only loaded new value, when
it was not empty, meaning that setting a non-empty value, and then
resetting it back to empty would keep the last non-empty value in
SvxAutoCorrCfg.
This change modifies SvxBaseAutoCorrCfg::Load to properly handle
empty values. Booleans are now checked using Any::operator==(bool),
which checks the type. For other values, the usual operator >>= is
used, which is simply no-op for empty Any.
testTdf151801 is modified to use ScopedConfigValue.
Change-Id: Ia3f413583541cde482db234fe73d7f665be507ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198502
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Found after running bin/find-unneeded-includes --headersfwd include/vcl/[q-w]*
This shaves off about 100M input
Change-Id: Ib4d0af44b383d34d856a9797fe70a974b359402f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196398
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
This is in preparation of moving code out of weld.hxx
to separate headers/source files, in order to make it
easier to keep an overview and to avoid having to
recompile ~all UI code when anything changes.
Also move weldutils.cxx to a new vcl/source/weld
directory.
Change-Id: Ia75b42f21e560dd248307282a522f186a64cd742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195777
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Replace by operator[], begin() and end(), which don't have overhead
since commit 2484de6728 (Remove non-
const Sequence::begin()/end() in internal code, 2021-10-15)
and commit fb3c04bd19 (Drop non-const
Sequence::operator[] in internal code, 2021-11-05).
Change-Id: I221470b3439bb0dc6e7705b0d99deb3cd2063484
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195176
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
and
cid#1660521 Variable copied when it could be moved
cid#1660513 Variable copied when it could be moved
cid#1660502 Variable copied when it could be moved
cid#1660458 Variable copied when it could be moved
cid#1660399 Variable copied when it could be moved
cid#1660300 Variable copied when it could be moved
cid#1660011 Variable copied when it could be moved
cid#1659730 Variable copied when it could be moved
cid#1659713 Variable copied when it could be moved
cid#1557959 Variable copied when it could be moved
Change-Id: I974cda301c10ce5c5c79a95d3ef0453195a9e31d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195053
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
When using Autocorrect->Apply, styles were applied unconditionally.
Add a second checkbox to allow disabling "Apply styles" in that case.
Change-Id: I4891f906b5518f518f3ac3e256e21392ade3f824
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190955
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@collabora.com>
... but don't skip the [All] (LANGUAGE_UNDETERMINED) list. See bug 141773
and commits ae56dc05b2 (tdf#96787: AutoCorrect:
after deleting a replacement entry, it's still used, 2021-01-10) and
50be3fa1f0 (tdf#141773 AutoCorrect: fix broken
[All] dictionaries, 2024-06-29).
A separate issue is that the languags list in autocorrect options now lists
[Multiple] and [Undetermined], which shouldn't be there (the latter is the
same as [All]). It needs an own bug and a separate fix.
Change-Id: I1de8879c892efec23ce976b9e450088a22fdd652
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191643
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
It uses the argument to pass to sorted_vector::find; and that can use
the string view instead of OUString.
Change-Id: I9c31aadae82a0dd1d28969ce073a6acc9e5729b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191585
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
cache LocaleDataWrapper because otherwise we spend quite a bit of
time doing function-pointer-symbol lookups.
Change-Id: Ic1bd07dabac95a2e1bdad70cffbc2b4cabdc62ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183221
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
There are two sets of getters there; and the non-const ones may copy
the COW mpImplFont, and may call its AskConfig.
The name overload is unfortunate. It is not obvious at the call site,
which of the two will be called; and what is different. IMO, the way
to fix it would be to keep only one set of getters (the const one),
and make the call to AskConfig explicit (in the places that set font
name, and know that resolution of other properties will be needed).
But in this change, I only rename the non-const getters, making sure
to keep the behavior unchanged (at least the intention is to have a
non-functional change, meaning that the places that called non-const
overload, now use the renamed functions), to make it clear where we
actually may copy and initialize it.
Change-Id: I9a5cd91d5c1c0de7ff8577b9b982d165e4cdd2c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183116
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
we can just take a "const &".
(found by running clang-tidy with the
performance-unnecessary-copy-initialization warning)
Change-Id: I20fd208c65303da78170b1ac06c638fdf3aa094b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176267
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This ctor is meant to set the value of nTime directly; and that value
is not nanoseconds, but an encoded value, using SEC_/MIN_/HOUR_MASK.
But in some places, this ctor was misused for setting of nanoseconds,
which would only accidentally work for values less than one second.
All places that initialized tools::Time with 0, now use EMPTY.
This makes the ctor private; and for the very few cases where really
the encoded value of nTime is stored / restored, fromEncodedTime is
introduced.
Change-Id: I1f1994bd9aab1b51a41b1de637619049fe820da4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175283
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This patch allows tools::PolyPolygon to be iterated using c++11's
fancy range-based for-loops. It also upgrades a bunch of old-style
for-loops iterating over polypolygons to the new style to make code
more readable.
Note that not all for-loops iterating over polypolygons have been
upgraded, as I didn't find a way to automatically find those. I just
did a few I found manually.
Change-Id: Ifa8d0d44e6f0aa28fdcfd87d70058b12f48c1349
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168730
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
SvxAutoCorrDoc::ChgAutoCorrWord() implementations: correct multiple patterns
* include/editeng/svxacorr.hxx, editeng/source/misc/svxacorr.cxx:
- Add classes SvxAutocorrWordList::{Iterator,WordSearchStatus}.
- Make SvxAutocorrWordList::SearchWordsInList() return WordSearchStatus
so the search can be continued with the added
SvxAutocorrWordList::SearchWordsNext() method.
- Make SvxAutoCorrect::SearchWordsInList(), and its lcl_SearchWordsInList()
companion, return WordSearchStatus propagated from
SvxAutocorrWordList::SearchWordsInList().
- SvxAutocorrWordList::WordMatches():
The existing mechanism of preventing collision of patterns like in
tdf#83037 (→ and ← and ↔ autocorrect collisions) was by storing
the matched string of wildcard pattern back to the list without
overwriting existing one. If the matched string was found in the list,
it would just be treated as no matching.
While this worked well for collision prevention, it caused failure
on the new exhaustive wildcard pattern visiting method when autocorrecting
the second text chunk with the same content. In such situation,
all intermediate stages of corrections of the first text chunk would be
recorded into the list. And, in the second chunk, the first stage would
just be applied from the recorded pattern, but all the next stages
would be refused due to the "collision" with the recorded patterns.
Moreover, the new method would cause the list to grow more quickly
as the autocorrections are done.
To solve the problem, just "peek" for the collision instead of
actually storing it. And SvxAutocorrWordList::ContainsPattern()
is added for this purpose.
* editeng/qa/unit/core-test.cxx:
- Modify TestAutoCorrDoc::ChgAutoCorrWord() to iterate through all patterns,
instead of finishing at the first one.
* editeng/source/editeng/edtspell.cxx:
- Ditto for EdtAutoCorrDoc::ChgAutoCorrWord().
* sw/source/core/edit/acorrect.cxx:
- Ditto for SwAutoCorrDoc::ChgAutoCorrWord().
- SwAutoCorrDoc::ChgAutoCorrWord(): Remove old dead code for autocorrection
on text with redlines.
* sw/qa/extras/uiwriter/uiwriter6.cxx,
+sw/qa/extras/uiwriter/data/tdf158454.odt:
- Add unit test "testTdf158454".
Change-Id: I8fb4a628a977b79b0ed2f239fd3749f15823b5df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160160
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>