Bug 57646 - Autocorrect exceptions are not added when undo
Summary: Autocorrect exceptions are not added when undo
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
4.0.0.0.alpha1
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 75155 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-11-28 06:55 UTC by Urmas
Modified: 2017-08-15 11:02 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Urmas 2012-11-28 06:55:54 UTC
In 4.0-alpha1, undoing autocorrect changes does not add exceptions for Capitalize after and TWo initial caps lists.
Comment 1 Joel Madero 2012-12-11 16:48:26 UTC
Urmas: Can you provide step by step instructions? Even in easy cases we ask that easy and reproducible steps are provided so that devs/triagers know that they are doing EXACTLY what the reporter did to produce the bug.

Marking as NEEDINFO. Once you get the steps please reopen as UNCONFIRMED and I'll get it triaged
Comment 2 Urmas 2012-12-12 06:36:38 UTC
1. Type any unit with two capital letters. It will be autocorrected.
2. Undo the autocorrection
3. Type this unit again.

The undo function should add autocorrection exceptions, but it doesn't.
Comment 3 Marco Menardi 2012-12-29 21:05:59 UTC
I've tried with 3.6.x and 4.0.beta2 (Debian GNU/Linux 64), and checked what the help says about it, i.e. Tools -> autocorrect options -> [Exceptions] tab, the lower Autoinclude (the one related to "Words with TWo INitial CApitals" is flagged, and in the tab [Options], comumn "T", are flagged "Correct TWo INitial CApitals" and "Capitalize first letter of every sentence".
I can confirm this bug, the exception is not automatically added, and wondering if has ever worked and in what release
Comment 4 Jorendc 2012-12-29 21:44:16 UTC
Thanks for reporting!

I can reproduce that.
There are some major improvement in LO 4.0 and 4.1 on autocorrection. I hope the developers will pick this bug up.
Comment 5 A (Andy) 2014-10-18 08:28:40 UTC
Reproducible with LO 4.3.2.2 (Win 8.1)
Comment 6 Julien Nabet 2014-12-22 23:13:56 UTC
*** Bug 75155 has been marked as a duplicate of this bug. ***
Comment 7 Julien Nabet 2014-12-22 23:15:01 UTC
On pc Debian x86-64 with 4.4 sources updated today, I could reproduce this.
(I can't test right now with master sources because of a problem during building).
Comment 8 Julien Nabet 2014-12-22 23:57:22 UTC
Noticing LoadWrdSttExceptList (http://opengrok.libreoffice.org/xref/core/cui/source/tabpages/autocdlg.cxx#1483) after having fixed fdo#87581, I tried to unwind to find at which moment a word is added:

1) SvxAutoCorrectLanguageLists::AddToWrdSttExceptList http://opengrok.libreoffice.org/xref/core/editeng/source/misc/svxacorr.cxx#2205

2) SvxAutoCorrect::AddWrtSttException
http://opengrok.libreoffice.org/xref/core/editeng/source/misc/svxacorr.cxx#1482

3) SwAutoCorrExceptWord::CheckChar
http://opengrok.libreoffice.org/xref/core/sw/source/core/edit/acorrect.cxx#431

4) http://opengrok.libreoffice.org/search?q=CheckChar&project=core&defs=&refs=&path=&hist= giving 2 ways, I put in each of them and found this one was called:
SwUndoOverwrite::UndoImpl
http://opengrok.libreoffice.org/xref/core/sw/source/core/undo/unovwr.cxx#174

Then I noticed with gdb that we don't enter in "if( pACEWord )" block:
    186     SwAutoCorrExceptWord* pACEWord = pDoc->GetAutoCorrExceptWord();
    187     if( pACEWord )
    188     {
    189         if( 1 == aInsStr.getLength() && 1 == aDelStr.getLength() )
    190             pACEWord->CheckChar( *pAktPam->GetPoint(), aDelStr[0] );
    191         pDoc->SetAutoCorrExceptWord( 0 );
    192     }
A quick search in GetAutoCorrExceptWord indicates that it returns mpACEWord
This one can be set or deleted in docedt.cxx

In gdb, I could see that it's been set just after having typed space (after having typed a word like "IJfs") but it's deleted right after because of this part:
Breakpoint 5, SwDoc::DeleteAutoCorrExceptWord (this=0x55769f0) at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/docedt.cxx:797
797	    delete mpACEWord;
(gdb) bt
#0  SwDoc::DeleteAutoCorrExceptWord (this=0x55769f0) at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/docedt.cxx:797
#1  0x00002aaaccbb77e4 in sw::DocumentStateManager::SetModified (this=0x5581510) at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/DocumentStateManager.cxx:58
#2  0x00002aaaccbb5213 in sw::DocumentStatisticsManager::DocInfoChgd (this=0x557f6a0)
    at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/DocumentStatisticsManager.cxx:87
