diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 718079f9cf5f..59606dd6db38 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -569,6 +569,8 @@ private: bool mbFinalTrackFormulas : 1; // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress. bool mbDocShellRecalc : 1; + // This indicates if a ScOutputData::LayoutStrings() is in progress. + bool mbLayoutStrings : 1; size_t mnMutationGuardFlags; @@ -2624,6 +2626,9 @@ public: bool IsInDocShellRecalc() const { return mbDocShellRecalc; } void SetDocShellRecalc(bool bSet) { mbDocShellRecalc = bSet; } + bool IsInLayoutStrings() const { return mbLayoutStrings; } + void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; } + /** * Serializes the specified sheet's geometry data. * diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx index 63ed2120c985..20edc99646ed 100644 --- a/sc/qa/extras/scpdfexport.cxx +++ b/sc/qa/extras/scpdfexport.cxx @@ -71,6 +71,7 @@ public: void testTdf143978(); void testTdf84012(); void testTdf78897(); + void testForcepoint97(); CPPUNIT_TEST_SUITE(ScPDFExportTest); CPPUNIT_TEST(testExportRange_Tdf120161); @@ -80,6 +81,7 @@ public: CPPUNIT_TEST(testTdf143978); CPPUNIT_TEST(testTdf84012); CPPUNIT_TEST(testTdf78897); + CPPUNIT_TEST(testForcepoint97); CPPUNIT_TEST_SUITE_END(); }; @@ -558,6 +560,18 @@ void ScPDFExportTest::testTdf78897() CPPUNIT_ASSERT_EQUAL(OUString(" 11.00 11.00 "), aActualText); } +// 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 xModel(mxComponent, uno::UNO_QUERY); + + // A1:H81 + ScRange range1(0, 0, 0, 7, 81, 0); + std::shared_ptr 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 83137e93ac37..bcdbd9b586e9 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -190,6 +190,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mbTrackFormulasPending(false), mbFinalTrackFormulas(false), mbDocShellRecalc(false), + mbLayoutStrings(false), mnMutationGuardFlags(0) { maPreviewSelection = { *mxSheetLimits }; diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index e8ee8682df60..404abe0988cc 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2148,7 +2148,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 && !rDocument.IsInLayoutStrings()) { // set number format explicitly if (!rDocument.IsThreadedGroupCalcInProgress()) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 3fbd8eab65e9..55291b388514 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include @@ -1472,6 +1473,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 ?!?!" );