sw/qa/extras/odfimport/data/tdf149978.fodt | 53 +++++++++++++++++++++++++ sw/qa/extras/odfimport/odfimport.cxx | 12 +++++ sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 2 sw/source/core/txtnode/thints.cxx | 9 +--- sw/source/uibase/docvw/OverlayRanges.hxx | 1 sw/source/uibase/docvw/ShadowOverlayObject.hxx | 2 6 files changed, 73 insertions(+), 6 deletions(-)
New commits: commit 0fd8c3d842d202f3d9834572c986882ba03a226c Author: Justin Luth <justin_l...@sil.org> AuthorDate: Thu Aug 29 09:43:09 2019 +0300 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jul 15 14:38:15 2022 +0200 related tdf#81345: make unit test robust - check last page On KDE Neon 18.04, something was causing page 1 to spill over onto page 2. Checking the last page instead of the second one is fine for testing the problem solved for bug 81345. Confirmed with bibisect53 that same header/page style had been used for the whole document originally. Change-Id: Id85562153d7ce1d570806a611f11d33fa5b83c87 Reviewed-on: https://gerrit.libreoffice.org/78250 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 6fa47ff2ee87bde38719bfaeac022efd966fc8a2) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 18b8c4824e35..66cf57cd6093 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1210,7 +1210,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - xCursor->jumpToPage(2); + xCursor->jumpToLastPage(); OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); CPPUNIT_ASSERT(pageStyleName != "Standard"); commit f6ff1f556df491946198f7fe009b3e8adee58345 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Jul 15 13:16:46 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jul 15 13:16:46 2022 +0200 missing includes Change-Id: Ib01c8224537448e146ab9dc80f4583f06c9f0c28 diff --git a/sw/source/uibase/docvw/OverlayRanges.hxx b/sw/source/uibase/docvw/OverlayRanges.hxx index 7482deef8f97..f8ea5694b128 100644 --- a/sw/source/uibase/docvw/OverlayRanges.hxx +++ b/sw/source/uibase/docvw/OverlayRanges.hxx @@ -24,6 +24,7 @@ #include <basegfx/range/b2drange.hxx> #include <vector> +#include <memory> class SwView; diff --git a/sw/source/uibase/docvw/ShadowOverlayObject.hxx b/sw/source/uibase/docvw/ShadowOverlayObject.hxx index 637d088eab7b..3651bf4e8b8d 100644 --- a/sw/source/uibase/docvw/ShadowOverlayObject.hxx +++ b/sw/source/uibase/docvw/ShadowOverlayObject.hxx @@ -22,6 +22,8 @@ #include <svx/sdr/overlay/overlayobject.hxx> +#include <memory> + class SwView; namespace sw { namespace sidebarwindows { commit 60c96b4c3e79910cd98af0b764430e889bdd5e51 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Jul 13 16:11:29 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jul 15 13:16:30 2022 +0200 tdf#149978 sw: ODF import: fix nondeterministic automatic styles The problem is that in SwpHints::TryInsertHint() there is a check for IsInXMLImport() that is presumably an optimization to avoid the potentially expensive call to BuildPortions(). While LO would only produce 1 text:span referencing an automatic style around any given character content, this is not required by ODF, and so other producers may legitimately produce such nested text:span elements. Unfortunately the current SwpHints::Insert() isn't deterministic, the RES_TXTATR_AUTOFMT with same start/end will be compared by address in CompareSwpHtStart() (whereas RES_TXTATR_CHARFMT has a sort number for this), so the result is going to be a random order. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137033 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit d7827f712ddd21a6c1e151f54dc6eba5c12690da) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137057 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> (cherry picked from commit 7a8f2c7e3a16dae6bdc891fb969e673527e45615) Change-Id: Id62a7ff5fb85dbe42b7e1a27b0d8b36b74cf1100 diff --git a/sw/qa/extras/odfimport/data/tdf149978.fodt b/sw/qa/extras/odfimport/data/tdf149978.fodt new file mode 100644 index 000000000000..5c4840c258fc --- /dev/null +++ b/sw/qa/extras/odfimport/data/tdf149978.fodt @@ -0,0 +1,53 @@ +<?xml version='1.0' encoding='UTF-8'?> +<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="ur n:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:font-face-decls> + <style:font-face style:font-family-generic="roman" style:font-pitch="variable" style:name="Times New Roman" svg:font-family="'Times New Roman'"/> + <style:font-face style:font-family-generic="system" style:font-pitch="variable" style:name="Lucida Sans Unicode" svg:font-family="'Lucida Sans Unicode'"/> + <style:font-face style:font-family-generic="system" style:font-pitch="variable" style:name="Tahoma" svg:font-family="Tahoma"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:line-break="strict" style:punctuation-wrap="hanging" style:tab-stop-distance="1.251cm" style:text-autospace="ideograph-alpha" style:writing-mode="page"/> + <style:text-properties fo:country="DE" fo:font-size="12pt" fo:hyphenate="false" fo:hyphenation-push-char-count="2" fo:hyphenation-remain-char-count="2" fo:language="de" style:country-asian="none" style:country-complex="none" style:font-name="Times New Roman" style:font-name-asian="Lucida Sans Unicode" style:font-name-complex="Tahoma" style:font-size-asian="12pt" style:font-size-complex="12pt" style:language-asian="zxx" style:language-complex="zxx" style:letter-kerning="true" style:use-window-font-color="true"/> + </style:default-style> + </office:styles> + + <office:automatic-styles> + <style:style style:family="text" style:name="A25" style:parent-style-name=""> + <style:text-properties fo:background-color="#d3d3d3"/> + </style:style> + <style:style style:family="text" style:name="A26" style:parent-style-name=""> + <style:text-properties fo:background-color="inherit" fo:color="inherit"/> + </style:style> + + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:background-size="full"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:text> + + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p> + + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 703de09ef7f7..fb5441da5254 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -255,6 +255,18 @@ DECLARE_ODFIMPORT_TEST(testPageStyleLayoutDefault, "hello.odt") CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty<style::PageStyleLayout>(xPropertySet, "PageStyleLayout")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf149978) +{ + load(mpTestDocumentPath, "tdf149978.fodt"); + // on Linux the bug only reproduces if a document has been loaded previously + load(mpTestDocumentPath, "tdf149978.fodt"); + // this was nondeterministic so try 10 times + for (int i = 1; i <= 10; ++i) + { + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(getRun(getParagraph(i), 2, "bar"), "CharBackColor")); + } +} + DECLARE_ODFIMPORT_TEST(testTdf64038, "space.odt") { // no space diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 3d55ed251f2b..fcb2fe20c0ba 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -3241,13 +3241,12 @@ bool SwpHints::TryInsertHint( { // There may be more than one character style at the current position. // Take care of the sort number. - // Special case ruby portion: During import, the ruby attribute is set - // multiple times - // Special case hyperlink: During import, the ruby attribute is set - // multiple times // FME 2007-11-08 #i82989# in NOHINTADJUST mode, we want to insert // character attributes directly - if ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) + if (!bNoHintAdjustMode + && ( (RES_TXTATR_CHARFMT == nWhich) + // tdf#149978 also for import of automatic styles, could be produced by non-LO application + || (RES_TXTATR_AUTOFMT == nWhich && rNode.GetDoc()->IsInXMLImport()))) { BuildPortions( rNode, *pHint, nMode ); }