#3  0x00002aaacd417b69 in SwDocShell::DoFlushDocInfo (this=0x56d7870) at /home/julien/compile-libreoffice/libo_4_4/sw/source/uibase/app/docsh2.cxx:207
#4  0x00002aaaaec191e6 in SfxObjectShell::FlushDocInfo (this=0x56d7870) at /home/julien/compile-libreoffice/libo_4_4/sfx2/source/doc/objmisc.cxx:218
#5  0x00002aaaaec68bcf in SfxDocInfoListener_Impl::modified (this=0x39a88a0) at /home/julien/compile-libreoffice/libo_4_4/sfx2/source/doc/sfxbasemodel.cxx:170
#6  0x00002aaaaebb1863 in cppu::OInterfaceContainerHelper::NotifySingleListener<com::sun::star::util::XModifyListener, com::sun::star::lang::EventObject>::operator() (
    this=0x7fffffff38f0, listener=uno::Reference to (SfxDocInfoListener_Impl *) 0x39a88c8)
    at /home/julien/compile-libreoffice/libo_4_4/include/cppuhelper/interfacecontainer.h:265
#7  0x00002aaaaebad1ca in cppu::OInterfaceContainerHelper::forEach<com::sun::star::util::XModifyListener, cppu::OInterfaceContainerHelper::NotifySingleListener<com::sun::star::util::XModifyListener, com::sun::star::lang::EventObject> > (this=0x39a83b0, func=...) at /home/julien/compile-libreoffice/libo_4_4/include/cppuhelper/interfacecontainer.h:279
#8  0x00002aaaaeba9396 in cppu::OInterfaceContainerHelper::notifyEach<com::sun::star::util::XModifyListener, com::sun::star::lang::EventObject> (this=0x39a83b0, 
    NotificationMethod=&virtual com::sun::star::util::XModifyListener::modified(com::sun::star::lang::EventObject const&), Event=...)
    at /home/julien/compile-libreoffice/libo_4_4/include/cppuhelper/interfacecontainer.h:292
#9  0x00002aaaaeba1bf5 in (anonymous namespace)::SfxDocumentMetaData::setModified (this=0x39a8320, bModified=1 '\001')
    at /home/julien/compile-libreoffice/libo_4_4/sfx2/source/doc/SfxDocumentMetaData.cxx:2201
#10 0x00002aaaaeb9e57a in (anonymous namespace)::SfxDocumentMetaData::setDocumentStatistics (this=0x39a8320, the_value=uno::Sequence of length 8 = {...})
    at /home/julien/compile-libreoffice/libo_4_4/sfx2/source/doc/SfxDocumentMetaData.cxx:1777
#11 0x00002aaaccbb5b1c in sw::DocumentStatisticsManager::IncrementalDocStatCalculate (this=0x557f6a0, nChars=5000, bFields=false)
    at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/DocumentStatisticsManager.cxx:212
#12 0x00002aaaccbb5365 in sw::DocumentStatisticsManager::UpdateDocStat (this=0x557f6a0, bCompleteAsync=true, bFields=false)
    at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/DocumentStatisticsManager.cxx:124
#13 0x00002aaaccbb527f in sw::DocumentStatisticsManager::GetUpdatedDocStat (this=0x557f6a0, bCompleteAsync=true, bFields=false)
    at /home/julien/compile-libreoffice/libo_4_4/sw/source/core/doc/DocumentStatisticsManager.cxx:104

Commenting the if block line 56 in DocumentStateManager::SetModified
     56     if( m_rDoc.GetAutoCorrExceptWord() && !m_rDoc.GetAutoCorrExceptWord()->IsDeleted() )
     57         m_rDoc.DeleteAutoCorrExceptWord();
see http://opengrok.libreoffice.org/xref/core/sw/source/core/doc/DocumentStateManager.cxx#41
allows to retrieve mpACEWord and so to add the word in exception list

Now I'm a bit stuck since I don't know if the condition is wrong or if "m_rDoc.GetAutoCorrExceptWord()->IsDeleted()" should be true and that would mean that bDeleted isn't set to true somewhere.

Michael: any thoughts?

(Really sorry for this long comment, I just wanted to put the whole investigation)
Comment 9 QA Administrators 2016-01-17 20:03:46 UTC Comment hidden (obsolete)
Comment 10 QA Administrators 2017-03-06 14:14:52 UTC Comment hidden (obsolete)
Comment 11 Cor Nouws 2017-08-15 11:02:59 UTC
is ok in Version: 6.0.0.0.alpha0+
Build ID: 368b583b992f2e9cad46c2362c9529a07c36d7a9
CPU threads: 4; OS: Linux 4.10; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-08-10_02:55:46
Locale: nl-NL (nl_NL.UTF-8); Calc: group