summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docbm.cxx
AgeCommit message (Collapse)Author
2023-10-20Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: swStephan Bergmann
Change-Id: I85fff7ed6932c5fc196e18f24fa01074ba4837e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158241 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-05-16tdf#154956 sw: delete bookmarks at end: fix crashtestingJustin Luth
This fixes LO 7.6 commit 21b1dd42e9a817ae9b68e9e13ea57ce2491940c6 wget https://bugs.documentfoundation.org/attachment.cgi?id=124859 \ -O ~/tdf99692-1.odt ./instdir/program/soffice --headless --convert-to odt ~/tdf99692-1.odt sw/source/core/crsr/pam.cxx:268: void SwPosition::SetContent(sal_Int32): Assertion `nNode.GetNode().GetContentNode() && "only valid to call this if we point to an SwContentNode"' failed. Change-Id: Ic8280bf56f1e7f339fdff3e9591470bc74aa0d5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151639 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2023-04-25tdf#154956 sw: delete bookmarks at end if whole node is selectedJustin Luth
Exposed by LO 7.2.2 commit 4bf04dea9afb30a9395e80b07a81d1908937ee8b Author: Michael Stahl on Fri Aug 27 14:38:18 2021 +0200 tdf#128106 sw: copy bookmarks at start if whole node is copied Change-Id: I9205463f9beb3704eeb63fe7556103230ba7283d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150772 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-03-27sw: fix assert due to inconsistent ordering of MarkManager::m_vAllMarksMichael Stahl
In function: std::pair<_FIter, _FIter> std::equal_range(_FIter, _FIter, const _Tp&, _Compare) [with _FIter = gnu_debug::_Safe_iterator<gnu_cxx:: normal_iterator<sw::mark::MarkBase**, vector<sw::mark::MarkBase*, allocator<sw::mark::MarkBase*> > >, debug::vector<sw::mark::MarkBase*>, random_access_iterator_tag>; _Tp = SwPosition; _Compare = {anonymous}::CompareIMarkStartsBefore] Error: elements in iterator range [first, last) are not partitioned by the predicate __comp and value __val. Change-Id: I2c78d64dc6e87ba1aae0dd08a0ece01b0c43e9fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149553 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-02-11sw: rename getFieldmarkFor() to getInnerFieldmarkFor()Justin Luth
The same change was made for getBookmarkFor() in https://gerrit.libreoffice.org/c/core/+/145412 Because otherwise it's quite confusing that we have a For() and an At() which could only be differentiated by a code read. Also improve getInnerFieldmarkFor() a tiny bit, so we process the first hit only once. Suggested at <https://gerrit.libreoffice.org/c/core/+/145348/1#message-286262286f234823b390e8f962e3ba11f5fa71b2>. Change-Id: I47e815eea0b8ac0df4957ac0d224acb6c5975b8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145486 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2023-01-30tdf#151548 sw content controls: keyboard navigation with tab keyJustin Luth
Combine content controls with legacy formfield controls in keyboard tab navigation. MS Word (I tested 2010) is extremely irrational and inconsistent in its behaviour, so I modeled my implementation on the specification and general logic, and not at all on "compatible misbehaviour". There is a third category of form control (activeX rich content), but these are mapped to internal LO controls that are only exposed at VCL level, and don't pass the keystrokes back to SW. Plus, they are not inline, but fly controls. However, it is still a TODO to handle these if reasonably possible. Change-Id: I1fef34d05a779e9d4f549987238435acb6c043d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146219 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-01-25sw: send LOK call back on bookmark deletionPranam Lashkari
this helps with zotero when user deletes a bookmark or use undo without this online will be unaware of any such changes made by user Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: Id5ea4ee0ee1d16c399460cd177ec8e33256ce3dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145777 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit ea112b6d85a6914e1df40e064cd5df6d46248d68) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146022 Tested-by: Jenkins
2023-01-24related tdf#151548 formfield navigation: loop to beginning/endJustin Luth
When reaching the end of the form using keyboard navigation, the next tabstop should return the user to the beginning of the form. This patch adds that to the existing legacy formfield navigation. I'll wait with a unit test until I have added activeX/contentControls into the mix. Change-Id: I24a15a60f5a0a2721f512cca50397efddcbf7e4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146035 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2023-01-18sw: rename getBookmarkFor() further to getOneInnermostBookmarkFor()Miklos Vajna
One additional complexity I missed is that there can be only one innermost fieldmark for a position, but there can be multiple bookmarks, because bookmarks don't have a starting dummy character. See <https://gerrit.libreoffice.org/c/core/+/145412/2#message-85a4780c8140038a9cc2bd4b9af64ecf97ee5e60>. Change-Id: Ia5d3bebddd42be7c44b8df2d5db3c5312285a5f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145699 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-01-13sw: rename getBookmarkFor() to getInnerBookmarkFor()Miklos Vajna
Because otherwise it's quite confusing that we have a For() and an At() variant as well, and it would be less clear what happens in For() when there are multiple matches. Also improve getInnerBookmarkFor() a tiny little, so we process the first hit only once. Suggested at <https://gerrit.libreoffice.org/c/core/+/145348/1#message-286262286f234823b390e8f962e3ba11f5fa71b2>. Change-Id: If068f93e6934c9fc042760c03aac866fe5b50bd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145412 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-01-11sw lok: expose name of bookmark under cursorMiklos Vajna
It was possible to get the names of all bookmarks, but you could not get the name of the (innermost) bookmark under the current cursor. Getting the name of the current bookmark is useful for Zotero: if we already have a citation and want to insert one more, then we should turn the current citation into a citation cluster. Fix the problem by adding an API similar to what commit bb20dee2ef1b0804065e1cda2c834d257fdd90ed (sw lok: expose field type & command of fieldmark under cursor, 2023-01-05) did, but here we deal with bookmarks, not fieldmarks. Handle the actual bookmark lookup in MarkManager, such functionality looks useful outside LOK as well. Change-Id: Ic5b9b36fda243c5d7d360fa03745b3e121b67b06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145323 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-30tdf#126788 no need to dynamic_cast twice hereNoel Grandin
Change-Id: I78ce9bb7a56d99fcfdb2e705898991995368a079 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142030 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-27add a commentNoel Grandin
Change-Id: Iefaf4124327f89277605b1092da2db8b28ef05e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141913 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-27crashtesting: fix PDF export of tdf98567-1.docxMiklos Vajna
Importing tdf98567-1.docx crashed with debug STL since commit 47bc36c0f87ec2d0329260bcb98d62c7667a5dd1 (sw: make sure mark container is sorted before calling equal_range(), 2022-10-24). The problem is that sw::mark::MarkManager::deleteMark() calls DeregisterFromDoc(), which can call selection change listeners, which may mutate the container. Fix the problem by delaying the DeregisterFromDoc call using an ILazyDeleter for DDE bookmarks. Change-Id: Ia4e8ec379dc0c597db8fe5d91d55af09363350c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141907 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-10-24sw: make sure mark container is sorted before calling equal_range()Miklos Vajna
ooo89390-1.doc from crashtesting failed to export to ODT due to this. The trouble is that equal_range() needs a sorted container, but a listener may make the container unsorted. Fix the problem by re-sorting the container after calling the listener. A full ODT export is not needed to trigger the crash, it's enough to hide deletions. Change-Id: Id5601d7659d534c0bbfa84845abf0e6bb8e94c6f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141765 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-18tdf#151548 sw: use provided name for formfieldsJustin Luth
This was already aded for TextFieldmark in 2018 via tdf#120225. (A unique name is created if that mark already exists.) Added it to the other formfield items. This is needed for DOC/DOCX import, and is critical for connecting macros to the control. mstahl said that DateFieldmark is not a valid MS formfield, and miklosv indicated no likely value in preserving a name there. There is also NonTextFieldmark and FieldmarkWithDropDownButton, but they just look like implementation gadgets to me so I didn't give them the same treatment. No need for a unit test here. This is super foundational - anything else building on it will be the unit test. Change-Id: Ide49d6efb8391fea17e7a61c9e99b30532bb2014 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141423 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-10-18sw: fix crash on deleting a bookmark with active selection listenersMiklos Vajna
The document had a registered selection listener that created UNO cursors (bookmarks) in its selectionChanged() callback. Once an UNO API user tried to delete a bookmark, Writer crashed. What happens is that sw::mark::MarkManager::deleteMark() created an iterator pointing to an element of m_vAllMarks, then called sw::mark::Bookmark::DeregisterFromDoc(), which indirectly calls SwXTextView::NotifySelChanged(), which invokes UNO selection listeners, which are allowed to create UNO cursors, which modify m_vAllMarks, invalidating the iterator. Fix the problem by first creating a non-const iterator based on ppMark, then conditionally invoke DeregisterFromDoc(). If DeregisterFromDoc() is called, then update the iterator based on pMark, so it is valid by the time we erase the bookmark from m_vAllMarks. This was not the problem when erasing the same mark from m_vBookmarks, as in that case the iterator creation and the erase() both happen before the de-registration. Change-Id: Iaae95ec9c3038e8ee3b84408094844d0ff678213 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141489 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-13sw: improve duplicated bookmarks in copied header/footer textMiklos Vajna
Bookmarks in copied text were renamed in a way that made it hard to differentiate between the original bookmark and the copy, e.g. "Bookmark 1" was renamed to "Bookmark 11". Bookmarks are supposed to have a unique name, so renaming makes sense, and it's probably better to do that compared to what commit 3ec224dcb15e0e663ba85077b8ea0e632f8f03f8 (DOCX import: avoid duplicated bookmarks in copied header/footer text, 2022-09-08) did to just omit them during copy. That solved the duplicated bookmarks, but if one had bookmarks around images to find them, now it doesn't work to find all such images. Fix the problem by going back to copying bookmarks, but copy "Bookmark 1" as "Bookmark 1 Copy 1" (and "Bookmark 1 Copy 2", etc), so API users can identify the original and the copied bookmarks. A similar problem is there for images as well, but that's not yet addressed here. Change-Id: Ic0689b05f790a99ff06523ff4836b1dd412af896 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141293 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-09-25unwrap SwInsText to a plain SfxHintBjoern Michaelsen
- also add some constnesss and move some things to private Change-Id: I67a45e1326361b5a8f7e320b3525e74e93b1ef12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140556 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2022-09-10crashtesting tdf135070-01.odtNoel Grandin
asserts with ./instdir/program/soffice --headless --convert-to pdf ~/tdf135070-1.odt ever since commit 0f0cc045e06c8f3cd3f9780054f2259c6a0995f7 use more SwPosition::Assign Change-Id: I653a3136e46fde12b3e31bacec7f44695b0e1329 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139749 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-31use more SwPosition::AssignNoel Grandin
part of hiding the internals of SwPosition Change-Id: I1f96b39094ea833ff742b5933fda610ef211997d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139118 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-31use more SwPosition::AssignNoel Grandin
part of hiding the internals of SwPosition Change-Id: I2010f2d46504d858cbe7451515e56d31e9c22a7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139119 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-27crashtesting ooo117844-1.docxNoel Grandin
regression from commit 59785c0237f2bc5eaf9e9742bdf30136f3b3d2ba Author: Noel Grandin <noelgrandin@gmail.com> Date: Mon Aug 15 15:24:32 2022 +0200 pass SwNode and sal_Int32 to delBookmarks Change-Id: I2d552cf1bc70850e09b354e11644d59013061377 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138935 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-25use SwNode instead of SwNodeIndex in CorrAbs/CorrRelNoel Grandin
part of the process of hiding the internals of SwPosition Change-Id: Id00dc63fd30ea9cf015b9d5f69ee8eb82dc52228 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138834 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-23sw: enable Replace with Protect BookmarksMichael Stahl
The dialog calls Replace on the whole bookmark, and with commit 7974cea6c788e02d7c36573e2d10dcc51884f70e the bookmark is preserved, so the HasReadonlySel() should not prevent this replace from happening. Change-Id: I823b042c8327c6716b2ac1a8a86beffd887e6e4c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138693 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-19use more SwPosition::GetContentIndexNoel Grandin
part of the process of hiding the internals of SwPosition Change-Id: Iaf038c006fc9f82073664536278aac4d44754340 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138512 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-18convert more nNode to SwPosition::GetNodeNoel Grandin
in places where we are using the result with operator< Change-Id: I3440d1204e69e30f21eaf833c2d0c42cde59e55c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138454 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-17convert more nNode to SwPosition::GetNodeNoel Grandin
in places where we are using the result with operator< Change-Id: I2aae14e9130efc31f5afd3450defdf6df4099950 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138403 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-17convert more nNode to SwPosition::GetNodeNoel Grandin
in places where we are using the result with operator== Change-Id: I28f8f6fa2c3754ec6612ab2334c3a58b61ecd065 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138401 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-16pass SwNode and sal_Int32 to delBookmarksNoel Grandin
instead of SwNodeIndex and SwContentIndex. Part of the process of hiding the implementation of SwPosition. Change-Id: Ic70cbf9bd72f7544bcc24a2ebc2f588d5efd9231 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138316 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-15pass SwNode and sal_Int32 to deleteMarksNoel Grandin
instead of SwNodeIndex and SwContentIndex. Part of the process of hiding the implementation of SwPosition. Change-Id: I290fbc14d738d1bbf5d3f613eae6d114fc7cda17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138271 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-14rename SwPaM::GetContentNode to GetPointContentNode/GetMarkContentNodeNoel Grandin
Using a parameter to select point/mark makes the code much harder to read Change-Id: Ic24098a6045ff2262d4c808228ded7bf8206fe8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138085 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-06make CheckNodesRange take a SwNode, not an SwNodeIndexNoel Grandin
as part of the process of hiding the internals of SwPosition Change-Id: If8e9426df4b78ebf95bbac54ebfdcff4b19b6292 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137874 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-05introduce SwNodes::GoNext(SwPosition*) and similar GoPreviousNoel Grandin
as part of the process of hiding the internals of SwPosition These are still the easy ones, i.e. no functional change intended Change-Id: Ic1128d9e31fb87c015e1e9e66f5c365b3c2ebdca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137803 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-05use more SwPosition::AssignNoel Grandin
as part of the process of hiding the internals of SwPosition these are still the easy ones, i.e. no functional change intended Change-Id: Ibb2adf17de47bab5374730b508d9c020991a945e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137802 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-04add more SwPosition::AssignNoel Grandin
These are just the "obviously correct" places where we can use SwPosition::Assign, i.e. the places where we are already correctly setting both nNode and nContent in SwPosition. Change-Id: I27078c91e491c9162770ce729364197056d62cb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137775 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02introduce SwPosition::GetContentIndexNoel Grandin
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nContent.GetIndex' | xargs perl -pi -e 's/\bnContent\.GetIndex/GetContentIndex/g' Change-Id: I12684071a6666c365dbadbab2a4b37cf51b274d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137695 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02introduce SwPosition::GetNodeIndexNoel Grandin
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nNode.GetIndex' | xargs perl -pi -e 's/\bnNode\.GetIndex/GetNodeIndex/g' Change-Id: I3616cea4c47595afe74f1aa8e3be553279f25d44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137694 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02introduce SwPosition::GetNodeNoel Grandin
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nNode.GetNode' | xargs perl -pi -e 's/nNode\.GetNode/GetNode/g' Change-Id: Id1937df1bd5a54677c2c1bbfb2d693a4e22a7b98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137671 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-26no need to allocate hereNoel Grandin
Change-Id: I0d08ee6a54ad87097909f5dacfd7a08c1f4b6770 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137479 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-25rename SwIndex->SwContentIndexNoel Grandin
to help my poor brain with the different kinds of index we have floating around Change-Id: I47ed223922170687d7e07812445aed66b3218230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137404 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-17tdf#119840 reduce cost of SwPosition::operator<=Noel Grandin
by fetching Start/End from SwPaM at the same time reduces load time by 5% Change-Id: Ie4a06c667aa0950c04e98e46b30cdc4b97f75ba7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137147 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-01Use stable_sort for m_vBookmarksStephan Bergmann
Using a randomizing debug-mode libc++ (`export LIBCPP_DEBUG=-D_LIBCPP_DEBUG=1` in config_host.mk), where (among other things) the elements of a range passed to std::sort are randomly shuffled before being sorted, thus simulating a std::sort that actually behaves non-deterministically compared to std::stable_sort: CppunitTest_sw_uiwriter5 consistently failed for me with > uiwriter5.cxx:255:Assertion > Test name: testTdf140982::TestBody > assertion failed > - Expression: aType != "AnnotationEnd" || !bAnnotationStart when _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED is 140384686472728. Dumping the contents of xRunEnum in testTdf140982 (sw/qa/extras/uiwriter/uiwriter5.cxx), that randomized run has > Text "Lorem " > Redline IsStart=true > Annotation > Text "ipsum" > Redline IsStart=false > Redline IsStart=true > Annotation > AnnotationEnd <= the CPPUNIT_ASSERT failed here > Redline IsStart=false > Redline IsStart=true > Text " " > Annotation > Text "dolor" > Redline IsStart=false > Redline IsStart=true > AnnotationEnd > Redline IsStart=false > Redline IsStart=true > Text " " > Annotation > Text "sit" > Redline IsStart=false > Redline IsStart=true > AnnotationEnd > Redline IsStart=false > Text " amet" > Redline IsStart=true > AnnotationEnd > Redline IsStart=false > Text "..." whereas a stable_sort run would have > Text "Lorem " > RedLine IsStart=true > Annotation > Annotation > Text "ipsum" > RedLine IsStart=false > RedLine IsStart=true > AnnotationEnd > RedLine IsStart=false > RedLine IsStart=true > Text " " > Annotation > Text "dolor" > RedLine IsStart=false > RedLine IsStart=true > AnnotationEnd > RedLine IsStart=false > RedLine IsStart=true > Text " " > Annotation > Text "sit" > RedLine IsStart=false > RedLine IsStart=true > AnnotationEnd > RedLine IsStart=false > Text " amet" > RedLine IsStart=true > AnnotationEnd > RedLine IsStart=false > Text "..." which suspiciously has the Annotation tokens at different positions relative to the Text tokens, so something looks indeed broken. And when dumping (via ToString()) the content of m_vBookmarks in MarkManager::sortSubsetMarks (sw/source/core/doc/docbm.cxx; which is apparently called multiple times during that test) before and after sorting, there are often cases where multiple elements have the same node and index, so are placed into the same equivalence class by lcl_MarkOrderingByStart (assuming there are no sw::mark::CrossRefBookmark instances involved in this test, for which lcl_MarkOrderingByStart has special rules). I'm not exactly sure whether this use of stable_sort is indeed the right fix or just a workaround, and the real issue is that the equivalence classes of lcl_MarkOrderingByStart are too broad, or something entirely different yet. I'm also not sure whether similar uses of sort in MarkManager::sortSubsetMarks and MarkManager::sortMarks would also need to be changed to stable_sort. (At least, I didn't find any breakage with my randomizing debug-mode libc++ and `make check` that would point to one of those other non-stable sort calls.) Change-Id: I51040e43b906bd3f18219d3bd0d28e1ccee89897 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136717 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-05-19sw_fieldmarkhide: fix wrong handling of SwInsText for fieldmarksMichael Stahl
For redlines, typically DocumentContentOperationsManager::InsertString() will insert text, and it explicitly removes any redlines on the text that has been inserted, hence it is always visible - so effectively the sw::MergedPara is updated correctly. However for fieldmarks the situation is different, if the insertion happens inside of the part that is hidden in the layout, then it must not be inserted into the sw::MergedPara. Try to figure out which part(s) of a fieldmark the insertion position is in and ignore the inserted text as appropriate in SwTextFrame::SwClientNotify(). Change-Id: Ic5066b20e9609f50438ca64ac7d2cbd09baeef23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134611 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-04-20tdf#147723 sw_fieldmarkhide: fix crash when copying multiple fieldmarksMichael Stahl
The problem is the UpdateFramesForAddDeleteRedline() call in makeMark(), this is called in a loop for multiple fieldmarks and when it's called for the first one, of course the other ones aren't in the document yet, so HideIterator::Next() can't find them. But this is only needed when inserting a new fieldmark anyway, so just disable for copying. (regression from commit 92384a813176b964a67bcbeb2fa617c554dbc4a2) Change-Id: Ic1b34d469a553cf7bbf2d1a99edaea900bdd7417 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133215 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-04-05forcepoint#104 sw: do not delete fieldmark chars in MoveNodeRange()Caolán McNamara
The problem is that SwXTextTableCursor::mergeRange() wants to move some nodes, and the deleteMarks() deletes a fieldmark creating a SaveBookmark but it contains the positions relative to the CH_TXT_ATR_FIELD* still in the text, while deleting the fieldmark of course removes these. The SaveBookmark would need to adjust the indexes and store the separator position too and the vector would need to be restored in reverse order. But every time the SaveBookmarks are created, they are restored as well, so it looks simpler to just suppress deleting the CH_TXT_ATR_FIELD* in this case, and inserting them too (latter is already done when copying text). Change-Id: I690c6432a38eab6dec10adff74e638f0e52cca55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132531 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-03-14loplugin:trivialdestructor (-stdlib=libc++)Stephan Bergmann
That these are only flagged when building against libc++ and not against libstdc++ is a consequence of the plugin's dependence on implementation details of the relevant classes, but so be it. Change-Id: I6b96f81939edab2b8e618aa53c9fe23492edfbbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131562 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-02-02tdf#147008 sw_fieldmarkhide: fix invalid NonTextFieldmark positionsMichael Stahl
Commit ab6176e88f78d0b3aa2490fbc7858304c2d4a437 introduced a crash in ModelToViewHelper when the positions of a NonTextFieldmark are invalid. The NonTextFieldmark must always contain 1 CH_TXT_ATR_FORMELEMENT but after SplitNode() the position is (rr) p *pFieldMark->m_pPos1 $2 = SwPosition (node 10, offset 1) (rr) p *pFieldMark->m_pPos2 $3 = SwPosition (node 9, offset 0) This is because in ContentIdxStoreImpl::SaveBkmks() there is an asymmetry where the m_pPos2 is recorded to be wrongly corrected to node 9, but if the positions were swapped so that m_pPos1 is the start position, then it will not be recorded and remain in node 10. So fix this by changing the NonTextFieldmark to insert its CH_TXT_ATR_FORMELEMENT differently. There is some very subtle code in SwTextNode::Update() that is again asymmetric and (non-obviously) prefers to move m_pPos2 and leave m_pPos1 alone (by moving it to aTmpIdxReg) in case the positions are equal. But then the fieldmark code increments "rEnd" (which is really the m_pPos1 i.e. the start after InsertString() returns), and then decrements m_pPos2. So avoid the problem by removing these 2 pointless adjustments. Then it turns a bunch of tests fail because other code assumes that m_pPos1 is the end of the NonTextFieldmark, so fix MarkManager::changeFormFieldmarkType(), ModelToViewHelper and SwHistoryNoTextFieldmark to use GetMarkStart(). Change-Id: I7c82f9a67661121662c95727e0f8f15e06d85a3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129289 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-01-19sw: generalize ModelToViewHelper to handle all NonTextFieldmarksMichael Stahl
Rename getDropDownsFor() to getNoTextFieldmarksIn(). Move some code so that sw::mark::ExpandFieldmark can expand all fieldmarks that use CH_TXT_ATR_FORMELEMENT. Change-Id: I8a1e28fc0ad77df3a749d9e55c306cb45187a082 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128606 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-10-21introduce SwNodeOffset strong typedefNoel Grandin
for indexing into node children. Replaces various usage of sal_uLong, tools::Long, sal_uInt32 with an underlying type of sal_Int32. Also add a NODE_OFFSET_MAX constant to replace usage of ULONG_MAX Change-Id: I2f466922e1ebc19029bb2883d2b29aa4c0614170 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123892 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>