summaryrefslogtreecommitdiff
path: root/writerfilter
AgeCommit message (Collapse)Author
2024-02-06Related: tdf#159382 Naming is hard: make initial monster shorterMike Kaganski
Rename "NoSpaceAfterHangingFootnoteNumbering" and friends to "NoGapAfterNoteNumber". This is cleaner, no less descriprive. Change-Id: I87d3103e4ddfc05e5604eaa4fe707b1fd5711aae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162654 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162660 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2024-02-06tdf#159382: introduce a Word compat flag for hanging footnote number spacingMike Kaganski
The new 'NoSpaceAfterHangingFootnoteNumbering' compatibility option is false for ODF documents by default. Word file format filters set it to true. Its purpose is to avoid extra spacing between the footnote number and its text, when the paragraph has hanging first line, as in MS Word. Change-Id: I42d9353865498137ab99e1d2c031f5b207cbc220 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162603 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162636 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2024-02-05tdf#158814 DOCX import: fix unwanted header with type="first" & no titlePgMiklos Vajna
The bugdoc had no header in Word, but had one in Writer, since commit 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (DOCX import: first page header should always set default headers as well, 2014-11-21). The code has changed a log in the meantime, today we import first page headers and left/right page headers as a single page style, but still code was missing to detect the case when <w:headerReference w:type="first"> was not followed by <w:titlePg>, which is an indicator that the first page header/footer should be used. Fix the problem by new flags to SectionPropertyMap to track if we ever seen a first/left/right header. This allows making an informed decision in SectionPropertyMap::setHeaderFooterProperties(): if the header is on, but we effectively don't have none of a first, left or right header, then it's time to turn it off, similar to what the DOC import does. Note that this only changes behavior for headers, but if there is a practical need, then the same could be also done for footers as well. Instead of adding a new test, notice that testTdf112694 in CppunitTest_sw_core_header_footer explicitly tests this case: a first header which is not a title page. So change that testcase to assert the behavior now matches Word and drop the FIXME. Change-Id: Ib604e786d7a5a197d4b562533326206697de882a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162992 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit d918beda2ab42668014b0dd42996b6ccc97e8c3a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162907 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit af302ee34f74b4d71b1721d23f62225b7e66ff2e)
2024-02-02tdf#159107 sw floattable: prefer inline table in footnote with change trackingMiklos Vajna
Writer doesn't really support tables in footnotes, see the warning at the top of SwFlowFrame::MoveFwd(). Still, there is some initial support for them, since commit 11c51eefe8c3210cef2b5850f401ba67a401d01 (tdf#95806 tdf#125877 tdf#141172 DOCX: fix tables in footnotes, 2021-03-28). Similarly, redlines really just track insertion and deletion, but some initial support for table operations were added in commit eebe4747d2d13545004937bb0267ccfc8ab9d63f (tdf#144270 sw: manage tracked table (row) deletion/insertion, 2022-01-12). The combination of these is a bit fragile, but the bugdoc happened to be imported as an inline table (in a footnote, with recording changes) before commit d477fa8ac1b0d3ee81427217bbb5950278ab16db (sw floattable: unconditionally map <w:tblpPr> to SwFormatFlySplit, 2023-03-17). Fix the problem by explicitly importing floating tables as inline in the footnote + redline case to restore the working use-case. DOCX import of this combination can be enabled again once Writer layout works for the produced model. Change-Id: I9cd0a1fabb9807f5117cb5a36ec8597d6646eece Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162733 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit af15f8b7f346898677f1eee6521a6be1ff63eb56) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162716 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit d19f051dd4244bdfb58458d4287305b59c2915c6)
2024-01-23tdf#154703 writerfilter framePr: avoid unexpected frame bordersJustin Luth
This fixes my regressive 7.6 commit 31ea6305b6a763ee48f639562313d9bd109a2923 The text's first border checked (the left one) returned void because the property SetState was DONTCARE. Then it SETS the text's left border to be nothing (I presume to remove the border from the paragraph since it is moving it onto frame). Well, apparently that act of setting one border sets all of them (which makes sense since it would be one box item, and once the box item exists, it has a definition for each border). Therefore on the the next steps of the for loop, the remaining borders will exist (as nothing) and be dutifully moved to the frame. Apparently the default for a frame is a box with DEFINED borders, so omitting the moving of a nothing border resulted in a stray edge. make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf159207_footerFramePrBorder Change-Id: I217d02678b368f70643be91c4466927b4ca53988 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162409 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> (cherry picked from commit f43efd5473862edbdad0feb7f78c7be02914e997) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162375 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2024-01-23tdf#159259: make sure to set FieldStartRange in sdt helperMike Kaganski
... also for field case. Unfortunately, it is not really clear, if the anagement of this could be moved to DomainMapper_Impl. There are several insertion contexts; they may use different insertion points; there maybe could be cases when an inserted content should not go into the current sdt (?). Thus, I didn't put the code into DomainMapper_Impl::appendTextContent(), where the field character is inserted. Instead, I added code to check and set the start range in the same place as for the normal text: we know for sure, that if it were a normal text, we would append it to GetCurrentTextRange()->getEnd() - so do the same for fields. My concern that still stays is that the use of hasUnusedText looks hackish and fragile. Inserted fields don't set it - so the code that depends on empty sdt will not notice it. OTOH, it can't set it: this would break inserting field result for an already inserted command. Possibly all handling of sdt should be refactored at some point. Change-Id: I7a783aab2400d9a9c1f9f2e5607c872cb58d346b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162398 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162427 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-01-23Related: tdf#159259 Drop obsolete exclusion of framePr inside sdtMike Kaganski
Commit 73bd937420b9a99e1e35950e3f9dcbcfd874876d (n#780853 fix DOCX import of w:sdtContent in table cell, 2012-09-25) had introduced a restriction, where a framePr was ignored, when inside an sdt. It was required to allow table import, which broke otherwise. Since then, the situation has obviously changed; the test case for the change, added in commit 7ea71eb8a28c4b41949299ff7d4b391486c90eea (n#780853 testcase, 2012-09-25) passes after removal of the check. This check disallows importing sdt in frame. This makes the bugdoc of tdf#159259 to import the sdt in frame. The Lorem Ipsum paragraph is still enclosed into the sdt - to be fixed in a follow-up. Change-Id: I60fbb2dd6f753682217d86e4f8d315f1883c6e83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162258 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 4d0f2d5ec9f7f988a1493916ae35bac1986c95a8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162384 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-01-23tdf#153909 docx import: wrap through shapes shouldn't FollowTextFlowJustin Luth
This resolves a NISZ 6.4.0 regression from commit 27d04f6dbf38aa28fb7215590d578c4567db5770 tdf#119038 DOCX: fix FollowTextFlow handling MSO is all over the place in how they implement layoutInCell (aka FollowTextFlow in LO). There are lots of compat15 differences for this, but I don't notice compat coming into play with this bug. For reference, see commit e993638d5ecd33783f2eebdccfa87a81e5a8a2c5 Author: Miklos Vajna on Mon Jan 24 12:53:25 2022 +0100 DOCX import: fix <wp:anchor layoutInCell="1"> with <wp:wrapNone> I'm sure this is the WRONG code spot for handling FollowTextFlow, but anywhere else and we lose the "it came from a vml shape" limiting information, so I'm not going to try to relocate this code. Inline (as-character) shapes ignore layoutInCell, so the type of anchor (floating or inline) shouldn't matter and therefore doesn't need to be part of the if () clause. The header can be special (in compat14 it means everything is wrap through), but at least in this case it is not limited to IsInHeaderHeader. Using a non-header as the unit test. make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf153909_followTextFlow The first patchset contains a list of all of the unit tests that were impacted by this patch: nothing interesting. Change-Id: I0c4c7924833550533ad1b0b7609840a666d4d589 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162324 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins (cherry picked from commit ad0266eb84eafa32ccc4e0ddf3c6392860bc9b13) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162286 Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2024-01-20tdf#158950 Paste as RTF loses char color and paragraph alignment from stylesNoel Grandin
This logic partially originated in commit 8e8f9388c323ad3c32cef3f91609ad19386b7d56 Author: Miklos Vajna <vmiklos@collabora.co.uk> Date: Tue Apr 22 12:53:24 2014 +0200 Related: fdo#77600 RTF import: RTFValue::equals: compare attribute content But it is rather weird to compare RTFSprms this way, comparing each attribute to a parent RTFValue. Making the comparison more "normal" fixes the reported bug while not breaking fdo#77600 Change-Id: Iee224c7bc9542c359f8a71086230e4b53c1c3e16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162164 Reviewed-by: Regina Henschel <rb.henschel@t-online.de> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit f6a559ccacaab875d1aa1da70e3011592158e9d4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162142 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-01-18tdf#135083: make sure to apply pending paragraph properties, even withoutMike Kaganski
... trailing \par. Commit a6ae84cc296d4d28e9a48a57406e955138c87a80 (tdf#70318: Prevent extra empty paragraph in clipboard RTF content, 2015-11-10) made sure to not emit trailing \par for RTF clipboard content. The problem was, that in the absense of the \par, the settings of the last paragraph were not applied (this happens in DomainMapper_Impl::finishParagraph). This change makes sure to call dispatchSymbol(RTFKeyword::PAR) (which eventually calls the mentioned method and applies pending para properties). Since this also adds a new paragraph (which needs to be avoided), a new flag is introduced, set by Stream::markLastParagraph. Its purpose is to make sure that all properties are applied to para, as opposed to bRemove argument to DomainMapper::finishParagraph, which prevents setting some properties (e.g., related to numbering - see DomainMapper::lcl_utext). Change-Id: Ia5e368e540c30f95058c81a280a62205aa85398b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162154 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162191 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 806d07ffa3fa8e0810a00d570c7cfa844cc226ee) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162221 Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-01-16tdf#158830 fixes regression introduces with tdf#158044Oliver Specht
Removing paragraph attributes equal to style attributes now works also for paragraphs within tables. This fixes also the regressions documented in tdf#158978 and tdf#158982 Change-Id: I9f430e23fd33cff4d6ec1d1954969666f0080574 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161824 Tested-by: Jenkins Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Gabor Kelemen <kelemeng@ubuntu.com> Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com> (cherry picked from commit 204d50a07501bf8445a8a0526f68987373834318) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162109
2024-01-15tdf#139915 tdf#159157 writerfilter: fix image position with TEXT_LINEJustin Luth
This is an IMAGE followup to vmiklos' shape/textbox fix in LO 7.2 commit 2f21e4f357ec60450df84ddd858c3cf0a4711b02 Images follow a different code path, but needed the same treatment. Change-Id: I974944c7fbb4e0fa6aa52ac239c6a16ec7f927e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161986 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161988
2024-01-10UnoApiTest::loadFromURL -> UnoApiTest::loadFromFileMike Kaganski
The old name was misleading (it doesn't take an URL, but a filename); also, now it's easier to grep for it - doesn't get mixed with vcl::graphic::loadFromURL. Change-Id: Ib88d2194200a6a54d2326971e0306ba39f0c7025 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161578 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161888 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2024-01-08tdf#158971: Only copy directly-set propertiesMike Kaganski
Commit f09420fa189be5165b0311083ba127073500a121 (tdf#158855: Make sure to not add extra paragraph after a table in a section, 2023-12-25) had implemented copying all attributes of a paragraph using copyAllProps. But the function didn't check the states of properties, so copied also default values of properties, making them direct properties of the paragraph. Due to tdf#158972, that caused an assertion when saving, and the main problem was a set of direct properties in the paragraph. Fix that by checking the properties states. Also make sure to work with paragraphs, rather than with ranges, which treats any properties set on paragraph level as default-state on the run level. Change-Id: I7cd9c7fbb9313d666c46be201913f0223a6b4f5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161539 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161580
2024-01-03tdf#158855: Make sure to not add extra paragraph after a table in a sectionMike Kaganski
Simplify the condition for last paragraph removal in lcl_utext, and clean up the complications piled after commit 2e8aad6d45c53d554ccaf26de998ede708cfc289 (fdo#39056 fdo#75431 Section Properties if section starts with table, 2014-04-24). This makes sure that the trailing extra paragraph gets properly removed, even when there was a dummy paragraph added for a table in section. Because of the removed check, import used to avoid the removal of the extra paragraph immediately following a table (when the table needed to be the last element in the section); hence, in DomainMapper_Impl::appendTextSectionAfter, a last section's table was followed by two paragraphs (one that is expected to stay after the created section, and one before that, that was not removed after the table). xCursor had ininitally both paragraphs in the selection after the forward goto* calls; and then, gotoLeft excluded only the last paragraph from the selection. After the change, in such a case, there is only one paragraph in the end: the one that should stay after the created section. But calling gotoLeft then would have to put the end of selection to a text node inside the table; since the selection that starts before the table can't end inside the table, the call resulted in the whole table excluded from the selection. This requires to add a paragraph here, to allow the previous behavior of cursor; and then the last paragraph in section is destroyed. The code makes sure that the trailing paragraph kept after the creation of the section has all the properties applied to the old last paragraph. testFdo53985 used to check for total 9 paragraphs in the document; while 3 of those were introduced exactly by the bug fixed here; they are absent in Word. The test is fixed; its logic is unchanged, and it still correctly tests that a round-trip doesn't increase number of paragraphs. Change-Id: Ibf6349ba7906dac185c759eb3b58c1849ee5064a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161275 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161300
2023-12-29tdf#158826 rtfimport: ignore page break before document startsJustin Luth
This avoids a 24.2 exposed bug from my commit 016f779ee6c7f601be3ae19dc57497e63a5bf817 RTF import simply cannot be relied upon to create paragraphs where they need to be. A side effect of fixing frames is that spurious paragraphs can be created, and if a frame starts the document, then an otherwise ignored page break can be attached to the second paragraph and thus become exposed. This seems pretty much like the RTF implementation of what was done for DOC and DOCX for tdf#118711. At least it is related. make CppunitTest_sw_rtfexport8 CPPUNIT_TEST_NAME=testTdf158826_extraCR The following unit tests trigger this code (with no visible change) abi10076.odt tdf121623.rtf tdf129513.rtf tdf131963.docx Change-Id: I21afa826b6f6fbb735591603a0620b8b47de517e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161374 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161395
2023-12-21tdf#158762 RTF writerfilter: fix list importOliver Specht
While importing the properties NumberingRules and NumberingStyleName interfere with each other. Avoid overwriting NumberingRules with an invalid NumberingStyleName. Regression from 588ff9a228f4894142264c68392ed1e9800a4d7d Change-Id: I706ea514da43faae0fdb9a2c0d4f5b1928ef55f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160967 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> (cherry picked from commit fad76223d1cff3746a5d2e4ce56b93ecd1c80f61) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161092
2023-12-21tdf#158044 writerfilter: handle toggle properties in import/exportOliver Specht
DOCX has some odd properties (bold, italic, shadowed, hidden ...), which switch on/off if they are applied multiple times, e.g. with paragraph and character styles. To fix that, a hard attribute has to switch off the attribute in that occasion on import and on export a hard attribute switches it on in Word. Includes partial fix for tdf#154370. Change-Id: Ie4c317cf9b7d02efd89b9d6a9996143585d7e937 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160343 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> (cherry picked from commit 9e127010a86b3521c803ac86c0b5f58dc8e2966b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161018
2023-12-21tdf#158556: provide objects anchored to node as a hidden propertyMike Kaganski
This introduces a hidden property of SwXParagraph, named OOXMLImport_AnchoredShapes. Testing on my system, starting the main process first, then launching another one like time soffice path/to/bugdoc.docx ... so that it only measures time spent in import, gave the following figures: LibreOffice 7.5.0.3 (TDF build): real 1m49.016s user 0m0.000s sys 0m0.000s LibreOffice 7.6.0.3 (TDF build): real 8m37.386s user 0m0.000s sys 0m0.000s Current master (my no-debug build): real 10m6.776s user 0m0.000s sys 0m0.000s Current master with this patch (my no-debug build): real 5m41.524s user 0m0.000s sys 0m0.015s Indeed, it is not as fast as it used to be; and the fix doesn't really remove the quadratic complexity, just uses faster iteration. If there is a way to directly list objects anchored to a given paragraph, rather than iterating over all objects checking their anchors, that would get much faster, but that would be a rather large change. Change-Id: Ie50515815e85fdce498d065185199c9b31d95794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160813 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit dcae6615ed254cf7884fa6415f64561f85b93588) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160807 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2023-12-19tdf#158586 RTF writerfilter: substitute hasProperties for inFrameJustin Luth
A proper inFrame() would be identical to hasProperties, so just substitute the existing, complete function for inFrame. This is based on a code read, not a problem document, but finding a document that depended on inFrame returning true made it trivial to modify it to fail. Somewhat surprisingly, it made it all the way through the rtfexports without failing. make CppunitTest_sw_rtfimport CPPUNIT_TEST_NAME=testFdo52052 Change-Id: I96f00c9b542dabd3709a896d778569b7681c8f19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160928 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160984
2023-12-19related tdf#158586 RTF writerfilter: HAnchor's default is text, not marginJustin Luth
\phcol: Use the column as the horizontal reference frame. This is the default if no horizontal reference frame is given. Change-Id: I8ef4a35c578768810edc0a68e3fd3b227c069dfe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160776 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160983
2023-12-19partial revert tdf#153178 writerfilter: do not create text frame spuriously2Justin Luth
If HoriAlign/VertAlign are defined, that is enough to create a frame. This fixes mstahl's 7.6.4 regression originating with commit 4e2f2489c4c7436f8b3a21a530bc625cbef4e365 make CppunitTest_sw_rtfexport8 CPPUNIT_TEST_NAME=testTdf158586_lostFrame Change-Id: Ibb639673cebcd8d5ec79f5551a5703caf948e0d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160744 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160982
2023-12-19partial revert tdf#153178 writerfilter: do not create text frame spuriouslyJustin Luth
If HoriAnchor/VertAnchor are assigned, that is enough to create a frame. make CppunitTest_sw_rtfexport8 CPPUNIT_TEST_NAME=testTdf158586_0B Note: because of a regression, this was already one page before this commit, so need to go back to the time of the reverted patch. Change-Id: Iddbe1cc4ba6d6e95e2d977a227ae6cab5271007e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160743 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160981
2023-12-19tdf#158583 tdf#158586 RTF writerfilter: only startRun for real frameJustin Luth
This fixes a LO 7.6.4 regression of a lost page break, as well as another example where part of the paragraph moves to next page, from mstahl's commit 4e2f2489c4c7436f8b3a21a530bc625cbef4e365 It seems likely that the run should only be checked when we know that there is a real frame here, which essentially becomes a run for most purposes (except perhaps for page breaks - as seen for DOCX). This code block was introduced with commit 0d9132c5046e15540abc20e45d64080708626441 Author: Miklos Vajna on Sat Mar 24 13:04:54 2012 +0100 fdo#47036 fix RTF import of shapes inside text frames at the start of the doc and in the other block of touched code, it did test inFrame. The unit test works when compiling right after the regression, but has broken because of tdf#153194. Since this will get backported way back and all over, it is a good time to introduce rtfexport8. make CppunitTest_sw_rtfexport8 CPPUNIT_TEST_NAME=testTdf158586_0 make CppunitTest_sw_rtfexport8 CPPUNIT_TEST_NAME=testTdf158586_1 Change-Id: Ib4b75efb8422d96e693da337cbef97520e975f3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160655 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 0984b022aab805571f40bdefad6e418cdfe69a81) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160939 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2023-12-14tdf#158681 Revert "tdf#153613 writerfilter: don't always split paraJustin Luth
... for shape w/ pagebreak" This reverts 7.6 commit a9bc19c2d4a35606668aa2dcc53355651b71ee78. The commit in general is probably fine. However, it fails in case of an empty paragraph (with only anchors). Unfortunately, there is no way of knowing ahead of time, so either everything needs to be processed after a delay, or else the paragraph needs to be split and then re-joined in case it is not an empty paragraph. Both options are extremely non-trivial - I don't know how to do either of them. In this case it is also the last paragraph in the document, again something not known during import and which has special-casing in MSO. make CppunitTest_sw_ooxmlexport18 \ CPPUNIT_TEST_NAME=testTdf153613_textboxAfterPgBreak3 Change-Id: I4471e216b6523032b85178d85795434694cc1e22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160720 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> (cherry picked from commit d58cd70f550e8967c2518ebb2179e15f5a3a84ea) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160695
2023-12-08cid#1545617 COPY_INSTEAD_OF_MOVECaolán McNamara
and cid#1545748 COPY_INSTEAD_OF_MOVE cid#1545741 COPY_INSTEAD_OF_MOVE cid#1545698 COPY_INSTEAD_OF_MOVE cid#1545594 COPY_INSTEAD_OF_MOVE cid#1545588 COPY_INSTEAD_OF_MOVE cid#1545558 COPY_INSTEAD_OF_MOVE cid#1545545 COPY_INSTEAD_OF_MOVE Change-Id: I5dfec77a68959b9384fc71a2fc0908c5d1b42869 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160448 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-08cid#1546472 COPY_INSTEAD_OF_MOVECaolán McNamara
and cid#1546459 COPY_INSTEAD_OF_MOVE cid#1546452 COPY_INSTEAD_OF_MOVE cid#1546403 COPY_INSTEAD_OF_MOVE cid#1546396 COPY_INSTEAD_OF_MOVE cid#1546394 COPY_INSTEAD_OF_MOVE cid#1546338 COPY_INSTEAD_OF_MOVE cid#1546324 COPY_INSTEAD_OF_MOVE Change-Id: If61457cfaf1d7ce4a069bcecdc0cc657aeb43c68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160445 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-08cid#1546501 COPY_INSTEAD_OF_MOVECaolán McNamara
and cid#1546486 COPY_INSTEAD_OF_MOVE cid#1546485 COPY_INSTEAD_OF_MOVE cid#1546484 COPY_INSTEAD_OF_MOVE cid#1546482 COPY_INSTEAD_OF_MOVE Change-Id: I53cc622f16afc0f57ffd72e3e0a6f18e390fbb83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160443 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-05writerfilter: fix crash in DomainMapper_Impl::PushSdt()Miklos Vajna
Crashreport signature: Fatal signal received: SIGSEGV code: 1 for address: 0x0 program/libwriterfilterlo.so writerfilter::dmapper::DomainMapper_Impl::PushSdt() writerfilter/source/dmapper/DomainMapper_Impl.cxx:987 program/libwriterfilterlo.so writerfilter::dmapper::DomainMapper::lcl_attribute(unsigned int, writerfilter::Value&) include/tools/ref.hxx:56 program/libwriterfilterlo.so writerfilter::ooxml::OOXMLProperty::resolve(writerfilter::Properties&) include/tools/ref.hxx:56 program/libwriterfilterlo.so writerfilter::ooxml::OOXMLPropertySet::resolve(writerfilter::Properties&) include/tools/ref.hxx:157 Change-Id: I76416ca707a4ac40495e5c22f62fcd017bcb5e48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160336 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 728f6ec104b1a91c8c8ea0790bc7f56471c67737) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160351 Tested-by: Jenkins
2023-12-05tdf#148540 Revert "tdf#109790 RTF import: keep remembering...Justin Luth
... paragraph style between \cell and \row" This reverts 5.4.1 commit aaa6a5202a447fb4e86d5f016d8e79fbc34a3ed7, and rtfexport7's tdf109790.rtf unit test still passes. I also did a visual test, which looks good. After \cell, we normally get more \cells, so an impending \row is completely unexpected most of the time. I'm not really sure why that patch was ever thought to be good. The problem was that \pard was not removing the paragraph style that was assigned to an earlier column. The end result seemed innocent (no bad formatting noticed), but that is probably based on other work done in the meantime which allows the unit test to still pass even after all of "its code" has been reverted. [If this causes a regression, perhaps m_pLastCharacterContext could be of value?] Change-Id: Ide9b65f5e5fa39c21bac6d8ed354bb88e0bbefe5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160233 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2023-12-05tdf#108505 writerfilter: fix field direct char settingsJustin Luth
Instead of adding characters properties one at a time, lets take care of everything all at once. The results seem to be good so far. There is even some similarity between how MS Word has these properties on the "in-between" pseudo end character, where placing the cursor after the field gets these properties. I don't see it happening in MS Word at the pseudo start character, but it does in LO now... Hopefully that doesn't end up doing bad things. In the unit test, replacing the content ends up in red, italic. However, I see the same thing in MSO when testing with my second FORMTEXT example, so I think everything is "working as expected". I tried to see if I could limit doing this for only certain types of fields or conditions. However, pContext->GetResult() doesn't have a \fldrslt yet at the time this is happening. Also, TextField.is() happens less than I expected. I'm sure I could limit it to just certain pContext->GetFieldId(), but so far no problems are noticed for all field types. make CppunitTest_sw_rtfexport6 \ CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat make CppunitTest_sw_rtfexport6 \ CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat2 Change-Id: I3223437fd0d694f5e5733a9f7323f10f03d7802f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160232 Tested-by: Jenkins Tested-by: Gabor Kelemen <kelemeng@ubuntu.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-12-05tdf#108505 writerfilter: fix legacy dropdown fields direct bold settingJustin Luth
Any character property should be passed on, but do that in a follow-up commit, so that at least the bold case will remain intact if the broader fix gets reverted for any reason. make CppunitTest_sw_rtfexport6 \ CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat Change-Id: Id77980b704db2ff118e89c29eb9d4db82e117cdc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160221 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-12-04cid#1546495 COPY_INSTEAD_OF_MOVECaolán McNamara
Change-Id: I8bc5ec6b9586a27e94164580ca7c1f785a08b04d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160273 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-01Fix typoAndrea Gelmini
Change-Id: I1998241849f0f9fa99d1b111f218cdab7e6074fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160208 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-12-01tdf#136472 adjust ooxml import to handle first header/footerTomaž Vajngerl
Previously the ooxml import added a new page style when the first header or footer was detected. Since then we gained support to add first page header/footer in an existing page style so we don't need to import it like that anymore. This changes the import code so that the old complication to add "First Page" page style is removed and it always just uses the "Standard" page style for all 3 cases: first, left and right headers and footers. This also adjusts the existing tests to align with this change. Change-Id: Ibf69597e6990499ac520ea9e323a5f73f429800b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157860 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2023-11-29cid#1554876 Use of auto that causes a copyCaolán McNamara
Change-Id: I8218a4371f0b002d8ef4d544bf9227db6684915f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160012 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-11-29Related: tdf#104718 Use package repair request and behaviorMike Kaganski
Same as in other places handling that: * SfxBaseModel::load (sfx2/source/doc/sfxbasemodel.cxx); * StorageFilterDetect::detect (filter/source/storagefilterdetect/filterdetect.cxx); * TypeDetection::impl_detectTypeFlatAndDeep (filter/source/config/cache/typedetection.cxx) In these cases, the same handler is used (RequestPackageReparation); when the user approves an attempt to repair the package, the media descriptor gets "RepairPackage" property set to true (this produces a "(repaired document)" appended to the document title); also, the document is opened in template mode (so saving it doesn't simply overwrite the original broken document, but asks for a new name). Re-using this logic, and checking if the "RepairPackage" is already set, allows to unify the behavior, and to avoid duplicate warnings when the user already approved repair of a broken package. The request won't contain the details of the XML problem; but it will be shown if rejected anyway, so OK for the diagnostics. Change-Id: Ic997f89272212227479d14236f5e7788298a904a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160001 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-11-28tdf#158348 Treat wordprocessing canvas like group shapeRegina Henschel
getFullWPGSupport() is always false for mrShapeContext in case of a shape on wordprocessing canvas in table cell. On the other hand we do not need the test, because a wordprocessing canvas only occurs in docx and thus the replacement group always has FullWPGSupport. Change-Id: I0e7a9cf1c1c91a893ad7411fda7607947f053e05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159979 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
2023-11-25loplugin:fieldcast in DomainMapper_ImplNoel Grandin
Change-Id: I1d734e1d30b91b84d42067b9cc621581ad744a40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159949 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-11-23fix a regression crash from commit 5082d50Jaume Pujantell
The commit generated crashes in the crashtest documents 7711 bugtrackers/docx/fdo78333-1.docx and 695 forums/docx/forum-mso-en-4096.docx. This was due to "m_xFieldStartRange", the start of the text portion of the block SDT, being recorded too early. This led to including characters that shouldn't be there in the generated content control. This patch moves the calls to setFieldStartRange to just before the first appendTextPortion call. Change-Id: I7230346fee9a37ebac70beb9bcafd9d7b612eb00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159816 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-11-20c++20: use std::erase(_if) instead of std::remove(_if)+erase (writerfilter)Julien Nabet
Change-Id: Id506689954f20c3b66d417798f25807bd0e84ca3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159710 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-11-19Extended loplugin:ostr: writerfilterStephan Bergmann
Change-Id: I83bdd43357d07bce18a2cf286e639c816846e7d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159665 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-11-16writerfilter: fix utext()'s dumb sal_uInt8* parameterMichael Stahl
This removes all but 4 reinterpret_cast in the module! TableManager::utext() even assumed that the bytes are little-endian. Change-Id: I12031336cabedfd6c0fb614ee0e3400810f98e2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159486 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-11-16writerfilter: remove DomainMapper::text() handling of paragraph breakMichael Stahl
Convert all remaining callers to utext(). Change-Id: Ie1fdf22e9e474289df2c72eadc236ec6b270df4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159485 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-11-16tdf#153194 writerfilter: RTF import: testContSectionPageBreak last paraMichael Stahl
For testContSectionPageBreak, Word inserts an additional empty paragraph at the end of the document that was missing in Writer. Ensure markLastSectionGroup() is always called at the end of the document so that the \par that is dispatched in m_bNeedPar case will be inserted and not automatically removed immediately. Also add a test for the same document without \sbknone, which has 4 pages instead of 2. Change-Id: Ib3e4fbdb66df55941e4a487d4b249cd98fe42008 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159472 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-11-16writerfilter: DomainMapper: fix undetected merge conflictMichael Stahl
... between commit fce18155052821756466ea043c638f4ed72f41d6 and commit 15b886f460919ea3dce425a621dc017c2992a96b - move the code from lcl_text() to lcl_utext(). Change-Id: Iaa515d2ebd9861e24b442b0d7b41f83662ed58df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159501 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-11-16tdf#153194 writerfilter: RTF import: \spltpgparMichael Stahl
1. Some experimenting with the bugdoc (saving it to DOCX in Word changes the layout in Word to exactly what Writer imports from RTF!) leads to DOCX w:splitPgBreakAndParaMark setting. 2. the RTF implementation of \spltpgpar was missing; apparently if the flag is present the "new" behavior is in effect, which is the opposite of how it's specified in RTF Spec 1.9.1. 3. the DomainMapper code that uses this attribute is not in the text() function to which RTFDocumentImpl sends paragraph breaks, but in the utext() function, so send the break there instead, rather than creating even more copypasta. 4. now some filters-text crashes with nullptr pContext in DomainMapper::lcl_utext(), avoid that. 5. dispatchSymbol(m_nResetBreakOnSectBreak) doesn't do anything because these are handled by dispatchFlag(). 6. Test name: testFdo81892::Load_Verify_Reload_Verify equality assertion failed - Expected: Performance - Actual : Fails because additional paragraph break inserted after \page; in dispatchSymbol() for \sect, remove the parBreak() as already hinted at in commit 3c610336a58f644525d5e4d2566c35eee6f7a618 7. rtfimport.cxx:868:Assertion Test name: testContSectionPageBreak::TestBody equality assertion failed - Expected: - Actual : THIRD It has no paragraph between SECOND and THIRD, whereas Word definitely shows a paragraph there. In dispatchSymbol() for \sect, sectBreak() is not called (which may create a paragraph break); in m_bIgnoreNextContSectBreak case this needs to be done manually for cont-section-pagebreak.rtf to get the empty paragraph between SECOND and THIRD. 8. testFdo52052 fails; in dispatchSymbol() for \sect, if the document ends with \sect (e.g. fdo52052.rtf) a paragraph break must be inserted after this (because DomainMapper unconditionally removes the last paragraph break), but not via m_bNeedCr as that creates unwanted page break in testNestedTable (m_bNeedCr => dispatchSymbol(\par) => m_bNeedSect => sectBreak()); handle it in RTFDocumentImpl::popState() for the end of the document by dispatching \par. 9. rtfimport.cxx:1519:Assertion testTdf108947 now has 1 empty paragraph in the header instead of 2; Word also shows only 1 so it's an improvement. 10. Test name: testFdo49893_2::Load_Verify_Reload_Verify equality assertion failed - Expected: 1 - Actual : 0 - xpath should match exactly 1 node This was reduced to only 2 pages, while Word shows 5; in dispatchSymbol() for \page, for the consecutive \page send an empty string to DomainMapper's utext() which causes a paragraph break to be created if \spltpgpar isn't set (this was not at all obvious!). 11. testTdf133437 fails with some numbers of flys changing, but it had those values before commit 3c610336a58f644525d5e4d2566c35eee6f7a618 which says "the exact number isn't that interesting". 12. testTdf153613_anchoredAfterPgBreak4 fails, but it now looks as in Word, so this is a bugfix. 13. Jenkins build on WNT (only) crashes in testForcepoint93 in sw layout code - disable test for now, debug asap. Change-Id: Ia1063693d96adff900ece943020a5bf69bdeb7a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159471 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-11-15Import Wordprocessing Canvas, wpc:wpc elementRegina Henschel
Currently LibreOffice uses the VML fallback, when a docx document has a wpc:wpc element. This patch implements to use the choice part with the wpc:wpc element. That is often called 'drawing canvas'. The patch uses a similar approach as for SmartArt. The drawing canvas is imported as group shape and for the background an additional rectangular shape is inserted as first in the children vector. Not using VML has the advantage, that the custom shape import is used for preset shapes. VML import produces problems because some properties are not available in VML or the current VML import has deficits. The test suite shows examples, what is better without using the VML fallback. Affected bug reports are e.g. tdf#104671 or tdf#154828. A drawing canvas must be used in Word for connector shapes. A connector in Word on the drawing canvas is not written as cxnSp element, but as ordinary wsp element with additional wps:cNvCnPr child element. The patch generates a connector in such case. Unsolved problems: The path of a curved connector in OOXML is basically incompatible to the path which LibreOffice generates. This patch uses the default path for a curved connector. Same is done in import in Impress. Using the VML fallback had generated a custom shape with the current path and handles, but the connections to the target shapes were lost. Export to docx is missing. The drawing canvas is not recreated, instead a group with the additional background shape is exported. That is no regression, using VML has produced a group too on export. I don't know whether XML_graphicFrame can occur in WordprocessingCanvasContext. At least charts and math equations are not possible on the drawing canvas in Word. Import of WordArt shapes does not work. That is not regression. It works neither in the VML import. Change-Id: I04bf8407efd1939cdf3137775f8afad420b74014 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156629 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-11-15writerfilter: avoid double map lookup in RTFDocumentImplMiklos Vajna
It's not much more code and is faster. Change-Id: I7ed6b80890dce5cb18555e6c66f7b02c49abcde2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159425 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-11-10tdf#158044 handling of paragraph attributes in RTF importOliver Specht
style attributes need to be repeated at the paragraph if not repeated then defaults have to be applied Change-Id: I4ee567e8006c240c046b7e7bb75eae92e5563776 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158839 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>