summaryrefslogtreecommitdiff
path: root/sw/source/core/undo/undobj1.cxx
AgeCommit message (Collapse)Author
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>
2019-10-01Avoid redundant IsAtEnd: NextItem returns nullptr iif iterator is at endMike Kaganski
To keep the check efficient, split NextItem to inline and Impl parts Change-Id: Id5877a3c5bed73aac9c39c655b106a715cf888ea Reviewed-on: https://gerrit.libreoffice.org/79894 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-09-28loplugin:constmethod in swNoel Grandin
Change-Id: I73c3c6d2165287d2d581a04b23b1d3b48166a488 Reviewed-on: https://gerrit.libreoffice.org/79780 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-28sw: prefix members of SwUndoFlyBaseMiklos Vajna
See tdf#94879 for motivation. Change-Id: I266ba820629ec6f8505d091fb6090ed8626b4742 Reviewed-on: https://gerrit.libreoffice.org/78211 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-08-21sw: prefix members of SwUndoDelLayFormatMiklos Vajna
See tdf#94879 for motivation. Change-Id: I16fe75a5a7fd586e021cd5d49676031b97838165 Reviewed-on: https://gerrit.libreoffice.org/77867 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2019-08-01tdf#126168: sw undo/redo crash fixedVasily Melenchuk
After undo of style creation we have a dangling pointers to deleted style in SwUndoSetFlyFormat. So instead of keeping pointers to SwFrameFormat which can be invalidated, we could keep style name and find style by name. Change-Id: I9a60d6b3311278d7391d676010c31c862189fd08 Reviewed-on: https://gerrit.libreoffice.org/76351 Reviewed-by: Michael Stahl <Michael.Stahl@cib.de> Tested-by: Jenkins
2019-05-14tdf#42949 Fix IWYU warnings in sw/source/core/inc/[t-w]*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I7cd9837360e244741bfa22b4693fd221241daf12 Reviewed-on: https://gerrit.libreoffice.org/71833 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-03-25sw: prefix members of SwUndoSetFlyFormatMiklos Vajna
Change-Id: I64701255f3c0d0eb05e9962819deaef9aa8127c3 Reviewed-on: https://gerrit.libreoffice.org/69644 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2018-12-08Remove obsolete SAL_FALLTHROUGH completelyStephan Bergmann
...after 7ffdd830d5fb52f2ca25aa80277d22ea6d89970b "HAVE_CPP_ATTRIBUTE_FALLTHROUGH is always true now" Change-Id: I54e5ff4e036a6bb3e5774d1c0524158aae18e937 Reviewed-on: https://gerrit.libreoffice.org/64800 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-16loplugin:buriedassign in swNoel Grandin
Change-Id: If2adf22a0ac3e030fca1b4ecd0173cac58f0f21e Reviewed-on: https://gerrit.libreoffice.org/63470 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-03-26use boost::optional in swNoel Grandin
instead of std::unique_ptr, where we end up needlessly putting small objects separately on the heap Change-Id: I107421e7530c9580869b7a0f088ea7b0514bcf36 Reviewed-on: https://gerrit.libreoffice.org/51863 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-01-25introduce SwClient::EndListeningAll()Bjoern Michaelsen
- this is to reduce the use of GetRegisterdIn(), which should be an implementation detail - remove SwTOXMark::DeRegister() which did the same for a part of the class tree - remove SwUndoSetFlyFormat::DeRegisterFromFormat(), same - remove doubletracking FrameDeleteWatch::m_bDeleted, just check GetRegisteredIn() Change-Id: Id9364076759446ee5ff1898683c3ca700c1014c9 Reviewed-on: https://gerrit.libreoffice.org/48548 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
2018-01-12More loplugin:cstylecast: swStephan Bergmann
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable loplugin:cstylecast for some more cases" plus solenv/clang-format/reformat-formatted-files Change-Id: I0f49d21dfdf82742f11b27709f74294feb1e419e
2017-09-13Enable -Wunreachable-codeStephan Bergmann
...motivated by <https://gerrit.libreoffice.org/#/c/41565/2> adding dead code at the end of a switch statement, after the last case's "break". -Wunreachable-code appears to work well on Clang, while it appears to have no effect on GCC. Most of the affected places are apparently temporary/TODO/FIXME cases of disabling code via "if (false)", which can be written with an extra set of parentheses as "if ((false))" to silence -Wunreachable-code on Clang (which thus needed loplugin:unnecessaryparen to be adapted accordingly). In some cases, the controlling expression was more complex than just "false" and needed to be rewritten by taking it out of the if statement to silence Clang. One noteworthy case where the nature of the disabled code wasn't immediately apparent: Sep 12 16:59:58 <sberg> quikee, is that "if (false)" in ScExponentialSmoothingDialog::ApplyOutput (sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx) some work-in- progress or dead code? Sep 12 17:02:03 <quikee> sberg: WIP, but you can remove it Sep 12 17:04:47 <sberg> quikee, I'll wrap the false in an extra set of parentheses for now, to silence -Wunreachable-code (I wouldn't want to remove it, as I have no idea whether I should then also remove the "Initial value" comment preceding it) Sep 12 17:07:29 <quikee> sberg: both are different ways to calculate the "intital value"... so no Another case where the nature of the dead code, following while (true) loops without breaks, is unclear is sd/source/ui/remotecontrol/BluetoothServer.cxx, where I added TODO markers to the workarounds that silence the warnings for now. basic/source/sbx/sbxvalue.cxx had a variable of type double, of automatic storage duration, and without an initalizer at the top of a switch statement. Clang warning about it is arguably a false positive. Apart from that, this didn't find any cases of genuinely dead code in the existing code base. Change-Id: Ib00b822c8efec94278c048783d5997b8ba86a94c Reviewed-on: https://gerrit.libreoffice.org/42217 Tested-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-08-04loplugin:constparams in sw part5Noel Grandin
Change-Id: I6c33709aa407ccb3eee7026ab9b40dc4257de209 Reviewed-on: https://gerrit.libreoffice.org/40769 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-21tdf#108867 sw: fix dangling text box frame format pointers in UndoMichael Stahl
If the text box is removed, the SwFrameFormat of the drawing shape still retains a pointer to the frame SwFrameFormat, and the latter is owned by the SwUndoFlyBase. This is pretty bad, so try to clear & reset the connection between them in SwUndoFlyBase::InsFly() and DelFly(). Hopefully nothing will actually delete the drawing shape SwFrameFormat while the Undo object is alive. Note that when the SwUndoInsLayFormat is created when the text box is added, the GetOtherTextBoxFormat() returns null as it's set later, that's why the constructor can't do anything. Change-Id: Iae562b6f8f272e47b2b5cf8ee80778db15d29ce0
2017-07-02loplugin:casttovoid: swStephan Bergmann
Change-Id: I224e9995962901e8740bfaed06d57f7c0389236c
2017-05-12coverity#1406101 Dereference null return valueCaolán McNamara
and coverity#1406100 Dereference null return value coverity#1406099 Dereference null return value coverity#1406098 Dereference null return value coverity#1406097 Dereference null return value Change-Id: I26d5c0f2e69dc049a87a607ca28586dc575a8ca3
2017-05-10tdf#107512 sw: fix rollback of text attributes in SwUndoDeleteMichael Stahl
The problem is that in SwUndoDelete::UndoImpl(), first the formatting attributes are restored via TmpRollback(), and then all footnote/fly attributes are restored via Rollback(). This means that the SwHistory doesn't actually store the original positions of the formatting hints; ideally there wouldn't be 2 separate steps here, but that appears difficult to change now given the plethora of calls to DelContentIndex() ... So work around the problem by adding a new SetAttrMode::NOHINTEXPAND to prevent expanding the existing hints when the CH_TXTATR_BREAKWORD are inserted from SwUndoDelLayFormat. This fixes 2 problematic cases: at the start of the paragraph, and if the hint ends at the position before the CH_TXTATR_BREAKWORD. Let's hope this won't break anything anybody cares about. Change-Id: I557c4c9136f4225ca502019730fb9f0a9c03d23b
2017-05-03tdf#88555 sw: remove dynamic_cast from SwFrameFormats::ContainsMichael Stahl
This is a bad idea as the function is sometimes used to check if a SwFrameFormat has been deleted, which can happen in Undo, and for SwCallMouseEvent before commit 32403675bf9d2d0380956f9a82da71593edbb53c Replace with ContainsFormat() and IsAlive(), and don't require a non-const SwFrameFormat parameter. Change-Id: I87ede94dfbfe7f6985f13faab4c156015c3a5fc0
2017-04-10tdf#39468 Translate German comments in swJens Carl
Translate German comments and terms in sw/inc/ and sw/source Change-Id: I1330a358db2c6cdc0512009befeafa0582ac4877 Reviewed-on: https://gerrit.libreoffice.org/36288 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2017-03-22loplugin:redundantcast find redundant c-style enum castsNoel Grandin
Change-Id: I2dab376d87804521aed6b6bd41ad7762830fa349 Reviewed-on: https://gerrit.libreoffice.org/35467 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-20convert RndStdIds to scoped enumNoel Grandin
Change-Id: I029ad67dfcbc40f3953adf485957efcbd97f23d0 Reviewed-on: https://gerrit.libreoffice.org/35328 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-16convert SwUndoId to scoped enumNoel Grandin
Change-Id: I782fdd53641c0d7c629265b6179de70aa54382f9 Reviewed-on: https://gerrit.libreoffice.org/35246 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-23Revert "used std::map in SfxItemSet"Noel Grandin
This reverts commit 2757ee9fe610e253e4ccc37423fa420004d0f388. Besides causing a performance regression, I now notice that there is code in SW that relies on iterating over two different SfxItemSet's in parallel, and assumes that missing items are returned as nullptr, which is not the case for my std::map based change. Change-Id: I2b1110350fe4c4b74e5508558e9661ef1e1a103e
2017-01-18new loplugin: useuniqueptr: sw part 2Noel Grandin
Change-Id: Ifa901f75072d8474d8a97ca57c2b5b48d8c6b79d Reviewed-on: https://gerrit.libreoffice.org/33250 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-17used std::map in SfxItemSetNoel Grandin
instead of naked array SfxItemIter ended up needing to take copies of stuff because various code likes to iterate over the items and delete items inside the loop. The gdb pretty printer is no longer quite as pretty as it was before, but it still prints useful info. Change-Id: I59b07ea42f6b1c74798a15402970b9dbd8233dbe
2016-12-04use proper message passingBjoern Michaelsen
Change-Id: I1ee686ff96615f7b8aa69c0cd4caafaae07318b7 Reviewed-on: https://gerrit.libreoffice.org/31493 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2016-12-04use proper message passingBjoern Michaelsen
Change-Id: I0c6610308f75a57e517b233db66c66b34eb25189 Reviewed-on: https://gerrit.libreoffice.org/31492 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2016-08-29Convert SwFrameFormats to boost::multi_indexJan-Marek Glogowski
This is almost the same situation as SwPageDescs. What makes this more complicated is the fact, that actually duplicated draw objects are allowed, in regard to the key values "type" and "name". And actually for some types, duplicate names are not allowed, e.g. SwDoc::FindFlyByName( const OUString& rName, sal_Int8 nNdTyp ) expects a single result! Change-Id: I6e0ea1099c1c1e6cfe90926170e27179722e88b8
2016-07-29sw undo: implement SfxUndoAction::GetViewShellId() interfaceMiklos Vajna
With this, it's possible to tell which view shell created which undo actions. It's visible only in the doc model xml dump only, though. Change-Id: Ia76d218a1d8b578aaad00ab733c772b10dda39f0 Reviewed-on: https://gerrit.libreoffice.org/27693 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2016-05-10Replace fallthrough comments with new SAL_FALLTHROUGH macroStephan Bergmann
...which (in LIBO_INTERNAL_ONLY) for Clang expands to [[clang::fallthrough]] in preparation of enabling -Wimplicit-fallthrough. (This is only relevant for C++11, as neither C nor old C++ has a way to annotate intended fallthroughs.) Could use BOOST_FALLTHROUGH instead of introducing our own SAL_FALLTHROUGH, but that would require adding back in dependencies on boost_headers to many libraries where we carefully removed any remaining Boost dependencies only recently. (At least make SAL_FALLTHROUGH strictly LIBO_INTERNAL_ONLY, so its future evolution will not have any impact on the stable URE interface.) C++17 will have a proper [[fallthroug]], eventually removing the need for a macro altogether. Change-Id: I342a7610a107db7d7a344ea9cbddfd9714d7e9ca
2016-04-18cppcheck: silence known condition warning in sw undobjJochen Nitschke
Change-Id: Iedbb6bbdcdccf4ea44a7ad4d2e11ce630431034f Reviewed-on: https://gerrit.libreoffice.org/24210 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
2015-11-25bin/rename-sw-abbreviations.shlibreoffice-5-1-branch-pointRobinson Tryon
This commit renames the most annoying abbreviations in Writer (and partially in the shared code too). Change-Id: I77e5134f42f25e3786afa36b7a505c7e3237a9e8
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
Change-Id: I01e11fa956a249974e77dce9deebe79311f098d0
2015-10-20loplugin:defaultparamsStephan Bergmann
Change-Id: I11ff551955c1ac291ab576f2f18c2dd410427eda
2015-10-01remove old standalone Sun bug numbersNoel Grandin
Sun bug numbers without any accompanying text are completely useless. Fixed with git grep -lP '//\s*#\d+#\s*$' | xargs perl -i -ne'/\/\/\s*#\d+#\s*$/d or print' And then hand-checking the result to restore places where it deleted code. And then some more grepping and hand-editing to kill the others. Change-Id: Ia96ce4466db8bb8da363ebf41f0ae7f45f28bf29 Reviewed-on: https://gerrit.libreoffice.org/19023 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2015-06-08loplugin:cstylecast: deal with remaining pointer castsStephan Bergmann
Change-Id: I8d27ae80d209159690182ab91e272cf00e9f863d
2015-05-20bin/rename-sw-abbreviations.shlibreoffice-5-0-branch-pointChristian Lohmaier
renames the most annoying abbreviations in Writer (and partially in the shared code too). Change-Id: I9a62759138126c1537cc5c985ba05cf54d6132d9
2015-05-11loplugin:cstylecast: nop between pointer types of exactly same spellingStephan Bergmann
Change-Id: I0e42e757a6f7b0c28758193aad8b3cb01607b8b1
2015-05-05loplugin:staticmethodsNoel Grandin
Change-Id: I90dd921077bbfc57200e398e7959306f26c65cfe
2015-05-03tdf#89783: Adjust to new GetPos retval (size_t vs. sal_uInt16)Katarina Behrens
Some of the usages of GetPos were just misusing it to find out whether a vector contains given element -- use Contains() in those cases This patch is partially based on work of Christoph Lutz Conflicts: sw/source/filter/ww8/wrtw8esh.cxx sw/source/filter/ww8/wrtw8num.cxx Change-Id: I40bedba905e7577ba23f69acee178e0ea7cc1521
2015-03-26const_cast: convert some C-style casts and remove some redundant onesStephan Bergmann
Change-Id: Icb14a036ea9d7636359b6bc5e0af17568c0d54cb
2015-01-22Merge common code of sw format listsJan-Marek Glogowski
Moves the common code of Fmt based lists and simple vector lists into two intermediate template classes, of which one provides the SwFmtsBase interface. Change-Id: If963c19293584654a3d17438221e3fca8bdfd4f9 Reviewed-on: https://gerrit.libreoffice.org/13448 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2014-11-26loplugin: cstylecastNoel Grandin
Change-Id: I19be8b6df10515e195a4d3ecb8f003c85d2349c2
2014-11-25loplugin: cstylecastNoel Grandin
Change-Id: I9f9fef666ee22c54d923f24ce862151d32f4a5a7
2014-11-19Use SwNode::GetTxtNode()Miklos Vajna
Change-Id: Icf3e1013d5eba5702badf19aa6c1f5e6708ed154
2014-11-09do not break encapsulation of SwFmtAnchor::GetCntntAnchor()Luboš Luňák
Change-Id: I0a320eb990f9a3b6800447a97a84c118239bae96
2014-10-24coverity#705269 Missing break in switchCaolán McNamara
Change-Id: I49eb09156b3e8d3f68c13c3acd8696cdf841c109
2014-08-12Refactored IDocumentLayoutAccess out of SwDoc.Valentin Kettner
Into the new class DocumentLayoutManager. Change-Id: I02d0cfcc63633d0bdab380508b2ef563187fd269