summaryrefslogtreecommitdiff
path: root/writerfilter
AgeCommit message (Collapse)Author
2022-10-13Fix typoAndrea Gelmini
Change-Id: Ie04728548d82e6eb5b0d46e65c279dcda5442bf8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141309 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2022-10-13Fix typoAndrea Gelmini
Change-Id: Iff1adef6278239436bbaabd619ed12648d0819df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141305 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2022-10-13sw: improve duplicated bookmarks in copied header/footer textMiklos Vajna
Bookmarks in copied text were renamed in a way that made it hard to differentiate between the original bookmark and the copy, e.g. "Bookmark 1" was renamed to "Bookmark 11". Bookmarks are supposed to have a unique name, so renaming makes sense, and it's probably better to do that compared to what commit 3ec224dcb15e0e663ba85077b8ea0e632f8f03f8 (DOCX import: avoid duplicated bookmarks in copied header/footer text, 2022-09-08) did to just omit them during copy. That solved the duplicated bookmarks, but if one had bookmarks around images to find them, now it doesn't work to find all such images. Fix the problem by going back to copying bookmarks, but copy "Bookmark 1" as "Bookmark 1 Copy 1" (and "Bookmark 1 Copy 2", etc), so API users can identify the original and the copied bookmarks. A similar problem is there for images as well, but that's not yet addressed here. Change-Id: Ic0689b05f790a99ff06523ff4836b1dd412af896 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141293 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-13tdf#149840 Use actual outer size for SmartArt in WriterRegina Henschel
SmartArt import needs the outer size of the diagram for to define a background shape in the correct size and calculate the size of the diagram shapes relative to the outer size. The patch passes the values read from wp:extent in writerfilter to DiagramGraphicDataContext in oox. Change-Id: Ib39227bc645ac353336bab2c558d041974188f6f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141223 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-10-11Deduplicate O(U)StringConcatenationMike Kaganski
And use an overloaded helper function with a better (?) unified name to show that the result is not an O(U)String. Change-Id: I8956338b05d02bf46a6185828130ea8ef145d46b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141203 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-10-10tdf#151261 DOCX import: fix dropdown SDT when the item display text is missingMiklos Vajna
Dropdown content controls have list items, and each list item can have a display text and a value. These are optional, and the bugdoc has a list item where the value is set, but not the display text. The trouble is that later in DomainMapper_Impl::PopSdt() we check if the length of the display texts and values array match and if not, then we throw away these arrays to avoid creating an inconsistent document model. Fix the problem by checking what display text and value we got at the end of each list item; if any of them is missing, we add an empty string, which matches the internal representation in SwContentControlListItem. This also helps in case these array sizes matched by accident, but display texts and values from different list items were mixed previously. Change-Id: Ib1eeabd2479963af4a84d4229d4f0ce4572e0f01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141151 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-07tdf#136617 DOCX import: fix empty table paragraphs with direct formattingLászló Németh
Table paragraph styles applied on paragraphs without runs, i.e. on empty paragraphs, despite their direct formatting, resulting e.g. different font size, and after that different paragraph i.e. cell height, breaking the original table layout. Regression from commit bf3124cdf61b40c94ba117a76f1b63dabdfd528e "tdf#135187 DOCX import: fix table style at character formatting". Also clean-up commit 498d2b82187ec3ff58f076e0d15741e64c0505ba "tdf#131546 DOCX import: fix performance regression at tables". Change-Id: I41f8da61d49902c8c1683bd01632cce6d58aebd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141052 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
2022-10-07tdf#151370: RTF import: docvar name/value can have several sequencesVasily Melenchuk
In case of unicode used there can be tokens, replacements, etc. So it is better to collect and join all received strings, not overwrite with just last received. Change-Id: I2b6ce465d87db4ee30987cbe0ecce1470386242f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141007 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-10-05sw content controls: preserve tagMiklos Vajna
This is similar to <w15:color> to preserve <w:tag>. Resolves <https://gerrit.libreoffice.org/c/core/+/137399/2#message-a5ba9f1e0dc9e586034758ee7c0a94e1533e8922>. Change-Id: I4fdab44aaf13ca812502ae79f38f32ec9468db11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140981 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-05sw content controls: preserve aliasMiklos Vajna
This is similar to <w15:color> to preserve <w:alias>. Related to <https://gerrit.libreoffice.org/c/core/+/137399/2#message-a5ba9f1e0dc9e586034758ee7c0a94e1533e8922>. Change-Id: I774b7204c5ca02ec6db89f5cbd3a6de6f2bf82a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140975 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-10-03tdf#138625 DOCX import: fix superscript footnote numbering in l10nLászló Németh
Footnote/endnote numbers in the footnote area didn't get superscript etc. formatting in non-English locale settings because of the writerfilter mapping to the English localization ("Footnote Characters" and "Endnote Characters") instead of the correct programmatic character style names ("Footnote Symbol" and "Endnote Symbol") according to SwStyleNameMapper::GetChrFormatProgNameArray(). Testing: unit test of tdf#82173. Manual: e.g. open test document of tdf#138625 in an Italian build, after setting Italian locale in it in Tools->Options...->Language Settings-> Languages->Language of user interface. Follow-up to commit 707eb4db1918658e0c2c2c2033c6a69f80c4eafd "tdf#82173 writerfilter: charStyle XnoteReference->Xnote Characters". Change-Id: I36b3c5ff065e9f80289d051e27f618b40e0c9355 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140918 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-09-29use more string_view in writerfilterNoel Grandin
Change-Id: Idd4582138e8da9cc60e0a728bdea5542a509a4f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140711 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-28tdf#147724: DOCX STD import: use storeid to indetify custom XMLVasily Melenchuk
We need to identify XML document to use by storeid in sdt block and in properties of external XML file. Otherwise are possible content collisions when same xpath can evaluate successfully absolutely unrelated custom XML. Change-Id: I6d201a539130b110046deb1818340513cc47a061 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139771 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenchuk@cib.de>
2022-09-26tdf#150762 RTF import: fix missing left margin on numbered paragraphMiklos Vajna
The bugdoc has a numbered paragraph with a custom left margin, but this left margin is missing in Writer. This went wrong in commit 61b7034824dead1635f9e9c6ec996297e10f6910 (tdf#104016 RTF import: deduplicate before text indent from numbering, 2017-12-05), and now it's broken because the numbering properties are applied before paragraph properties in the DOCX case, but the RTF tokenizer didn't do this ordering. This behavior of sw core somewhat makes sense, users expect the margins from direct formatting to go away if you apply a new numbering. So fix the problem by tweaking the RTF tokenizer to emit the numbering tokens first and only then the paragraph tokens, which is an order that's closer to the working DOCX tokenizer. This only affects the old (WW6-style) paragraph numbering markup, not the newer (WW8-style) numbering markup. Change-Id: I39698f57684d47c03ea4848fc8eb6b2e855c4fbc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140584 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-09-22sw content controls, combo box: add DOCX filterMiklos Vajna
Map the ComboBox UNO property to: <w:sdtPr> <w:comboBox> ... </w:comboBox> </w:sdtPr> and the opposite on import. Change-Id: I50e0b961bca99f4ecca86d6784d2e6a13f469314 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140399 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-09-19sw content controls, plain text: enable DOCX filter with data bindingMiklos Vajna
- writerfilter/ had explicit code to not map plain text SDT to Writer content controls if it has data bindings specified, lift this limitation and set the value of content control from data binding, like Word does and Writer did it for input fields since b5c616d10bff3213840d4893d13b4493de71fa56 (tdf#104823: support for sdt plain text fields, 2021-11-24) - call DocxExport::AddSdtData() on the export side to do the opposite on export - give up on the idea to export content controls to DOCX by finding the text attribute in SwWW8AttrIter::OutAttrWithRange(): this needs buffering in both directions (need to start the SDT before the start of the run, need to end it after the end of the run), and solving this using marks and merges at a fast-serializer level looks like hacks on top of hacks. To be more specific, CppunitTest_sw_ooxmlexport7's testSdtAndShapeOverlapping seems to be very hard to fix with this design - instead, give not only the start position but also the length of the run to DocxAttributeOutput::EndRun(), which has random access to the doc model and can look up if there is a content control start or end that needs writing at the current position of the XML output, without any buffering, which also means less code - adapt CppunitTest_sw_ooxmlfieldexport's testSdtBeforeField, which didn't like the empty run at the start of content controls, which seems to be harmless otherwise - fix CppunitTest_sw_ooxmlfieldexport CPPUNIT_TEST_NAME=testSdtDateDuplicate by disabling the "set content control value from data binding" logic for date pickers because that logic in writerfilter/ sets the value as-is and it has to consider the requested date format before this can be enabled As a side effect, this gives PDF export for plain text SDTs, even if they have data binding set. CppunitTest_sw_ooxmlfieldexport's testTdf104823 is now updated to ensure that we import such SDTs as Writer content controls. Change-Id: I749a845b5a25454c51066b8ded892682f523b6b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140134 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-09-14tdf#149551 use 'WritingMode' instead of TextPreRotateAngleRegina Henschel
Commit 7e23cbdbb6ec0247a29ed8a8f744c01e10963ea0 changed the code so, that TextPreRotateAngle is used to track ooxml vert attribute. This patch changes it so, that the style attribute WritingMode is used. Now text direction can be written in 'writing-mode' attribute in the graphic properties in ODF, same for shapes as for frames. The needed conversion from WritingMode BT-LR and TB_LR90 to TextPreRotateAngle for rendering of text in custom shapes is now in one place in class SdrObjectCustomshape. The shape edit engine cannot yet render it itself. Some unit tests are adapted to use WritingMode property instead of TextPreRotateAngle. The value text::WritingMode2::TB_RL90 is introduced, corresponding to vert='vert' and textDirection='tbRl' or ='rl' in OOXML. It is used for frames too, so that the original text direction is preserved and vert='eaVert' can be distinguished from vert='vert'. TextPreRotateAngle is currently still used in SmartArt import for 'upr' and 'grav' and in emulating 'upright' but no longer to emulate text direction. Change-Id: Idc4339bbfc3592fe90b154d75e2c404a1fa30856 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138813 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-09-13tdf#140302 RTF import: fix unexpected repeated imageMiklos Vajna
The bugdoc has 2 images, but the resulting doc model had 3 images since commit 7e863504854ae8ab286b32510aba8b363a8e314b (tdf#81943 sw RTF import: fix missing wrap in background for in-table shape, 2018-07-16). The trouble was that shape replay wants to access the current shape at m_aStates.top().aShape, but we only set it, forgot to unset it after replay was done, which can result in duplicated insertions. Fix this by saving the old current shape on the stack, set the current shape to the wanted value and then undo it after replay. This only affects documents that have a \picprop group, since the unwanted insertion happened when popping that group. Change-Id: I088054de2332deb4b45f7e269672fa799dd49c2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139818 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-09-12tdf#150267 Import docvar value correctlySamuel Mehrbrodt
Change-Id: I388923e3f7bea35c1247f47812c158f5ab92fc0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139793 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
2022-09-09writerfilter: avoid divide by zeroXisco Fauli
in DomainMapperTableManager::endOfRowAction() See https://crashreport.libreoffice.org/stats/signature/writerfilter::dmapper::DomainMapperTableManager::endOfRowAction() Probably since 116cadb5d2582532c69677a2f8499e8e9b7b9b80 "tdf#59274 DOCX import: fix tables with incomplete grid" Change-Id: I12f2842107885fbbc62be2186511102f642e3efc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139717 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-09-09tdf#148214 RTF import: avoid fake paragraph for \page when possibleMiklos Vajna
The bugdoc has 2 pages, an explicit page break between them and the first page has enough content that an additional fake paragraph at the end would lead to a 3rd, unwanted page. The fake paragraph was introduced in commit 7b58fc3dafc789aa55fff5ffef6ab83c3aa8b6e0 (fdo#48104 fix RTF import of \page in inner groups, 2012-04-02), because dmapper ignores more than 1 page breaks in a paragraph. Fix the problem by only inserting the fake paragraph in case the "page break before" paragraph property would have no effect (very first paragraph in the document) or we already sent characters (para props are lazy-sent on the first character). This keeps existing cases working, but avoids the unwanted fake paragraph in the bugdoc. I suspect the root cause is that dmapper doesn't handle multiple page breaks in a paragraph -- once that's fixed, this parBreak() call can be completely removed. Adjusted tests: - testImportHeaderFooter: this asserted the presence of fake paragraphs, which are now gone in the easy case, so this change is an improvement - testTdf133437: no visual difference before/after, probably the test intent was just "make sure this page has several shapes", the exact number isn't that interesting Change-Id: Idd2b8a70b4122eb08d9d305018d384dc0bbb276a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139704 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-09-08DOCX import: avoid duplicated bookmarks in copied header/footer textMiklos Vajna
In case a DOCX document has 2 sections and the 2nd section has a linked header, writerfilter/ copies the header text from the 1st page style to the 2nd page style. This leads to duplicated bookmarks in the doc model, which causes an unexpected increase in bookmark count on export. This went wrong with 8885bdf2f564bb7b56181c50baf39ff99d551ec9 (tdf#128106 sw: copy bookmarks at start if whole node is copied, 2021-08-27), previously at least bookmarks at the start of the header were not duplicated, though that was also inconsistent, since other bookmarks were still duplicated. Interestingly the DOC import doesn't have this problem, because it first copies header text and only later imports the bookmarks. Fix the problem by introducing a new SwCopyFlags::SkipBookmarks flag, add UNO API to set this from writerfilter/ code and skip copying bookmarks (but not other marks) in sw::CopyBookmarks() accordingly. Copying other marks is still needed, because e.g. fieldmarks have a mark and a field, and it would be inconsistent to copy the field, but not the mark. Note that the text is still duplicated in header/footer, linked header/footer is a missing feature on the Writer side. Change-Id: I40e18f231ef2c0d91ae9582621684ef5b6284904 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139697 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-09-06crashtesting: fix DOCX export of forum-mso-en-11199.docxMiklos Vajna
This went wrong in a4432eb0946c0bc775b3d30b634bef5d66544f8d (tdf#104823: support for sdt plain text fields, 2021-11-24), when we started to turn cell SDTs into a field containing the cell text, which now needs to work with redlining, even if the original DOCX file had no fields. The root cause was introduced earlier, in 0c84c60f48cf681daf467c0678a768711f22e5c3 (tdf#77419 DOCX table import: ignore right white space, 2020-01-21), which assumed that goRight(2, select=false) is the opposite of goLeft(1, false) + goLeft(1, true), which is not true for input fields where an input field with 2 chars will select 5 chars (not 1) when you do goLeft(1, true) with a cursor at the right edge of the field (2 chars of content + CH_TXT_ATR_INPUTFIELDSTART + CH_TXT_ATR_INPUTFIELDEND + the field's dummy character itself), as "going left" selects the entire field, not just 1 character. Fix the problem by replacing goRight() with re-positioning the cursor the way it was positioned before trimming whitespace a few lines above. Change-Id: Iaae8878e9801df95d3bc7465d3e8ad12c724a888 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139469 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-09-01tdf#127806: RTF import: use shape dimensions for pib pictureVasily Melenchuk
If RTF shape contains pib (embedded picture) we should override any picture sizes by values from shape. Values provided inside \pict are ignored by MS Word; only shape values matter. To achieve this we need to know shape dimensions so it's calculation is moved to earlier step before internal picture eval. Change-Id: I99c1af7ba62c343b64b3db734b837ff101483ad8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139043 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-09-01tdf#150474 RTF import: fix missing char props for in-table newline charactersMiklos Vajna
I forgot about this in b9508dd55f82d35f09a58021dc001cf79b390e08 (fdo#50665 rtftok: don't ignore character properties of text fields, 2012-06-06), which handled the plain body text case, but not the buffered case. Change-Id: I5c5ebb58becc44a6cf1e0bb8984b2b8c212c3c2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139143 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-08-22tdf#150267 RTF: Import/Export unused document variablesSamuel Mehrbrodt
Previously document variables were only imported when there was a field in the document using them. This adds import/export for the RTF `docvar` group. Change-Id: I25099e037594f4b4c5530ba3a28c64aaa2927918 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138482 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
2022-08-18Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxxStephan Bergmann
...so that its TOOLS_WARN_EXCEPTION can be used in comphelper/source/misc/logging.cxx in a follow-up commit. (And while at it, rename from diangose_ex.h to the more appropriate diagnose_ex.hxx. The comphelper module is sufficiently low-level for this immediate use case, so use that at least for now; o3tl might be even more suitable but doesn't have a Library until now. Also, for the immediate use case it would have sufficed to only break DbgGetCaughtException, exceptionToString, TOOLS_WARN_EXCEPTION, TOOLS_WARN_EXCEPTION_IF, and TOOLS_INFO_EXCEPTION out of include/tools/diagnose_ex.h into an additional new include/comphelper/diagnose_ex.hxx, but its probably easier overall to just move the complete include file as is.) Change-Id: I9f3222d4ccf1a9ac29d7eb9ba1530d53e2affaee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138451 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-17tdf#150200 tdf#150438 sw, DOCX: fix drop cap dash, quotation etc.László Németh
In drop cap layout, set smaller size for all glyphs positioned over the baseline, e.g. dashes (dash, en-dash, em-dash, figure dash), bullet, asterisks and quotation marks by extending the bounding box of the glyph to the baseline, like MSO does. Add "DropCapPunctuation", a new default compatibility option for this. Only old ODT files loads the old layout (which was partially broken: e.g. dashes were too long, often missing from the drop cap area or the drop cap was disabled). New ODT and imported DOCX documents use the new default layout for better typesetting and interoperability. Change-Id: I3aba0727fd15f6edb9245e31f523e12f407d189e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138356 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-08-16crashtesting: fix DOCX export of forum-mso-de-99522.docxMiklos Vajna
Export of this document to DOCX wrote not-well-formed XML output, resulting in an assertion failure in debug builds. writerfilter/ maps a selection of <w:sdt> tags to Writer content controls (a safe subset), and leaves the rest unchanged, which means we continue to map those to grab-bags. The trouble is that a combination of content controls and grab-bags leads to bad output on export, as we start the <w:sdt> element twice, but only close it once. Fix the problem by extending writerfilter/ code to not do any grab-bags for the richText type, we already did that in the past for dropDowns. In the long run, we should never do grab-bagging for any <w:sdt> elements that we map to Writer content controls. Change-Id: I27a0b814efd667cc0477d8f492f7f956c938c854 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138351 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-08-15tdf#150382 writerfilter,sw: RTF import of paragraph border overrideMichael Stahl
The style (default unnamed \s0, applied via \pard) defines green borders, which are overridden at the 2nd paragraph and cleared. Of course there isn't a single border control word to be found on the 2nd paragraph, the override happens by omitting the borders of the implicitly applied style. Hence handle LN_CT_PrBase_pBdr in getDefaultSPRM(). The export of the override relies on changes from commit 967a03eb8760fb498c5ea6c32d03d1eea486bbe2. Change-Id: I081eb2908d76123e7828cab6c31ceb7b11760183 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138193 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-13loplugin:unusedmethodsNoel Grandin
tweak the python script to code with some clang weirdnes Change-Id: I88fc9f901748ff44af2b67704cc437b770ef0737 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138196 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-12writerfilter: typo Srpms->SprmsMichael Stahl
Change-Id: Ib24c5711539b54b429231693fe2aa034593c6262 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138156 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-11tdf#129631 writerfilter,sw: RTF import of invalid border...Michael Stahl
... and export of border on paragraph that clears the border from the paragraph style. The import problem is that a lone \brdrcf17 without any preceding keyword about which border it belongs to (as required by the EBNF in the RTF spec) is apparently handled by Word as overriding/clearing all paragraph borders that may be inherited from the paragraph style. The export problem is that a null SvxBorderLine isn't exported at all, but there needs to be a \brdrnone to override the definition from the style. There was also an API problem that the null SvxBorderLine is wrongly converted to a table::BorderLine2 with LineStyle SOLID. Change-Id: I5fa3857de2ef843f5194e12dd0c3e57bcf1ca52b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138089 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-11related tdf#150197: use SetListFormat instead of SetPrefix/SuffixJustin Luth
Commits prior to this handled all the instances that were caught by a make check. I found a few more by temporarily setting an additional boolean parameter on SetPrefix/SetSuffix which let me catch these. This means we don't have unit tests related to these. Change-Id: I1b3bb1e6eec7878e43ccf546f6df7cb38ac5299e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138072 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2022-08-10loplugin:passstuffbyrefNoel Grandin
Change-Id: Ib2b2650da7abc9260897f9b5aad619a0ea6ae941 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138052 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-08tdf#148518 writerfilter,sw: RTF import/export of FORMDROPDOWN fieldMichael Stahl
On import, the values overwrote each other; export of the form data was missing completely. Change-Id: I918b3cfced39dc2602c6de03cdaf5848a9825dd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137861 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-03tdf#143703 sw: always assign name for fly sectionVasily Melenchuk
Previously generated name was assigned only if not in doc reading mode. But there is no guarantee that it will be assigned later. Better to insert any name in SwDoc::MakeFlySection_() and later it can be overwritten, but fly will definitely have any unique name. * Some test failed because GraphicImport_Impl::applyName() overwrote the name with a different generated one. * This breaks chaining of VML shapes, see test testTDF87348. The code introduced in commit 091fe76b6329b4bb974987554369cbfadd8f2401 in DomainMapper_Impl::ChainTextFrames() breaks if the text frame already has a name; it's a bit confusing which names there come from the file and which come from the API, and it also mixes 2 different cases of VML chaining and DrawingML chaining that look like they should be using different data. * This also breaks moving flys anchored at-char in flys into them in SwXText::convertToTextFrame(), see ooxmlexport13 testFlyInFly. This kind of worked by accident before: the fly is copied and then the original deleted, keeping the same name (with help of SwDoc::mbCopyIsMove); with no name it would compare the SdrObject pointer, which is different for the new copy, now the name is the same. Fix this by only moving flys anchored at the edge of the selection back inoto the body; it turns out that Word actually supports at-char anchors in text frames, but only if it's a VML shape or Compatibility Mode or whatever; i wasn't able to do it in a document created from scratch. This is a bit tricky to ignore the nodes added for floating tables as seen in ooxmlexport10 testFloatingTablesAnchor. * Another change is required in SwDoc::SetFlyName() because of testTdf127732, as it would rename a frame named "Frame1" to "Frame2" when called to rename it to "Frame1". * Some tests failed because after MakeFlySection_() assigns a name it is immediately unconditionally overwritten; replace that with asserts Change-Id: I46752a4413ba3a9e981eccd1e153b3aaf8053781 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127556 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-02tdf#148360: sw: do not ignore list label followed byVasily Melenchuk
...even if numbering is empty. Since this is a core change to avoid impact on other formats (mostly ODT) it is implemented as a new document setting. Change-Id: I35e1cec97eb40f9f3411e3ba74cb553bd8afac59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134989 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2022-08-02clang-tidy modernize-pass-by-value in ooxNoel Grandin
Change-Id: Ia553a24693f2ffc0f580c9869b82f0d01a1a0ffb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137693 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-01use more string_view when dealing with attributesNoel Grandin
which means we don't need to call strlen on them, since we already know how long they are. Change-Id: Iefc76f38a23250e87a65c27df3634d562464a760 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137679 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-01tdf#120972 DOCX: fix import of decimal tabulatorsTünde Tóth
Use locale specific decimal separator for decimal tabulators, because OOXML does not support custom decimal separator. Regression from commit c0b6aadedc9429eee4f4df85957e00e29ccb0c8f "(related: fdo#81033) writerfilter: default tab fill character is space". Change-Id: I9d89e5817707f3b39a1b718b732f6e289f7c6a99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136846 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-07-31clang-tidy modernize-pass-by-value in writer*Noel Grandin
Change-Id: Ib08c971eb3e859e7b04cdd408af7966d83c2955b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137585 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-28these classes can be finalNoel Grandin
Change-Id: I84bb39b6365e445998a793798279c7f9f1064581 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137552 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-28tdf#119840 remove some OUString allocationNoel Grandin
Change-Id: I488db37b3a60feb351d1ecd46278f6d5c3cdde5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137535 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-25sw content controls, plain text: add DOCX importMiklos Vajna
- the core of this is the writerfilter/ change to call PopSdt() for SdtControlType::plainText, which maps inline plain text SDTs to Writer content controls, not to input fields - disable the grab-bag in this case, otherwise we would run duplicated <w:sdt> elements on export - fix CppunitTest_sw_ooxmlexport7's testSdtAndShapeOverlapping by postponing the SDT start in DocxAttributeOutput::WriteContentControlStart() in case a shape is anchored at the same position as the SDT start: if the shape should start inside the content control, then it should be anchored after the dummy character - reduce the debug output in VMLExport::Commit(), which could write control characters to the terminal on test failure, potentially breaking it (requiring a 'reset' to recover) - fix CppunitTest_sw_ooxmlexport5's testSdt2Run: now we merge two runs inside a plain text content control into a single one, and there is no problem with that, so adapt the test instead - fix CppunitTest_sw_ooxmlexport17's testTdf148361: plain text inline SDT is now a content control, not a field - fix CppunitTest_sw_ooxmlfieldexport's testfdo82492: explicitly assert that there is 1 text run inside the SDT and there is a shape after it (outside). Also extend DocxAttributeOutput::EndContentControl(), so it ends the content control at the correct, earlier position in case it's followed by an as-char shape - fix CppunitTest_sw_ooxmlfieldexport's testfdo82123: again assert that the SDT has 1 run with text, and there is a drawing after the SDT - fix CppunitTest_sw_ooxmlfieldexport's testTdf104823: this revealed that some more complex logic is needed to support data bindings, so exclude text-with-databinding from the scope of this commit and continue to map those to input fields for now - fix CppunitTest_sw_ooxmlfieldexport's testFdo81945: this had a similar problem as as-char shapes, but this time a new SDT is starting right after a previous SDT. Adapt DocxAttributeOutput::EndContentControl() accordingly, though perhaps this should be generalized later, so we always close SDTs in the previous run, unless this is the last run, or something similar Change-Id: Ifaf581be884a683de6c8b932008a03ba43734b75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137399 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-07-22elide some makeStringAndClear() callsNoel Grandin
Change-Id: I3b7ae370b41638c0a67374d5132b7bdf56e7c672 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137311 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-15tdf#139759 writerfilter: avoid exception importing w:shd in commentsJustin Luth
The unit test depends on the two previous fixes in this bug report. -initial load tests highlight import -export tests saving the character background -reload tests this shade import Change-Id: Iceb405841efc6814654061659e5551ac89f3c7b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137091 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2022-07-13tdf#139759 writerfilter: import comment highlightJustin Luth
Although it is a highlight, LO doesn't have such a silly duplicate thing in the editeng code. So just map this as normal char background instead of char highlight. As of LO 7.x, we default to exporting as char background anyway, so highlight is on the way out in LO. P.S. Highlight is one of 17-ish colors. It is the background button in the Char panel in MS Word. Background is on Word's Para panel (even though it is a character property), and so it can fairly easily be removed in MS Word. I didn't add a unit test because it doesn't round-trip, and an import-only test is basically useless. I'm having a surprisingly hard time finding why it doesn't export. Change-Id: Iad279b503b9f307994f1d9b96e7d984d6d8b44fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137036 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2022-07-12tdf#149313: DOCX import: improved conditions for removeparagraphVasily Melenchuk
Quite complex conditions to define if current paragraph can be removed for document were forcing to keep paragraphs after page break with only section definition. Usually these pars are removed, but since tdf#103975 fix they were kept. It looks like to resolve that problem will be enough to ensure current break is a column break: they are bit different and processed in a different way unlike other break types. So this condition part instead of "do not remove par with section info after any break" it is right now "do not remove par after column break". Change-Id: Ib6290dc6254430883a598bef3ecd1f7ab7063922 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135969 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
2022-07-11tdf#114734 writerfilter: avoid PostIt exceptionJustin Luth
Comments (aka AnnotationMarks) cannot contain a paragraph style. The exception was causing all properties to be dropped. This fixes the right-to-left text direction issue. Additionally, I need to cancel code when dealing with justify. There is no underlying style to deal with, and also MS Word seems to treat justify literally when dealing with comments. IIRC, LO interally always refers to justify literally, while DOCX normally depends on the RtL context, treating LEFT as START and RIGHT as END. Hmm - I bet that complicates things for export, since exporting comments needs to be handled uniquely. Change-Id: I4f604f90aaad36ea56b8a9157a8a8458f39877c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136690 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>