summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/DocumentContentOperationsManager.cxx
AgeCommit message (Collapse)Author
2020-10-15tdf#136577 sw: fix Undo of Replace with nothingMichael Stahl
The UI doesn't allow to replace an empty selection anyway, but it now happens on Undo. (regression from e1629c210ad78310e3d48c0756723134a27b89df) Change-Id: I468f28335beaeb8c42df8ed4cfc90f2c03129239 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104308 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit d3eca4177a78c3db17b4699ea6e071e52488c46f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104305 Reviewed-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit ba5584a3ce86c2db52e2e4a4b91254741b2616ec) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104333 Tested-by: Michael Stahl <michael.stahl@cib.de>
2020-10-15tdf#135260 sw_redlinehide: fix insert-with-delete differentlyMichael Stahl
The problem with the fix for tdf#127635 is that now the cursor doesn't move left on backspace if change tracking is on. (regression from 398ba26077f9029bdf6f7378bfc9ce8376b6f02d) Revert that and fix the autocorrect position in SwWrtShell::Insert() instead. Change-Id: I5989a589b654fc6e5ba3dd66922af15eff758ecc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104280 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit be4616d6b49b8c9cf1a90b212b24ead3dabcab6c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104299 Reviewed-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 10c638e520096a0cc282d91ac2a447509f674a6f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104332 Tested-by: Michael Stahl <michael.stahl@cib.de>
2020-08-20tdf#135412 tdf#135888 sw: fix copying of linked text-boxesMichael Stahl
The resetLink()/restoreLinks() were added in commit 00a007be5ad88bac9905b373bc5e02d02acab11a because testMissingPath missing-path.docx was crashing. But then 0bcc5b3daebeb2a7d2b5ba132af4745cc6c78cd0 refactored how linking works and introduced the isTextBox function, which is called in the middle of DocumentContentOperationsManager::CopyFlyInFlyImpl() after resetLink(), and this now always returns false, the same for another call inside CopyLayoutFormat() (when called from CopyFlyInFlyImpl()), which causes text-boxes to be copied to 2 separate flys (tdf#135888). The problem in tdf#135412 is that somehow when called from SwFEShell::Paste() the content-index from the clipboard document ends up in the SwDrawFrameFormat that is created in the target document, and this causes crash in Undo because the node index is out of bounds. 10 SwUndoInsLayFormat::UndoImpl (this=0x7c2a760, rContext=...) at sw/source/core/undo/undobj1.cxx:310 (rr) p rContent.GetContentIdx()->GetNode().GetDoc()->IsClipBoard() (rr) $29 = true It turns out that missing-path.docx doesn't crash any more without resetLink(), and removing it fixes the 2 bugs. Change-Id: I0c6c91a42e00b9f3b79b774c814e7323f2bb3e05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101004 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 10ae7ba661dff57a7d08174792565ec5e33fae9b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100948 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-08-02tdf#134436 sw: fix SwUndoDelete::RedoImpl() with section at end...Michael Stahl
... of document; the root cause is that in some intermediate delete operation, the delete will remove a section start/end node pair that surrounds the last text node in the document, but SwUndoDelete::RedoImpl() will not remove it, thus for subsequent Undo actions the indexes are messed up and weird things happen. Fix this in DocumentContentOperationsManager::DeleteRangeImplImpl(), with the same weird "is point at the end" check as SwUndoDelete. Change-Id: Iebf20d3c129c69692df8d57e3c5b9e6fec281e4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99810 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 22a77cb83a3769a8b43d80565282988a74214866) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99858 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-07-30tdf#134250 sw_redlinehide: fix copy non-empty node before non-textnodeMichael Stahl
The problem in CopyImplImpl() is that pCopyPam's end position was updated to index 0 but text was copied into the node, which is thus not covered by pCopyPam and thus also not by SwUndoInserts. Then SwUndoInserts::UndoImpl() doesn't delete the bookmarks in the end node and the bookmark positions cause ~SwIndexReg asserts. Change-Id: I4cc03e846eae4cabd9eb4346a98c1e5c2866050d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99643 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 8ec8da5638ab465e69900a08067ad496bcb5d3d5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99778 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2020-07-22tdf#132911 sw_redlinehide: fix assert in CopyImplImpl()Michael Stahl
With Ctrl+A, Ctrl+X, Ctrl+V we get the bAfterTable = true case; line 4722 does pCopyPam->GetPoint()->nNode-- and then line 5085 does pCopyPam->GetPoint()->nNode++ but the problem is that nContent still points to the same node as initially while the node after the table end node is now a different one, i.e. nNode and nContent point to different nodes and something in redlining asserts becuase of that with "Assertion `m_pIndexReg == rIndex.m_pIndexReg' failed."; we don't get to step 4 anyway. (reportedly something changed with commit 4532845e22c10f252840887e55002307227b2390 but it's a mystery what that would be) Change-Id: I23744fad543e1e7bfcc11c4b488d4469ba9e509c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99166 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 14bdbc36f0cf3913f6de10c746044b6aadf37095) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99194 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2020-07-07tdf#134253 sw: fix SwUndoInserts::UndoImpl() if inserting before sectionMichael Stahl
Somehow the clipboard is pasted before the SwSectionNode, which is the first node in the body text. The OSL_ENSURE( !bStartIsTextNode, "Oops, undo may be instable now." ) is triggered; the Undo must remove 2 SwTextNode in this case. Because of the extra SwTextNode the indexes are off by 1 and this starts to assert since commit 24fd14b387dca458a1b6e9415e936d26562ddb1e when setting a fieldmark on a non-text node. Change-Id: Ic52b0f4c7665994cadfe8f074bc4607c55352aa1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97887 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit dc7e7b94a7211c576454267c09eb108e761e4487) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98078 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2020-07-01tdf#134099 sw: fix textbox anchors on copy-paste and undoMiklos Vajna
Regression from commit c7307c77254557646f33017af915f6808a861e29 (fdo#82191 sw::DocumentLayoutManager: copy textbox content of draw formats, 2014-08-15), without which this problem gets hidden, as copy breaks the textbox into 2 pieces, so the textbox codepaths are no longer hit. The direct problem is that SwHistorySetFormat::SetInDoc() uses a raw node index into the nodes array, which is past the end of the nodes array. Root cause is that we have this invariant that actions and their undo has to be in sync, otherwise raw node indexes no longer work. In this case, SwUndoSaveContent::DelContentIndex() did not delete a fly frame format, because it was out of range, as it had a wrong anchor. Fix this in SwTextFlyCnt::SetAnchor(), so that whenever the anchor of a draw format is set via that function, we update its textbox as well. Also fix a related problem when fly formats were copied twice. (cherry picked from commit 682e0488df819c191c13a03758fad0690706e508) Conflicts: sw/qa/core/txtnode/txtnode.cxx Change-Id: I0d6c9069544c405eb20c5fed65fb40423b0adc84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97515 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2020-06-20tdf#127635 sw_redlinehide: put point at the end of deletionMichael Stahl
SwWrtShell::Insert() is called with a selection, so it first calls DeleteAndJoin() to get rid of the selection. With redlining enabled, this leaves the cursor as it was before, so if the point was at the start it still is at the start, so the following Insert will insert at the start of the selection. But then AutoCorrect wants to do things and it uses TextFrameIndex and ViewToModelPos and gets a result at the end of the delete redline, while the cursor remains at the start of the delete redline. Avoid this by swapping the selection after DeleteAndJoin() (and also DeleteRange() for consistency) so that insertion happens at end of redline (swap "above" DoWithBreaks because it creates temporary PaMs). (regression from sw_redlinehide) Change-Id: Ib5b0475f610c2ce426e9202e9d325dd0cc451d5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96743 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 398ba26077f9029bdf6f7378bfc9ce8376b6f02d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96705 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-06-16tdf#133957 sw: SelectAll should select fly in empty sectionMichael Stahl
Ctrl+A should select everything in the section; if the section is empty, there's no text to select, and then the shell will cancel the selection because SwCursorShell::HasSelection() returns false - so check if there are flys anchored there, which fixes the Copy. To fix Delete, a few more checks for empty selection need to be changed. Change-Id: If54160bdca976ad5f153b89cf8492f4da1e774b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96324 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 2d89b9929e85bede4c72684a12e7508751875f0e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96368 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-06-12tdf#132254 sw: fix block selection copy reversed orderMichael Stahl
The problem is that SwEditShell::CopySelToDoc() relies on the passed target SwPosition being after the target range by CopyRange(), but due to an erroneous update of aInsPos in CopyImplImpl() it was at the beginning of the target range. (regression from 28b77c89dfcafae82cf2a6d85731b643ff9290e5) Change-Id: Ie0846bd44f9349517878efcca996440bede05611 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96063 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 63a43218c369a43624e6bdbe880b7caa40a3b61a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96092 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-06-11tdf#101856 copy missing bookmark propertiesSerge Krot
- in case of undo/redo - in case of copying bookmark Change-Id: Ia21f42973b0e7c2cc4abfe2febe9818509aec4d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96038 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-05-04tdf#132187 sw: fix creation of frames on end node in CopyWithFlyInFly()Michael Stahl
The problem is that the rInsPos node is included in the range passed to MakeFrames(), but it already has a frame, so now it has 2 and that means the next call to MakeFrames() in this position will create all the frames twice. This is tricky because while in practice there is currently only one layout in theory there could be multiple, and then it could happen that RecreateStartTextFrames() will destroy the node's frame in one layout but not the other, while MakeFrames() always works on all layouts. Fix this by checking if all the existing frames survive RecreateStartTextFrames() and if it's not the case (like in tdf#130685) explicitly delete all the frames and including the node in MakeFrames(). (regression from 166b5010b402a41b192b1659093a25acf9065fd9) Change-Id: I1bba11da053fe1c6359b2f76f3a352e44c6a2a1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93416 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 49f26e7dae550aff6ca90b3cda7f89e11ac8cfd4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93375 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-04-27tdf#132351 DOCX export: fix character formatting of numberingLászló Németh
with removed ListAutoFormat. Using untouched text portion of paragraph marker, DOCX export restored the changed character formatting of numbering with removed ListAutoFormat (see RES_PARATR_LIST_AUTOFMT in wrtw8nds.cxx). Follow-up of commit e4509d7db7562f7e4ab9366b915ed558291ac3de (tdf#127606 DOCX lists: fix unchangeable formatting) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92744 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry-picked from commit 7690f3269c89140930f49068133e7d061d475948) Change-Id: Ie576a204d86694296cb29185a5b130e87a518b7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92801 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2020-04-27tdf#127606 DOCX lists: fix unchangeable formattingLászló Németh
of numbering symbols. It was not possible to modify the character format of numbering symbols, if it is different from the format of the list item, handled by ListAutoFormat compatibility paragraph attribute and APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING compatibility setting. Now changing character attributes removes ListAutoFormat, if it is applied on wholly list item(s) during editing. See commit 5ba30f588d6e41a13d68b1461345fca7a7ca61ac (tdf#64222 sw: better DOCX import/export of paragraph marker formatting) and commit df07d6cb9f62c0a2c4b29bd850d4efb4fcd4790b (handle direct formatting for numbering in .docx (bnc#875717)). (cherry picked from commit 6287845eab339a8eb3c660d648d012e9f1dcce30) Change-Id: I60dae1b9c084d0804e453f54df5c6bbafe479869 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92534 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2020-04-22tdf#127109 Writer: fix Undo entry "Delete $1"László Németh
Regression from commit b69c518df68ce673b28d589da6626bd3d860f309 (tdf#54819 keep style & numbering at tracked deletion) Change-Id: I3041cc5a70d00bea14d7be1c275bb7d2a22e768a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92614 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit cfac976e27f310014dcd866000c874014fd6b173) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92531 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2020-04-05tdf#130685 sw_redlinehide: fix copying to position following redlineMichael Stahl
In DocumentContentOperationsManager::CopyWithFlyInFly(), first CopyNodes() also creates all layout frames, then SaveRedlEndPosForRestore fixes the end position of all redlines that were moved by CopyNodes() (they were moved not by changing their position but by inserting new nodes before their end position). Of course this means that the layout frames are created with redlines that have only a temporary end position, and then things go wrong when the end positions are adjusted, so add something similar to SwUndoDelete::UndoImpl() to recreate the frames in CopyWithFlyInFly(). This hit the assert: sw/source/core/text/redlnitr.cxx:94: std::unique_ptr<sw::MergedPara> sw::CheckParaRedlineMerge(SwTextFrame&, SwTextNode&, sw::FrameMode): Assertion `pNode != &rTextNode || &pStart->nNode.GetNode() == &rTextNode' failed. (regression from ... sw_redlinehide) Change-Id: I82e0f5b320cab201e762f58800f83e08f4f01048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91596 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 166b5010b402a41b192b1659093a25acf9065fd9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91523 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-04-05(related: tdf#130685) sw: fix ~SwIndexReg asserts from ...Michael Stahl
... lcl_DeleteRedlines(), if there are redlines immediately consecutive that get deleted; merge the SwPaM ring in that case which should help. Change-Id: I07b67413ad6ee52bc81b89facc40202d0ca75e2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91595 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 27aa4b16bf704d0246595750daf57b57ff2577b3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91522 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-02-07tdf#130362 sw: fix anchoring of inline math objectsMiklos Vajna
Regression from a7528cd6f17ea5c5b29e7d607e54c62de0d9e7db (sw: insert image: set anchor to at-char by default, 2019-11-18), that defaulted to at-char anchoring for charts and images. What was not considered is that math objects had a previous as-char default (not to-para), and that is supposed to be unchanged. (cherry picked from commit a2f85c062aafb3fd9dfb1c6c6e87e1e73e7545a3) Change-Id: I2a91af6425035b48a0e47ad9b10939945855cd16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87997 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
2020-01-21tdf#129582 sw: fix copying of flys in header/footer in DOCX/RTF importMichael Stahl
The problem is that the exception for writerfilter in IsDestroyFrameAnchoredAtChar() and IsSelectFrameAnchoredAtPara() is wrong in the case when the header/footer content is copied via SwXText::copyText(); that is, previously the situation was that writerfilter relied on Delete not deleting such flys (for RemoveLastParagraph) but Copy copying them. (regression from 28b77c89dfcafae82cf2a6d85731b643ff9290e5 and e75dd1fc992f168f24d66595265a978071cdd277) So restrict the writerfilter hack to delete; this causes a problem with ooxmlexport9 test testTdf100075: it has 2 flys anchored at the same paragraph; writerfilter will insert the content into the body and then convert to fly; when the 2nd one is converted it will copy the 1st fly and anchor it inside the 2nd fly but then unotext.cxx:1719 will reset its anchor to inside the body... Prevent this unwanted copy by relying on the new parameter bCopyText that was introduced in 04b2310aaa094794ceedaa1bb6ff1823a2d29d3e, but change things a bit so that the case that pass in the extra flag isn't the copyText() one that wants the *normal* selection semantics in writerfilter import, but the 2 known places that want the *exceptional* selection semantics in writerfilter import (hopefully there aren't more). This is not ideal and the various bool parameters to CopyRange() plus mbCopyIsMove plus mbIsRedlineMove should probably be consolidated into some flags enum passed to CopyRange(). Change-Id: I638c7fa7ad0b4ec149aa6a1485e32f2c8e29ff5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87072 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 81ec0039b2085faab49380c7a56af0c562d4c9e4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87095 Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-01-21DOCX import: fix lost objects anchored to an empty linked headerMiklos Vajna
This is really similar to commit 04b2310aaa094794ceedaa1bb6ff1823a2d29d3e (DOCX import: fix lost objects anchored to the single para of a linked header, 2020-01-10), except here the header is not just a single-paragraph one, but has no text portions. Update text-copy.docx to have a header which is not only a single paragraph, but also has no character content. This keeps testing the original case, but now also tests the more strict case (single paragraph -> single empty paragraph). Change-Id: I11bb062e77af1a83f717225ea5b4daef39e5a672 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86552 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit c12358166a9bd88fe10feabca45a6ad3f65dff8e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87123 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2020-01-21DOCX import: fix lost objects anchored to the single para of a linked headerMiklos Vajna
Regression from commit 08f13ab85b5c65b5dc8adfa15918fb3e426fcc3c (tdf#112202 writerfilter,sw: fix loss of headers, 2019-12-16), the problem is that on one hand, copyText() is meant to copy a complete XText (header, table cell, footnote, etc), OTOH the internal API use used only copies at-para anchored objects for complete text nodes, so a one-paragraph header will loose its anchored objects when a linked header is copied. Introduce a new "CopyText" flag that provides the expected copyText() behavior and use that when the copyText() UNO API is invoked, but leave the selection behavior unchanged. Perform the inclusive check in IsSelectFrameAnchoredAtPara(), opt in for that from SwXText::copyText(), the rest is just passing the flag around. Change-Id: Id727f7ca4f6121a7050340359716a52ecb4886f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86529 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit 04b2310aaa094794ceedaa1bb6ff1823a2d29d3e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87122 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-12-08Fix heap-use-after-freeStephan Bergmann
...after 91b2325808a75174f284c48c8b8afc118fad74e4 "tdf#121300 sw: consistent fly at-pargraph selection", as seen with ASan during UITest_writer_tests6 (see also <https://ci.libreoffice.org/job/lo_ubsan/1472/>): > ERROR: AddressSanitizer: heap-use-after-free on address 0x6040006ec168 at pc 0x7f75b9ee9c81 bp 0x7f75d168a410 sp 0x7f75d168a408 > READ of size 4 at 0x6040006ec168 thread T41 (cppu_threadpool) > #0 in SwFormatAnchor::GetAnchorId() const at sw/inc/fmtanchr.hxx:65:44 > #1 in sw::DocumentContentOperationsManager::CopyImplImpl(SwPaM&, SwPosition&, bool, SwPaM*) const at sw/source/core/doc/DocumentContentOperationsManager.cxx:4863:30 > #2 in sw::DocumentContentOperationsManager::CopyImpl(SwPaM&, SwPosition&, bool, SwPaM*) const at sw/source/core/doc/DocumentContentOperationsManager.cxx:4432:16 > #3 in sw::DocumentContentOperationsManager::CopyRange(SwPaM&, SwPosition&, bool, bool) const at sw/source/core/doc/DocumentContentOperationsManager.cxx:1868:16 > #4 in SwFEShell::Paste(SwDoc*) at sw/source/core/frmedt/fecopy.cxx:1038:62 [...] > 0x6040006ec168 is located 24 bytes inside of 40-byte region [0x6040006ec150,0x6040006ec178) > freed by thread T41 (cppu_threadpool) here: > #0 in operator delete(void*, unsigned long) at /home/sbergman/github.com/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:172:3 > #1 in SwFormatAnchor::~SwFormatAnchor() at sw/source/core/layout/atrfrm.cxx:1473:1 > #2 in SfxItemPool::Remove(SfxPoolItem const&) at svl/source/items/itempool.cxx:741:13 > #3 in SfxItemSet::~SfxItemSet() at svl/source/items/itemset.cxx:252:42 > #4 in SwAttrSet::~SwAttrSet() at sw/inc/swatrset.hxx:161:20 > #5 in SwFormat::SetFormatAttr(SfxPoolItem const&) at sw/source/core/attr/format.cxx:541:5 > #6 in sw::DocumentContentOperationsManager::CopyImplImpl(SwPaM&, SwPosition&, bool, SwPaM*) const at sw/source/core/doc/DocumentContentOperationsManager.cxx:4861:27 > #7 in sw::DocumentContentOperationsManager::CopyImpl(SwPaM&, SwPosition&, bool, SwPaM*) const at sw/source/core/doc/DocumentContentOperationsManager.cxx:4432:16 > #8 in sw::DocumentContentOperationsManager::CopyRange(SwPaM&, SwPosition&, bool, bool) const at sw/source/core/doc/DocumentContentOperationsManager.cxx:1868:16 > #9 in SwFEShell::Paste(SwDoc*) at sw/source/core/frmedt/fecopy.cxx:1038:62 [...] Change-Id: I7a31e9dbb6fa1cdf938420a9a949b125c66e3ce2 Reviewed-on: https://gerrit.libreoffice.org/84683 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> (cherry picked from commit 546cbc9182589e9fec1dc0a23f1af07ddfbc576c) Reviewed-on: https://gerrit.libreoffice.org/84691 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-12-07ofz#18563 sw: fix 2 problems with field marksMichael Stahl
* sw::CalcBreaks had a thinko in that a separator that had a start but no matching end wasn't reported * DocumentContentOperationsManager::DelFullPara() may apparently be called with a rPam having just one position, in which case expanding it doesn't work. Change-Id: I6503498dd38d188799385aa706ffe7dfccfdba08 Reviewed-on: https://gerrit.libreoffice.org/84662 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 522ed1b685f5b7eb52efb9d874dfacc02bf82139) Reviewed-on: https://gerrit.libreoffice.org/84692 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-12-06tdf#121300 sw: consistent fly at-pargraph selectionMichael Stahl
As a follow-up to commit 28b77c89dfcafae82cf2a6d85731b643ff9290e5, add IsSelectFrameAnchoredAtPara() function and use it to harmonize at-para fly selection across all relevant operations: * CopyImpl: - it had a pre-existing bugs that would lose a fly anchored to the 2nd (1st fully selected) node of a redline - remove a bunch of code for finding the last node of the body content, which doesn't matter for the remaining at-fly checks - flys that already existed at the insert position need to have their anchors corrected * DeleteRange: - get rid of the bDelFwrd checks * MoveRange: - the ALLFLYS flag would be obsoleted by the new selection, were it not for the writerfiler "special hack", see below * also adapt A11y and UI selection, SwRootFrame::CalcFrameRects() The selection behavior is changed: * the bDelFwrd case is quite odd, some code was checking whether a deletion was "forward" or "backward" and removing only the flys at the point node while retaining the flys at the mark node; this worked in a very non-obvious way relying on sw_GetJoinFlags actually calling Exchange() on the cursor, and then SwUndoDelete stored it in m_bJoinNext, but it turns out that only SwUndoMove also has a m_bJoinNext and it's dead, and no other Undo has such a flag, so this only worked for "delete". It's not obvious what the value of this is, let's just ignore the "direction". * Selections exclude the start and end position except if it's a fully selected node or at the start or end of a section (i.e. Ctrl+A should also select every at-para fly). * An exception is made in case the selection looks like it's a backspace/delete joining 2 paragraphs; flys are not deleted in that case because it seemed annoying (and as it happens, Word does not appear to delete flys in that case), particularly if both of the nodes are already empty. This is done with a heuristic, it's conceivable to pass down some flag from DelLeft()/DelRight() but probably this is good enough. A special hack is needed to keep writerfilter happy for now; it likes to anchor flys at nodes which it then deletes in RemoveLastParagraph(), which likely could be improved there. The ALLFLYS usage in SwRangeRedline::MoveFromSection() could be removed (because the end-of-section check already handles the case) except for this, because it turns out that the ODF import runs SetRedlineFlags with a temporarily reset IsInXMLImport() flag because of its effect in thints.cxx, so during the move IsSelectFrameAnchoredAtPara() can't check it. tdf#108124 scenario works better, now everything that's selected is both copied and deleted. Fixes the problem where an at-para fly at the 2nd node of a redline where the 1st node is partially deleted was lost on ODF export. Change-Id: I168013665e70ff0a5f198e09f3fa3afc06ba0449 Reviewed-on: https://gerrit.libreoffice.org/84576 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 91b2325808a75174f284c48c8b8afc118fad74e4) Reviewed-on: https://gerrit.libreoffice.org/84621
2019-11-23sw: check fieldmark overlap in SwpHints::TryInsertNesting()Michael Stahl
This is a follow-up to bd2ada701aad2c4e85d03cd8db68eaeae081d91c, which added the check for nesting hints in MarkManager::makeMark(). Change-Id: Ife847a677514fb1aeb28dc8d6254caea365b754d Reviewed-on: https://gerrit.libreoffice.org/83388 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit ab90d83d73b701747a56e09f71e3609a92378504) Reviewed-on: https://gerrit.libreoffice.org/83424 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-11-20ofz#18554 sw: fix Null-dereference due to overlapping fieldmarksMichael Stahl
The problem is that the WW8 import wants to set a fieldmark on a range that contains only the CH_TXT_ATR_FIELDEND of another fieldmark: (rr) p io_pDoc->GetNodes()[12]->m_Text.copy(33,10) $30 = "\bÿÿÿ\001ÿÿÿ\001 " MarkManager::makeMark() must check that a new fieldmark never overlaps existing fieldmarks or meta-fields. While at it, it looks like the test in DocumentContentOperationsManager::DelFullPara() can't necessarily use the passed rPam, because it obviously deletes entire nodes, but at least SwRangeRedline::DelCopyOfSection() doesn't even set nContent on rPam. Also, the check in makeMark() triggers an assert in CppunitTest_sw_uiwriter testTextFormFieldInsertion because SwHistoryTextFieldmark::SetInDoc() was neglecting to subtract 1 from the end position for the CH_TXT_ATR_FIELDEND. Change-Id: I46c1955dd8dd422a41dcbb9bc68dbe09075b4922 Reviewed-on: https://gerrit.libreoffice.org/83000 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit bd2ada701aad2c4e85d03cd8db68eaeae081d91c) Reviewed-on: https://gerrit.libreoffice.org/83268 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-11-05tdf#42949 Fix IWYU warnings in sw/source/core/d*/*cxxGabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Id33b8c1e0c02c21591b167a8b3f0ea288fac63bd Reviewed-on: https://gerrit.libreoffice.org/81689 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-10-31sw: copy bookmarks in SwDoc::CopyPageDescHeaderFooterImpl()Michael Stahl
When importing tdf113521-1.doc, a footer is copied, but the fieldmark in it is not copied, so there are CH_TXT_ATR_FIELD* in the copy without matching fieldmark, and the result is sw/source/filter/ww8/wrtw8nds.cxx:2342: virtual void MSWordExportBase::OutputTextNode(SwTextNode&): Assertion `pFieldmark' failed. Change-Id: I42b005e22b57f181e4e8bc52afb053546db5f741 Reviewed-on: https://gerrit.libreoffice.org/81792 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-28cid#1455157: sw: Memory - illegal accesses (WRAPPER_ESCAPE)Michael Stahl
(regression from b522fc0646915d4da94df38dd249c88b28f25be7) Change-Id: I54f93ac16a2d4ddc687937d44c3aec450e59dd0e Reviewed-on: https://gerrit.libreoffice.org/81588 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-23sw: fix buildMichael Stahl
should have just reverted that patch... Change-Id: I17c8517a0dfd500423a6cd185abb89f40164daa9
2019-10-23sw: fix copying of fieldmarks in lcl_CopyBookmarks()Michael Stahl
Surprisingly this handles CHECKBOX_FIELDMARK differently than the others but clearly it's a bug not to copy a fully selected TEXT_FIELDMARK as seen in CppunitTest_sw_ooxmlexport testMultiPageToc, where a header is copied with its CH_TXT_ATR_FIELD* but not the fieldmark. Change-Id: Ibf4d934ea834c1ac9fe4e541259605a745246049 Reviewed-on: https://gerrit.libreoffice.org/80914 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-23sw: DocumentContentOperationsManager::CopyImpl()Michael Stahl
Change-Id: I1a6ce9f439be9b8f863f3981fb9fd7ef1123e6c7
2019-10-23sw: DelFullPara() and MoveRange() shouldn't do anything...Michael Stahl
Change-Id: I34bcbf4d601dd96e13efec513e8a001865f3065f Reviewed-on: https://gerrit.libreoffice.org/80071 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-23sw: maintain fieldmarks in DeleteRange()/DeleteAndJoin()/ReplaceRange()Michael Stahl
Avoid overlapping deletes of the CH_TXT_ATR_FIELD*. Change-Id: I0cbfcfbc8f39c029e7faefa39e75fce7e7e4b9e2 Reviewed-on: https://gerrit.libreoffice.org/80070 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-22loplugin:constantparamNoel Grandin
Change-Id: Ibfe70492683ff3ec208cee95d8a11155ec54f690 Reviewed-on: https://gerrit.libreoffice.org/81314 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-04sw: add DocumentContentOperationsManager::DeleteDummyChar()Michael Stahl
... and lcl_RemoveFieldMarks() uses it; this avoids the problem that lcl_CalcBreaks() would of course remove the dummy character from the deletion range. Change-Id: Iba0f7901b9efe4af273e17c58c6b40d4fd783efd Reviewed-on: https://gerrit.libreoffice.org/80069 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-04sw: remove dead branches in DocumentContentOperationsManagerMichael Stahl
Change-Id: I481b993c54fbd06d399193d0d75212599ca6fa78 Reviewed-on: https://gerrit.libreoffice.org/80048 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-04sw: Overwrite() should ignore CH_TXT_ATR_INPUTFIELD*Michael Stahl
Change-Id: I8c5b3d8f9d3c16f45b1b958a566121308cbf0468 Reviewed-on: https://gerrit.libreoffice.org/80047 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-01Drop SfxItemIter::FirstItemMike Kaganski
It is always used right after the iterator is created, where simple GetCurItem gives the same value without reseting the position. Change-Id: I871dc7989b79e13f06436ef7928692645b5209f6 Reviewed-on: https://gerrit.libreoffice.org/79903 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-09-01Fix '..'Andrea Gelmini
To complete this: https://gerrit.libreoffice.org/#/c/78312/ This is a massive replace for lines ending with ".." instead of "..." It passed "make check" on Linux. Change-Id: I07fa7b2e30ba9ea17a1f9a5e21c57216ba958efe Reviewed-on: https://gerrit.libreoffice.org/78356 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
2019-08-09tdf#126626 sw: fix duplicate SwUndoInsLayFormat in single-node CopyMichael Stahl
Fly Undo created later in SwUndoInserts::SetInsertRange(); suppress it in DocumentContentOperationsManager::CopyImpl(). (regression from 28b77c89dfcafae82cf2a6d85731b643ff9290e5) Change-Id: I3b8756c20a7472029748d9e64a941320fc10b19f Reviewed-on: https://gerrit.libreoffice.org/77190 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
2019-08-07Fix typosAndrea Gelmini
Change-Id: Ie48d61e07ce44a3022b92cd295527b65532a64e7 Reviewed-on: https://gerrit.libreoffice.org/76773 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
2019-07-22tdf#117185 tdf#110442 sw: bring harmony & peace to fly at-char selectionMichael Stahl
Use IsDestroyFrameAnchoredAtChar() to harmonize the at-char fly selection across all relevant operations: * CopyImpl: this is the most tricky one: - the code in CopyWithFlyInFly() and CopyFlyInFlyImpl() is quite con- voluted as it needs to do some things ignoring a partially selected start node, while including it in other cases - it had pre-existing bugs too that would lose a fly anchored to the 2nd (1st fully selected) node of a redline - now it needs to copy the flys in the selection if it is inside a single node - another complication is that flys that already existed at the insert position need to have their anchors corrected - SwUndoInsLayFormat need to be created for the appropriate flys - SwUndoInserts Undo/Redo needs to run the nested SwUndoInsLayFormat at the appropriate time - SwUndoInserts::UndoImpl() needs a special case to *never* delete flys at the start/end of the selection because those are handled by nested SwUndoInsLayFormat - Insert File (shellio.cxx) needs adapting to the SwUndoInserts change * DeleteRange: this just needs to delete the flys via DelFlyInRange() * MoveRange: - this is used by the old SwRangeRedline Show/Hide, i.e. on ODF export - the SaveFlyInRange()/RestFlyInRange() was rather inadequate and didn't even restore content indexes at all... * IsShown: the sw_redlinehide code needs to check visibility against the (inverted) extents The selection behavior is changed so that at-char flys in the start and end node of the selection are also selected, instead of having their anchor moved to a different content index by the operation. This appears more obvious and user-friendly, fixes tdf#110442, and is also more like what Word does. Selections exclude the start and end position except if it's a fully selected node or at the start or end of a section (i.e. Ctrl+A should also select every at-char fly). A special hack is needed to keep writerfilter happy for now; it likes to anchor flys at nodes which it then deletes in RemoveLastParagraph(), which likely could be improved there (disposing the SwXParagraph runs into the same problem...). Crashes fixed by this: tdf#117185 tdf#117215 except comment#12 tdf#124720 tdf#124721 tdf#124739 Previously fixed bugs tested: i#97570 plus the 2 bugs that already have UITests Change-Id: I4fec2a3c15ca0e64e5c4e99acfb04f59bb2bcf64 Reviewed-on: https://gerrit.libreoffice.org/75516 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
2019-06-24tdf#54819 keep style & numbering at tracked deletionLászló Németh
and direct paragraph formattings after wholly deleted paragraphs. Clean-up and extension of the previous workaround, now with Undo. See commit 22639148ae5400bac98f32a75d7431b857c80195 "change tracking: keep paragraph style after full deletion" and commit 23c159d948af360baecfe243e1321987760916d7 "change tracking: don't copy page break". (Note: the first fixed the numbering, the second reverted it accidentally.) Change-Id: Ic97af3b171490b011523d1bae11f75aaf4baab54 Reviewed-on: https://gerrit.libreoffice.org/74299 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
2019-05-31tdf#125372 writer, file with lots of hints very slow to open, part8Noel Grandin
Takes load time from 22s to 15.5s sw::mark::IMark does not need to be held by shared_ptr - we have one vector, which holds all marks we created, and when we remove from that vector, which remove the other references too. Change-Id: Ie6d287d9d825f7129855b64a34afa81a2ef9c378 Reviewed-on: https://gerrit.libreoffice.org/73206 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-30tdf#125372 writer, file with lots of hints very slow to open, part7Noel Grandin
Takes load time from 1m45 to 22s Instead of (1) taking a list of SwTextAttrs (2) invoking a method that inserts a new one (3) taking a new list and doing a delta on the list, just the information about the new SwTextAttr up the stack and avoid all that work. Change-Id: Iec88618af696299aaba65f43bc33b1a5f030fac0 Reviewed-on: https://gerrit.libreoffice.org/73195 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-23convert nsRedlineType_t to scoped enumNoel Grandin
and move the auto-format embedded flag to a separate field Change-Id: I02155702389178fbfdf874f592d47a29f8759974 Reviewed-on: https://gerrit.libreoffice.org/72771 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-25WIP: Further preparations for deeper Item changesArmin Le Grand
(1) Migrated all still existing binary load/save stuff in SfxPoolItem to legacy files. Isolated from Item implementations. Adapted all usages. No more methods Create/Store needed, also GetVersion removed (2) Removed operator= for SfxPoolItem. Adapted all usages. Goal ist to handle Items more as Objects ('Object-Oriented') in the sense to move/handle instances, not to copy one instance over another one (which is more and more problematic with hard to copy content as UNO API stuff or similar). This lead to much more usages of std::shared_ptr which correlates well with future plans fr Items (see dev branch). Next logic step will be to also remove copy constructor Linux build and corrections done Fixed Writer test and removed unused defines Fixed another unused m,acro Started to unify the AutoFormat stuff Changes to OUString constructor usages, tests completely No idea why, but SfxStringItem constructor which takes a OUString& now insists of not getting ::OUString's handed in - changed all 'SfxStringItem.*OUString.*".*"' accordingly Change-Id: Ibed7358b18fb019994a7490332b9d797a6694c29 Reviewed-on: https://gerrit.libreoffice.org/71075 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2019-03-28tdf#42949 Fix IWYU warnings in include/sfx2/[e-M]*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I6e97c7ed6c0211dfafee83b9bdbea672e415fc49 Reviewed-on: https://gerrit.libreoffice.org/69715 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>