external/libnumbertext/EmptyString.patch1 | 13 ++ external/libnumbertext/UnpackedTarball_libnumbertext.mk | 6 + filter/source/xsltfilter/LibXSLTTransformer.hxx | 2 formula/source/core/api/token.cxx | 8 + oox/source/ole/vbacontrol.cxx | 6 - sc/inc/document.hxx | 5 sc/qa/extras/scpdfexport.cxx | 16 +++ sc/qa/extras/testdocuments/forcepoint97.xlsx |binary sc/qa/unit/data/xlsx/forcepoint107.xlsx |binary sc/qa/unit/filters-test.cxx | 9 + sc/source/core/data/colorscale.cxx | 6 - sc/source/core/data/documen2.cxx | 1 sc/source/core/data/documentimport.cxx | 8 + sc/source/core/data/dpobject.cxx | 11 +- sc/source/core/data/dptabres.cxx | 12 +- sc/source/core/data/formulacell.cxx | 6 - sc/source/filter/xml/XMLCalculationSettingsContext.cxx | 14 +- sc/source/filter/xml/xmlexprt.cxx | 26 +++-- sc/source/ui/unoobj/chart2uno.cxx | 3 sc/source/ui/view/output2.cxx | 7 + sw/qa/core/data/rtf/pass/forcepoint110.rtf |binary sw/qa/extras/odfimport/data/forcepoint108.fodt | 67 +++++++++++++ sw/qa/extras/odfimport/odfimport.cxx | 20 +++ sw/source/core/unocore/unoframe.cxx | 9 + sw/source/filter/xml/XMLRedlineImportHelper.cxx | 82 ++++++++++++++++ vcl/source/outdev/text.cxx | 2 writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 27 files changed, 310 insertions(+), 31 deletions(-)
New commits: commit 47f896a30da723d9e0043c1772b207d949ce8b6e Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Aug 15 20:47:13 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:40 2022 +0200 forcepoint#108 sw: prevent creating SwRangeRedline anchored in itself the SwRangeRedline in frame #8 triggers deleting itself at frame #0 which repeats the DeleteSection attempt which is already in progress #0 SwRangeRedline::~SwRangeRedline() (this=0x5335300) at sw/source/core/doc/docredln.cxx:1168 #1 0x00007fffc9b91aab in SwRedlineTable::DeleteAndDestroy(unsigned long) (this=0x4f388f8, nP=0) at sw/source/core/doc/docredln.cxx:669 #2 0x00007fffc9c8454a in sw::DocumentRedlineManager::DeleteRedline(SwPaM const&, bool, RedlineType) (this=0x4f388e0, rRange=SwPaM = {...}, bSaveInUndo=true, nDelType=RedlineType::Any) at sw/source/core/doc/DocumentRedlineManager.cxx:2578 #3 0x00007fffc9c84a2f in sw::DocumentRedlineManager::DeleteRedline(SwStartNode const&, bool, RedlineType) (this=0x4f388e0, rNode=..., bSaveInUndo=true, nDelType=RedlineType::Any) at sw/source/core/doc/DocumentRedlineManager.cxx:2676 #4 0x00007fffc9c1c57f in sw::DocumentContentOperationsManager::DeleteSection(SwNode*) (this=0x4f3b460, pNode=0x5331780) at sw/source/core/doc/DocumentContentOperationsManager.cxx:2092 #5 0x00007fffc9cbfea7 in sw::DocumentLayoutManager::DelLayoutFormat(SwFrameFormat*) (this=0x4edad40, pFormat=0x53318b0) at sw/source/core/doc/DocumentLayoutManager.cxx:285 #6 0x00007fffc9a9abd2 in DelFlyInRange(SwNode&, SwNode&, SwContentIndex const*, SwContentIndex const*) (rMkNd=..., rPtNd=..., pMkIdx=0x0, pPtIdx=0x0) at sw/source/core/doc/docedt.cxx:254 #7 0x00007fffc9c1c53d in sw::DocumentContentOperationsManager::DeleteSection(SwNode*) (this=0x4f3b460, pNode=0x532a1f0) at sw/source/core/doc/DocumentContentOperationsManager.cxx:2091 #8 0x00007fffc9b965f7 in SwRangeRedline::MoveFromSection(unsigned long) (this=0x5335300, nMyPos=0) at sw/source/core/doc/docredln.cxx:1834 #9 0x00007fffc9b951f8 in SwRangeRedline::Show(unsigned short, unsigned long, bool) (this=0x5335300, nLoop=1, nMyPos=0, bForced=false) at sw/source/core/doc/docredln.cxx:1277 #10 0x00007fffc9c7d64b in sw::DocumentRedlineManager::SetRedlineFlags(RedlineFlags) (this=0x4f388e0, eMode=RedlineFlags::ShowMask) at sw/source/core/doc/DocumentRedlineManager.cxx:1149 #11 0x00007fffcb129668 in SwXTextDocument::setPropertyValue(rtl::OUString const&, com::sun::star::uno::Any const&) (this=0x4f52730, rPropertyName="ShowChanges", aValue=uno::Any("boolean": 1 '\001')) at sw/source/uibase/uno/unotxdoc.cxx:1795 #12 0x00007fffcab7ce8d in XMLRedlineImportHelper::~XMLRedlineImportHelper() (this=0x52792f0) at sw/source/filter/xml/XMLRedlineImportHelper.cxx:341 #13 0x00007fffcac2366d in SwXMLTextImportHelper::~SwXMLTextImportHelper() (this=0x527cae0) at sw/source/filter/xml/xmltexti.cxx:157 #14 0x00007fffcac236a9 in SwXMLTextImportHelper::~SwXMLTextImportHelper() (this=0x527cae0) at sw/source/filter/xml/xmltexti.cxx:152 #15 0x00007fffea9d5ee2 in salhelper::SimpleReferenceObject::release() (this=0x527cae0) at include/salhelper/simplereferenceobject.hxx:76 #16 0x00007fffeabc2619 in rtl::Reference<XMLTextImportHelper>::clear() (this=0x525cd60) at include/rtl/ref.hxx:196 #17 0x00007fffeabb07e0 in SvXMLImport::cleanup() (this=0x525ccd0) at xmloff/source/core/xmlimp.cxx:458 #18 0x00007fffeabb08bf in SvXMLImport::~SvXMLImport() (this=0x525ccd0) at xmloff/source/core/xmlimp.cxx:464 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138191 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit a8b3953531035bf93306ed90142c4172cc32ac43) forcepoint#108 sw: tweak a bit * the fly-at-fly case didn't work, iteration also skips it * delete the bad redline section in the nodes array Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138434 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 477e489e71b4a96ff10d9f2d2b802d91dec3e319) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138289 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> (cherry picked from commit 2d16f0639b74bcc9328fbb77f774cf9141d1675b) Change-Id: I640874df3fd10af935cf05df707d45bea2c9fd6e diff --git a/sw/qa/extras/odfimport/data/forcepoint108.fodt b/sw/qa/extras/odfimport/data/forcepoint108.fodt new file mode 100644 index 000000000000..4328ea65f61d --- /dev/null +++ b/sw/qa/extras/odfimport/data/forcepoint108.fodt @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:initial-creator>ms </meta:initial-creator><meta:creation-date>2015-08-24T21:49:45.305718699</meta:creation-date><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="0" meta:word-count="0" meta:character-count="0" meta:non-whitespace-character-count="0"/><meta:generator>LibreOfficeDev/4.3.7.2$Linux_X86_64 LibreOffice_project/8a35821d8636a03b8bf4e15b48f59794652c68ba</meta:generator></office:meta> + <office:font-face-decls> + <style:font-face style:name="Lohit Devanagari1" svg:font-family="'Lohit Devanagari'"/> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Source Han Sans CN Regular" svg:font-family="'Source Han Sans CN Regular'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Regular" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Regular" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + </office:styles> + <office:automatic-styles> + <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:footnote-max-height="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="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties officeooo:rsid="000b01fe" officeooo:paragraph-rsid="000b01fe"/> + </style:style> + <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties officeooo:rsid="000b01fe" officeooo:paragraph-rsid="000b01fe"/> + </style:style> + <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame"> + <style:graphic-properties style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + + <text:tracked-changes> + <text:changed-region xml:id="ct58510944" text:id="ct58510944"> + <text:deletion> + <office:change-info> + <dc:creator>ms </dc:creator> + <dc:date>2015-09-10T15:36:00</dc:date> + </office:change-info> + <text:p text:style-name="P1"><draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="char" svg:width="2cm" draw:z-index="-0"><draw:text-box fo:min-height="1.158cm"><text:p text:style-name="P1">foo<text:change text:change-id="ct58510944"/></text:p> + + </office:text> + </office:body> diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 9ee4f206f5a5..5146f7f7b79f 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -34,10 +34,12 @@ typedef std::map<OUString, css::uno::Sequence< css::table::BorderLine> > AllBordersMap; typedef std::pair<OUString, css::uno::Sequence< css::table::BorderLine> > StringSequencePair; +char const DATA_DIRECTORY[] = "/sw/qa/extras/odfimport/data/"; + class Test : public SwModelTestBase { public: - Test() : SwModelTestBase("/sw/qa/extras/odfimport/data/", "writer8") {} + Test() : SwModelTestBase(DATA_DIRECTORY, "writer8") {} }; DECLARE_ODFIMPORT_TEST(testEmptySvgFamilyName, "empty-svg-family-name.odt") @@ -926,5 +928,21 @@ DECLARE_ODFIMPORT_TEST(testTdf123829, "tdf123829.odt") pDoc->getIDocumentSettingAccess().get(DocumentSettingId::COLLAPSE_EMPTY_CELL_PARA)); } +class testForcepoint108 : public Test +{ + CPPUNIT_TEST_SUITE(testForcepoint108); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); + void test(); + CPPUNIT_TEST_SUITE_REGISTRATION(testForcepoint108); +}; +// just care that it doesn't crash/assert +void testForcepoint108::test() +{ + //load would assert because it fails to load entirely, like testMathMalformedXml + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "forcepoint108.fodt"; + mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, {}); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 250a31688151..15e6651661b3 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -31,6 +31,10 @@ #include <IDocumentStylePoolAccess.hxx> #include <tools/datetime.hxx> #include <poolfmt.hxx> +#include <fmtanchr.hxx> +#include <ftnidx.hxx> +#include <txtftn.hxx> +#include <ndtxt.hxx> #include <unoredline.hxx> #include <o3tl/any.hxx> #include <xmloff/xmltoken.hxx> @@ -562,6 +566,73 @@ inline bool XMLRedlineImportHelper::IsReady(RedlineInfo* pRedline) !pRedline->bNeedsAdjustment ); } +/// recursively check if rPos or its anchor (if in fly or footnote) is in redline section +static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& rPos) -> bool +{ + if (rRedlineSection.GetIndex() <= rPos.GetIndex() + && rPos.GetIndex() <= rRedlineSection.EndOfSectionIndex()) + { + return true; + } + // loop to iterate "up" in the node tree and find an anchored XText + for (SwStartNode const* pStartNode = rPos.StartOfSectionNode(); + pStartNode != nullptr && pStartNode->GetIndex() != 0; + pStartNode = pStartNode->StartOfSectionNode()) + { + switch (pStartNode->GetStartNodeType()) + { + case SwNormalStartNode: + case SwTableBoxStartNode: + continue; + break; + case SwFlyStartNode: + { + SwFrameFormat const*const pFormat(pStartNode->GetFlyFormat()); + assert(pFormat); + SwFormatAnchor const& rAnchor(pFormat->GetAnchor()); + if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE) + { + return false; + } + else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_FLY) + { // anchor is on a start node, avoid skipping it: + pStartNode = rAnchor.GetContentAnchor()->nNode.GetNode().GetStartNode(); + assert(pStartNode); + // pass the next node to recursive call - it will call + // call StartOfSectionNode on it and go back to pStartNode + SwNodeIndex const next(*pStartNode, +1); + return RecursiveContains(rRedlineSection, next.GetNode()); + } + else + { + return RecursiveContains(rRedlineSection, rAnchor.GetContentAnchor()->nNode.GetNode()); + } + } + break; + case SwFootnoteStartNode: + { // sigh ... need to search + for (SwTextFootnote const*const pFootnote : rRedlineSection.GetDoc()->GetFootnoteIdxs()) + { + if (pStartNode == pFootnote->GetStartNode()->GetNode().GetStartNode()) + { + return RecursiveContains(rRedlineSection, pFootnote->GetTextNode()); + } + } + assert(false); + } + break; + case SwHeaderStartNode: + case SwFooterStartNode: + return false; // headers aren't anchored + break; + default: + assert(false); + break; + } + } + return false; +} + void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) { OSL_ENSURE(nullptr != pRedlineInfo, "need redline info"); @@ -631,6 +702,17 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) } } } + else if (pRedlineInfo->pContentIndex != nullptr + // should be enough to check 1 position of aPaM bc CheckNodesRange() above + && RecursiveContains(*pRedlineInfo->pContentIndex->GetNode().GetStartNode(), aPaM.GetPoint()->nNode.GetNode())) + { + SAL_WARN("sw.xml", "Recursive change tracking, removing"); + // reuse aPaM to remove it from nodes that will be deleted + *aPaM.GetPoint() = SwPosition(pRedlineInfo->pContentIndex->GetNode()); + aPaM.SetMark(); + *aPaM.GetMark() = SwPosition(*pRedlineInfo->pContentIndex->GetNode().EndOfSectionNode()); + pDoc->getIDocumentContentOperations().DeleteRange(aPaM); + } else { // regular file loading: insert redline commit 24255514ef5c4373f5155b31e87a0016c3063252 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Aug 16 16:18:51 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:40 2022 +0200 forcepoint#110 set PaMs to somewhere safe to park Change-Id: I4dbf27d67b74ff99583dad46a5448700f133c2f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138371 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit d9655727ac688753ea12aaedc09a006134dd4a13) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138292 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> (cherry picked from commit 6a26be4102e2e80bca4138fb0bdbb38cae90cbc8) diff --git a/sw/qa/core/data/rtf/pass/forcepoint110.rtf b/sw/qa/core/data/rtf/pass/forcepoint110.rtf new file mode 100644 index 000000000000..b7594ff6b622 Binary files /dev/null and b/sw/qa/core/data/rtf/pass/forcepoint110.rtf differ diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index b0de9f773463..6328408cb0af 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2713,8 +2713,13 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan aFrameSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 )); } - aPam.DeleteMark(); // mark position node will be deleted! - aIntPam.DeleteMark(); // mark position node will be deleted! + // park these no longer needed PaMs somewhere safe so MakeFlyAndMove + // can delete what it likes without any assert these are pointing to + // that content + aPam.DeleteMark(); + aIntPam.DeleteMark(); + *aPam.GetPoint() = *aIntPam.GetPoint() = SwPosition(pDoc->GetNodes()); + pFormat = pDoc->MakeFlyAndMove( *m_pCopySource, aFrameSet, nullptr, pParentFrameFormat ); commit 08290a2ef4a6587cca4747a755ebc0b7fe40d45f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sat Aug 6 15:35:29 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:40 2022 +0200 crashtesting: keep a reference to the passed in LibXSLTTransformer otherwise, as seen with: soffice --headless --convert-to docx forum-mso-de-42789.docx and error will notify the other thread that the load has ended and the other thread will destroy the passed in LibXSLTTransformer early while this thread assumes it continues to exist Change-Id: Ieea9ecc3439ea73cd0433e5e12b87811906c49aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137819 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit fafe00bb7d72d6d4bec663b40a4cd92e50f33f0f) diff --git a/filter/source/xsltfilter/LibXSLTTransformer.hxx b/filter/source/xsltfilter/LibXSLTTransformer.hxx index 2e434033f93c..4ec405901ec7 100644 --- a/filter/source/xsltfilter/LibXSLTTransformer.hxx +++ b/filter/source/xsltfilter/LibXSLTTransformer.hxx @@ -68,7 +68,7 @@ namespace XSLT static const sal_Int32 OUTPUT_BUFFER_SIZE; static const sal_Int32 INPUT_BUFFER_SIZE; - LibXSLTTransformer* m_transformer; + rtl::Reference<LibXSLTTransformer> m_transformer; Sequence<sal_Int8> m_readBuf; Sequence<sal_Int8> m_writeBuf; commit 19002851e4c19177860def1b8c86444fed8792d4 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Aug 2 11:52:23 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: assert on export of forum-mso-en3-17256.xlsx to ods a lang::IllegalArgumentException is thrown on seeing myEB_Y_Pos and the xml tags become unbalanced Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137612 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit ecf0074b1582842620ce9057a27fbe10f1812b61) Change-Id: I2bd65933c572d7bd1d1ade699fcef21a63a85e9f diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 8cd6ebc11085..b189f4f67762 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -108,6 +108,7 @@ #include <tools/color.hxx> #include <tools/urlobj.hxx> +#include <tools/diagnose_ex.h> #include <rtl/math.hxx> #include <svl/zforlist.hxx> #include <svx/unoshape.hxx> @@ -3453,16 +3454,23 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, uno::Sequence< OUString > aRepresentations( xReceiver->getUsedRangeRepresentations()); SvXMLAttributeList* pAttrList = nullptr; - if(aRepresentations.getLength()) + try { - // add the ranges used by the chart to the shape - // element to be able to start listening after - // load (when the chart is not yet loaded) - uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter ); - pAttrList = new SvXMLAttributeList(); - pAttrList->AddAttribute( - GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + if (aRepresentations.getLength()) + { + // add the ranges used by the chart to the shape + // element to be able to start listening after + // load (when the chart is not yet loaded) + uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter ); + pAttrList = new SvXMLAttributeList(); + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + } + } + catch (const lang::IllegalArgumentException&) + { + //TOOLS_WARN_EXCEPTION("sc", "Exception in lcl_RangeSequenceToString - invalid range?"); } GetShapeExport()->exportShape(xShape, XMLShapeExportFlags::NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 89ebe89061ee..e019dbb6dfa1 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2206,7 +2206,10 @@ OUString SAL_CALL ScChart2DataProvider::convertRangeToXML( const OUString& sRang ScRefTokenHelper::compileRangeRepresentation( aRefTokens, sRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar(), true); if (aRefTokens.empty()) + { + SAL_WARN("sc", "convertRangeToXML throw IllegalArgumentException from input of: " << sRangeRepresentation); throw lang::IllegalArgumentException(); + } Tokens2RangeStringXML converter(m_pDocument); converter = ::std::for_each(aRefTokens.begin(), aRefTokens.end(), converter); commit 962eede7b74d131928a02d1c642ff9aa68d89b00 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jun 21 10:38:30 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 forcepoint#107: ensure to be deleted formulas are unshared first Change-Id: I32cee0a22616e96d85c59d76319a6f6074fcde8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136228 Tested-by: Jenkins Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 31c05349320aceb056d61e4ecd06b18fc31509bb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137185 Reviewed-by: Eike Rathke <er...@redhat.com> (cherry picked from commit a7bf0d61db1343d8af564a2b657def3e17b39b79) diff --git a/sc/qa/unit/data/xlsx/forcepoint107.xlsx b/sc/qa/unit/data/xlsx/forcepoint107.xlsx new file mode 100644 index 000000000000..f5238dcb5c3e Binary files /dev/null and b/sc/qa/unit/data/xlsx/forcepoint107.xlsx differ diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 2a0afb4323aa..48b60471fc8e 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -85,6 +85,7 @@ public: void testSortWithSheetExternalReferencesODS(); void testSortWithSheetExternalReferencesODS_Impl( ScDocShellRef const & xDocShRef, SCROW nRow1, SCROW nRow2, bool bCheckRelativeInSheet ); + void testForcepoint107(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCVEs); @@ -106,6 +107,7 @@ public: CPPUNIT_TEST(testEnhancedProtectionXLSX); CPPUNIT_TEST(testSortWithSharedFormulasODS); CPPUNIT_TEST(testSortWithSheetExternalReferencesODS); + CPPUNIT_TEST(testForcepoint107); CPPUNIT_TEST_SUITE_END(); @@ -761,6 +763,13 @@ void ScFiltersTest::testSortWithSheetExternalReferencesODS_Impl( ScDocShellRef c } } +// just needs to not crash on recalc +void ScFiltersTest::testForcepoint107() +{ + ScDocShellRef xDocSh = loadDoc(u"forcepoint107.", FORMAT_XLSX, true); + xDocSh->DoHardRecalc(); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) , mbUpdateReferenceOnSort(false) diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 079a752d55c7..04aa11c9b4b7 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -381,6 +381,14 @@ void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCel mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pCell->GetCode()); sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells; + + sc::CellStoreType::position_type aPos = rCells.position(rPos.Row()); + if (aPos.first != rCells.end() && aPos.first->type == sc::element_type_formula) + { + ScFormulaCell* p = sc::formula_block::at(*aPos.first->data, aPos.second); + sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p); + } + pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), pCell); } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 965a81a38777..77b6746a7fcb 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -939,6 +939,9 @@ ScFormulaCell::~ScFormulaCell() if (!mxGroup || !mxGroup->mpCode) // Formula token is not shared. delete pCode; + + if (mxGroup && mxGroup->mpTopCell == this) + mxGroup->mpTopCell = nullptr; } ScFormulaCell* ScFormulaCell::Clone() const commit fab7f620ef8ffda8627c3058e18d3042fef5a1df Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Jun 30 01:38:43 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: assert on reexport to ods of forum-it-7248.ods source document available from: https://forum.openoffice.org/it/forum/download/file.php?id=7248 The actual cause is already a bad <table:null-date table:date-value="0000-00-00"/> imported unchecked. For this, sax::Converter::parseDateTime() returns a success value, just use it.. If bad keep the default NullDate. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136611 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit 626458eaec9a1c6ef2c29fd25dc5612d3dd1555c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136646 (cherry picked from commit a60e3c28dbf561b0d1eb190baf32f06151bf32a0) Change-Id: If4caa57e302cfe8304e6cb49bf9d330245a97660 diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx index fd7aab6ddb23..802cbf35a00c 100644 --- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx +++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx @@ -150,12 +150,14 @@ ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& rImport, if (aIter != rAttrList->end()) { util::DateTime aDateTime; - ::sax::Converter::parseDateTime(aDateTime, aIter.toString()); - util::Date aDate; - aDate.Day = aDateTime.Day; - aDate.Month = aDateTime.Month; - aDate.Year = aDateTime.Year; - pCalcSet->SetNullDate(aDate); + if (::sax::Converter::parseDateTime(aDateTime, aIter.toString())) + { + util::Date aDate; + aDate.Day = aDateTime.Day; + aDate.Month = aDateTime.Month; + aDate.Year = aDateTime.Year; + pCalcSet->SetNullDate(aDate); + } } } } commit 268f4d4174dea1a319441dc6957eecb0eff9b447 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jun 27 16:30:19 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 tdf#149692 crash importing document with vba forms This bug appears to date back to commit a43cc9ec8dde4f311bcf8ff96e6a26d56b2abdcf Author: Noel Power <noel.po...@suse.com> Date: Wed Apr 17 17:08:59 2013 +0100 implement MultiPage, Page & TabStrip import for oox Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136500 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit a15fe37bf1dc50fcf88cea9c0038b217119671b8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136472 Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit ef79ccd5bbd5fbc0f0c132c4fc5a48fcd1fbbc16) Change-Id: Ia4784e4c34189f05e516704fa2e2485e4560fa4b diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 36b9278c079d..36200523149b 100644 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -440,13 +440,17 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla if ( xPageSiteRef.get() ) idToPage[ xPageSiteRef->getId() ] = control; } - else + else if (elem->getControlType() == API_CONTROL_TABSTRIP) { AxTabStripModel* pTabStrip = static_cast<AxTabStripModel*>(elem.get()); sCaptions = pTabStrip->maItems; pMultiPage->mnActiveTab = pTabStrip->mnListIndex; pMultiPage->mnTabStyle = pTabStrip->mnTabStyle; } + else + { + SAL_WARN("oox", "unexpected control type " << elem->getControlType()); + } } // apply caption/titles to pages auto itCtrlId = pMultiPage->mnIDs.begin(); commit 2443d2ce0a819f7ea083b1aba5f56f7ac74b0696 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Jun 27 10:00:13 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: fix assert seen with forum-mso-en-8349.docx a string that ends in spaces Change-Id: I808f046be816d0d4a76f801a349e284024a2061c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136465 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 83923eb10c198ae86e20bf9eb7def400a8c08268) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 2506a9609206..71709f775ec8 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2621,7 +2621,7 @@ static OUString lcl_ExctractVariableAndHint( const OUString& rCommand, OUString& sal_Int32 nIndex = rCommand.indexOf( ' ', 2); //find last space after 'ASK' if (nIndex == -1) return OUString(); - while(rCommand[nIndex] == ' ') + while (nIndex < rCommand.getLength() && rCommand[nIndex] == ' ') ++nIndex; OUString sShortCommand( rCommand.copy( nIndex ) ); //cut off the " ASK " commit db668c576021d2faaab4f418e2c95a10a7217b90 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Jun 27 09:40:22 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: fix assert seen on loading forum-nl-1226.ods Change-Id: If8c08a51b11a459a03b4a0604c1fb9897351e598 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136467 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit a095f58d981569cbe79d724a301ed04f0f92748d) diff --git a/external/libnumbertext/EmptyString.patch1 b/external/libnumbertext/EmptyString.patch1 new file mode 100644 index 000000000000..d6570117da09 --- /dev/null +++ b/external/libnumbertext/EmptyString.patch1 @@ -0,0 +1,13 @@ +--- a/src/Soros.cxx 2022-06-27 09:36:46.486075920 +0100 ++++ b/src/Soros.cxx 2022-06-27 09:37:52.594072196 +0100 +@@ -98,8 +98,8 @@ + s = regex_replace(s, quoteEnd, L""); + s = translate(s, c.substr(1), m.substr(1), L""); + replace(s, slash, L"\\\\"); // -> \\, ", ;, # +- begins.push_back(s[0] == L'^'); +- ends.push_back(s[s.length()-1] == L'$'); ++ begins.push_back(!s.empty() && s[0] == L'^'); ++ ends.push_back(!s.empty() && s[s.length()-1] == L'$'); + s = L"^" + regex_replace(s, wregex(L"^\\^"), L""); + s = regex_replace(s, wregex(L"\\$$"), L"") + L"$"; + try diff --git a/external/libnumbertext/UnpackedTarball_libnumbertext.mk b/external/libnumbertext/UnpackedTarball_libnumbertext.mk index ac2a14133205..00f43151326c 100644 --- a/external/libnumbertext/UnpackedTarball_libnumbertext.mk +++ b/external/libnumbertext/UnpackedTarball_libnumbertext.mk @@ -13,4 +13,10 @@ $(eval $(call gb_UnpackedTarball_set_tarball,libnumbertext,$(LIBNUMBERTEXT_TARBA $(eval $(call gb_UnpackedTarball_update_autoconf_configs,libnumbertext)) +$(eval $(call gb_UnpackedTarball_set_patchlevel,libnumbertext,1)) + +$(eval $(call gb_UnpackedTarball_add_patches,libnumbertext, \ + external/libnumbertext/EmptyString.patch1 \ +)) + # vim: set noet sw=4 ts=4: commit 8647e1ce50e6397ddf5c9657b454fd67f0b05e1a Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Jun 22 16:05:53 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: assert seen with forum-mso-de-53682 not reproducible for me, but appears to be an empty string here sometimes. Change-Id: I8465f178cc7e5a6efdc08c1d15c154eeb2277c7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136247 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit dff039e61ac737c779b538d20a57a5e0a401cf60) diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index a8fb0b42541d..b85fdff6dc9e 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -1176,8 +1176,12 @@ bool FormulaMissingContext::AddMissingExternal( FormulaTokenArray *pNewArr ) con const OUString &rName = mpFunc->GetExternal(); - // initial (fast) check: - sal_Unicode nLastChar = rName[ rName.getLength() - 1]; + // initial (fast) checks: + sal_Int32 nLength = rName.getLength(); + if (!nLength) + return false; + + sal_Unicode nLastChar = rName[ nLength - 1]; if ( nLastChar != 't' && nLastChar != 'm' ) return false; commit 7e36b83030e81cc771c8e0c9fdf1b0c5b453de1c Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jun 14 12:24:41 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: negative index seen on loading forum-de3-15472.ods Change-Id: I737e6132f117a85c4d7e5df4a33561d09eff86af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135837 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit d26e960fb3cb6dcff887654b3ec51e5cdea5a878) diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 4ea3606e48b8..a257fae0a87d 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -484,8 +484,10 @@ Color CalcColor( double nVal, double nVal1, const Color& rCol1, double nVal2, co double GetPercentile( const std::vector<double>& rArray, double fPercentile ) { size_t nSize = rArray.size(); - size_t nIndex = static_cast<size_t>(::rtl::math::approxFloor( fPercentile * (nSize-1))); - double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( fPercentile * (nSize-1)); + double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1)); + SAL_WARN_IF(fFloor < 0, "sc", "negative percentile"); + size_t nIndex = fFloor >= 0 ? static_cast<size_t>(fFloor) : 0; + double fDiff = fPercentile * (nSize-1) - fFloor; std::vector<double>::const_iterator iter = rArray.begin() + nIndex; if (fDiff == 0.0) return *iter; commit 8c1c2d197fbf5d9dff6826f3f184b32ca5423866 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jun 14 12:56:41 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: assert seen on loading forum-en-38962.ods mismatched Push/Pop, catch offending exception Change-Id: Ib2297a8ab04a2f2491e4c922d9e4db82a66ea911 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135841 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit adc0d38ea1b434e0f5c996acce87fc9106706801) diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index cb733d25a8da..22d1941f1eb0 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1038,7 +1038,16 @@ bool ScDPObject::GetMembers( sal_Int32 nDim, sal_Int32 nHier, vector<ScDPLabelDa for (sal_Int32 i = 0; i < nCount; ++i) { - Reference<container::XNamed> xMember(xMembersIA->getByIndex(i), UNO_QUERY); + Reference<container::XNamed> xMember; + try + { + xMember = Reference<container::XNamed>(xMembersIA->getByIndex(i), UNO_QUERY); + } + catch (const container::NoSuchElementException&) + { + //TOOLS_WARN_EXCEPTION("sc", "ScNameToIndexAccess getByIndex failed"); + } + ScDPLabelData::Member aMem; if (xMember.is()) commit 8ed94c58e836d30d981da134f336884d040af13d Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jun 14 10:51:13 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:39 2022 +0200 crashtesting: crash seen on exporting forum-it-5909.ods to xlsx Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135752 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 8e14296fcf11bafe91f3ec45598841ba117b20b8) Change-Id: I64b629e2f5b0ece7f903049bd006775463f97586 diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 38107b70e09f..d3e0d108f38a 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -2769,7 +2769,10 @@ ScDPResultDimension::~ScDPResultDimension() ScDPResultMember *ScDPResultDimension::FindMember( SCROW iData ) const { if( bIsDataLayout ) - return maMemberArray[0].get(); + { + SAL_WARN_IF(maMemberArray.empty(), "sc.core", "MemberArray is empty"); + return !maMemberArray.empty() ? maMemberArray[0].get() : nullptr; + } MemberHash::const_iterator aRes = maMemberHash.find( iData ); if( aRes != maMemberHash.end()) { @@ -2976,8 +2979,11 @@ void ScDPResultDimension::LateInitFrom( long ScDPResultDimension::GetSize(long nMeasure) const { - long nTotal = 0; long nMemberCount = maMemberArray.size(); + if (!nMemberCount) + return 0; + + long nTotal = 0; if (bIsDataLayout) { OSL_ENSURE(nMeasure == SC_DPMEASURE_ALL || pResultData->GetMeasureCount() == 1, @@ -3130,7 +3136,7 @@ void ScDPResultDimension::SortMembers( ScDPResultMember* pRefMember ) // handle children // for data layout, call only once - sorting measure is always taken from settings - long nLoopCount = bIsDataLayout ? 1 : nCount; + long nLoopCount = bIsDataLayout ? std::min<long>(1, nCount) : nCount; for (long i=0; i<nLoopCount; i++) { ScDPResultMember* pMember = maMemberArray[i].get(); commit f533718408cef32995451fc66b876f4cb3f9ef65 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Apr 1 15:08:09 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 14:27:38 2022 +0200 forcepoint#97 avoid Invalid read of size 2 ==143282== Invalid read of size 2 ==143282== at 0x190CDBFC: SfxItemSet::Count() const (itemset.hxx:96) ==143282== by 0x1910F33E: SfxItemSet::Get(unsigned short, bool) const (itemset.cxx:748) ==143282== by 0x1F14D76C: ScPatternAttr::GetItem(unsigned short, SfxItemSet const&, SfxItemSet const*) (patattr.cxx:1347) ==143282== by 0x1F14D7DA: ScPatternAttr::GetItem(unsigned short, SfxItemSet const*) const (patattr.cxx:1352) ==143282== by 0x202A3E44: ScLineBreakCell const& ScPatternAttr::GetItem<ScLineBreakCell>(TypedWhichId<ScLineBreakCell>, SfxItemSet const*) const (patattr.hxx:83) ==143282== by 0x2028E8BC: ScOutputData::LayoutStrings(bool, bool, ScAddress const&) (output2.cxx:1677) ==143282== by 0x2028D4A8: ScOutputData::DrawStrings(bool) (output2.cxx:1473) ==143282== by 0x202D9879: ScPrintFunc::PrintArea(short, int, short, int, long, long, bool, bool, bool, bool) (printfun.cxx:1675) ==143282== by 0x202DD459: ScPrintFunc::PrintPage(long, short, int, short, int, bool, ScPreviewLocationData*) (printfun.cxx:2301) ==143282== by 0x202DF491: ScPrintFunc::DoPrint(MultiSelection const&, long, long, bool, ScPreviewLocationData*) (printfun.cxx:2713) ==143282== by 0x20031888: ScModelObj::render(int, com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (docuno.cxx:2259) ==143282== by 0x30C1A485: PDFExport::ExportSelection(vcl::PDFWriter&, com::sun::star::uno::Reference<com::sun::star::view::XRenderable> const&, com::sun::star::uno::Any const&, StringRangeEnumerator const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&, int) (pdfexport.cxx:219) ==143282== by 0x30C1F879: PDFExport::Export(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (pdfexport.cxx:987) ==143282== by 0x30C33BA2: PDFFilter::implExport(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (pdffilter.cxx:174) ==143282== by 0x30C33F2A: PDFFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (pdffilter.cxx:237) ==143282== by 0x21AC6986: SfxObjectShell::ExportTo(SfxMedium&) (objstor.cxx:2488) ==143282== by 0x21AC2363: SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) (objstor.cxx:1553) ==143282== by 0x21ACE816: SfxObjectShell::PreDoSaveAs_Impl(rtl::OUString const&, rtl::OUString const&, SfxItemSet const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (objstor.cxx:2966) ==143282== by 0x21ACCA87: SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, rtl::OUString const&, SfxItemSet&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (objstor.cxx:2756) ==143282== by 0x21AA8CDB: SfxObjectShell::APISaveAs_Impl(rtl::OUString const&, SfxItemSet&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (objserv.cxx:317) ==143282== by 0x21B2B4AD: SfxBaseModel::impl_store(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, bool) (sfxbasemodel.cxx:3132) ==143282== by 0x21B2CB12: SfxBaseModel::storeToURL(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (sfxbasemodel.cxx:1768) ==143282== by 0x1C507AFE: ScPDFExportTest::exportToPDF(com::sun::star::uno::Reference<com::sun::star::frame::XModel> const&, ScRange const&) (scpdfexport.cxx:192) ==143282== by 0x1C511A33: ScPDFExportTest::testForcepoint97() (scpdfexport.cxx:571) ==143282== by 0x1C52778D: void std::__invoke_impl<void, void (ScPDFExportTest::*&)(), ScPDFExportTest*&>(std::__invoke_memfun_deref, void (ScPDFExportTest::*&)(), ScPDFExportTest*&) (invoke.h:74) ==143282== by 0x1C5276C1: std::__invoke_result<void (ScPDFExportTest::*&)(), ScPDFExportTest*&>::type std::__invoke<void (ScPDFExportTest::*&)(), ScPDFExportTest*&>(void (ScPDFExportTest::*&)(), ScPDFExportTest*&) (invoke.h:96) ==143282== by 0x1C527659: void std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) (functional:420) ==143282== by 0x1C5275E2: void std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>::operator()<, void>() (functional:503) ==143282== by 0x1C52758C: void std::__invoke_impl<void, std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>&>(std::__invoke_other, std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>&) (invoke.h:61) ==143282== by 0x1C52753C: std::enable_if<is_invocable_r_v<void, std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>&>, void>::type std::__invoke_r<void, std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>&>(std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()>&) (invoke.h:111) ==143282== by 0x1C52731C: std::_Function_handler<void (), std::_Bind<void (ScPDFExportTest::*(ScPDFExportTest*))()> >::_M_invoke(std::_Any_data const&) (std_function.h:290) ==143282== by 0x1C527A34: std::function<void ()>::operator()() const (std_function.h:590) ==143282== by 0x1C527078: CppUnit::TestCaller<ScPDFExportTest>::runTest() (TestCaller.h:175) ==143282== by 0x49326F2: CppUnit::TestCaseMethodFunctor::operator()() const (TestCase.cpp:32) ==143282== by 0x15937E3D: (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (vclbootstrapprotector.cxx:46) ==143282== by 0x4929ED1: CppUnit::ProtectorChain::ProtectFunctor::operator()() const (ProtectorChain.cpp:20) ==143282== by 0x4B05D6D: (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (unobootstrapprotector.cxx:78) ==143282== by 0x4929ED1: CppUnit::ProtectorChain::ProtectFunctor::operator()() const (ProtectorChain.cpp:20) ==143282== by 0x4AF2F2A: (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (unoexceptionprotector.cxx:62) ==143282== by 0x4929ED1: CppUnit::ProtectorChain::ProtectFunctor::operator()() const (ProtectorChain.cpp:20) ==143282== by 0x491261E: CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (DefaultProtector.cpp:15) ==143282== by 0x4929ED1: CppUnit::ProtectorChain::ProtectFunctor::operator()() const (ProtectorChain.cpp:20) ==143282== by 0x4928690: CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (ProtectorChain.cpp:86) ==143282== by 0x4946ACD: CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (TestResult.cpp:182) ==143282== by 0x4932103: CppUnit::TestCase::run(CppUnit::TestResult*) (TestCase.cpp:91) ==143282== by 0x4932BCF: CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (TestComposite.cpp:64) ==143282== by 0x4932A5F: CppUnit::TestComposite::run(CppUnit::TestResult*) (TestComposite.cpp:23) ==143282== by 0x4932BCF: CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (TestComposite.cpp:64) ==143282== by 0x4932A5F: CppUnit::TestComposite::run(CppUnit::TestResult*) (TestComposite.cpp:23) ==143282== by 0x494FDBF: CppUnit::TestRunner::WrappingSuite::run(CppUnit::TestResult*) (TestRunner.cpp:47) ==143282== Address 0x1d7624b0 is 64 bytes inside a block of size 120 free'd ==143282== at 0x4847669: operator delete(void*) (vg_replace_malloc.c:923) ==143282== by 0x1F150EA1: ScPatternAttr::~ScPatternAttr() (patattr.hxx:53) ==143282== by 0x190D29B2: SfxItemPool::Remove(SfxPoolItem const&) (itempool.cxx:802) ==143282== by 0x1EA27F8E: ScAttrArray::SetPatternAreaImpl(int, int, ScPatternAttr const*, bool, ScEditDataArray*, bool) (attarray.cxx:574) ==143282== by 0x1EBF43D5: ScAttrArray::SetPattern(int, ScPatternAttr const*, bool) (attarray.hxx:148) ==143282== by 0x1EBD9068: ScColumn::ApplyAttr(int, SfxPoolItem const&) (column.cxx:634) ==143282== by 0x1EC6C1EB: ScColumn::SetNumberFormat(int, unsigned int) (column2.cxx:3094) ==143282== by 0x1F1CB737: ScTable::SetNumberFormat(short, int, unsigned int) (table2.cxx:2238) ==143282== by 0x1EE3F135: ScDocument::SetNumberFormat(ScAddress const&, unsigned int) (document.cxx:3717) ==143282== by 0x1F09CCA5: ScFormulaCell::InterpretTail(ScInterpreterContext&, ScFormulaCell::ScInterpretTailParameter) (formulacell.cxx:2155) ==143282== by 0x1F099D9F: ScFormulaCell::Interpret(int, int) (formulacell.cxx:1615) ==143282== by 0x1ECC048D: ScFormulaCell::MaybeInterpret() (formulacell.hxx:465) ==143282== by 0x1F09F5C8: ScFormulaCell::IsValue() (formulacell.cxx:2760) ==143282== by 0x1EA82355: (anonymous namespace)::hasNumericImpl(CellType, ScFormulaCell*) (cellvalue.cxx:155) ==143282== by 0x1EA822FA: ScRefCellValue::hasNumeric() const (cellvalue.cxx:624) ==143282== by 0x2028E876: ScOutputData::LayoutStrings(bool, bool, ScAddress const&) (output2.cxx:1676) ==143282== by 0x2028D4A8: ScOutputData::DrawStrings(bool) (output2.cxx:1473) ==143282== by 0x202D9879: ScPrintFunc::PrintArea(short, int, short, int, long, long, bool, bool, bool, bool) (printfun.cxx:1675) ==143282== by 0x202DD459: ScPrintFunc::PrintPage(long, short, int, short, int, bool, ScPreviewLocationData*) (printfun.cxx:2301) ==143282== by 0x202DF491: ScPrintFunc::DoPrint(MultiSelection const&, long, long, bool, ScPreviewLocationData*) (printfun.cxx:2713) ==143282== by 0x20031888: ScModelObj::render(int, com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (docuno.cxx:2259) ==143282== by 0x30C1A485: PDFExport::ExportSelection(vcl::PDFWriter&, com::sun::star::uno::Reference<com::sun::star::view::XRenderable> const&, com::sun::star::uno::Any const&, StringRangeEnumerator const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&, int) (pdfexport.cxx:219) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134362 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> (cherry picked from commit 6d615be74e30f50b164e0342a0f8fb3324ce8058) Change-Id: Idf19b79f5aef7e07666249f5f9ec510003a3f886 diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index dff46dffd699..a5b9c8fbe781 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -541,6 +541,8 @@ private: bool mbTrackFormulasPending : 1; bool mbFinalTrackFormulas : 1; + // This indicates if a ScOutputData::LayoutStrings() is in progress. + bool mbLayoutStrings : 1; size_t mnMutationGuardFlags; @@ -2429,6 +2431,9 @@ public: SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const; + bool IsInLayoutStrings() const { return mbLayoutStrings; } + void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; } + private: /** diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx index 02f00f8fac5d..69bcbde242d6 100644 --- a/sc/qa/extras/scpdfexport.cxx +++ b/sc/qa/extras/scpdfexport.cxx @@ -55,12 +55,16 @@ private: // unit tests public: void testExportRange_Tdf120161(); + void testForcepoint97(); CPPUNIT_TEST_SUITE(ScPDFExportTest); CPPUNIT_TEST(testExportRange_Tdf120161); + CPPUNIT_TEST(testForcepoint97); CPPUNIT_TEST_SUITE_END(); }; +char const DATA_DIRECTORY[] = "/sc/qa/extras/testdocuments/"; + void ScPDFExportTest::setUp() { test::BootstrapFixture::setUp(); @@ -278,6 +282,18 @@ void ScPDFExportTest::testExportRange_Tdf120161() } } +// just needs to not crash on export to pdf +void ScPDFExportTest::testForcepoint97() +{ + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + "forcepoint97.xlsx", + "com.sun.star.sheet.SpreadsheetDocument"); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + + // A1:H81 + ScRange range1(0, 0, 0, 7, 81, 0); + std::shared_ptr<utl::TempFile> pPDFFile = exportToPdf(xModel, range1); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScPDFExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/extras/testdocuments/forcepoint97.xlsx b/sc/qa/extras/testdocuments/forcepoint97.xlsx new file mode 100644 index 000000000000..152fbbc45a9f Binary files /dev/null and b/sc/qa/extras/testdocuments/forcepoint97.xlsx differ diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 88c9b972c912..a810494b056c 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -221,6 +221,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mbUseEmbedFonts(false), mbTrackFormulasPending(false), mbFinalTrackFormulas(false), + mbLayoutStrings(false), mnMutationGuardFlags(0) { SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index b43e908352ed..965a81a38777 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2010,7 +2010,8 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa // XXX if mbNeedsNumberFormat was set even if the current format // was not General then we'd have to obtain the current format here // and check at least the types. - if (bSetFormat && (bForceNumberFormat || ((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0))) + const bool bSetNumberFormat = bSetFormat && (bForceNumberFormat || ((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0)); + if (bSetNumberFormat && !pDocument->IsInLayoutStrings()) { // set number format explicitly if (!pDocument->IsThreadedGroupCalcInProgress()) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 3dfaaa9889f9..a956be4a7205 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -74,6 +74,7 @@ #include <scopetools.hxx> #include <com/sun/star/i18n/DirectionProperty.hpp> +#include <comphelper/scopeguard.hxx> #include <comphelper/string.hxx> #include <memory> @@ -1453,6 +1454,12 @@ void ScOutputData::DrawStrings( bool bPixelToLogic ) tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, const ScAddress &rAddress) { + bool bOrigIsInLayoutStrings = mpDoc->IsInLayoutStrings(); + mpDoc->SetLayoutStrings(true); + comphelper::ScopeGuard g([this, bOrigIsInLayoutStrings] { + mpDoc->SetLayoutStrings(bOrigIsInLayoutStrings); + }); + OSL_ENSURE( mpDev == mpRefDevice || mpDev->GetMapMode().GetMapUnit() == mpRefDevice->GetMapMode().GetMapUnit(), "LayoutStrings: different MapUnits ?!?!" ); commit 4b4a103867a42433f5d8b7aa0abb117ae8f480bf Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon May 2 21:17:06 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 23 12:56:42 2022 +0200 ofz: Use-of-uninitialized-value Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133717 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit f248b99b6f7f93b5170b4c50d7827fa0dd23421e) Change-Id: I9ca24a135494a49449aec63615b2d945a93e8b27 diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index d0b3a80bfc9d..f5079fa41489 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1119,7 +1119,7 @@ void OutputDevice::GetCaretPositions( const OUString& rStr, long* pCaretXArray, for( i = 0; i < 2 * nLen; ++i ) if( pCaretXArray[ i ] >= 0 ) break; - long nXPos = pCaretXArray[ i ]; + long nXPos = (i < 2 * nLen) ? pCaretXArray[i] : -1; for( i = 0; i < 2 * nLen; ++i ) { if( pCaretXArray[ i ] >= 0 )