diff options
author | Szabolcs Toth <szabolcs450@gmail.com> | 2020-09-01 13:46:38 +0200 |
---|---|---|
committer | Gabor Kelemen <kelemen.gabor2@nisz.hu> | 2020-09-18 10:32:34 +0200 |
commit | 721e7c4d5a20797ea2876c89e21cccfe394b36af (patch) | |
tree | 312d094f53f7715d81aad2fa36bcf7fef00560ba | |
parent | ad9a1c8dc9b7c267126b8d7591812c6db3188fc9 (diff) |
tdf#133688 tdf#125414 XLSX: don't export tracer arrows
(see Tools->Detective) as plain shapes.
Co-authored-by: Balázs Regényi
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101845
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 14b40ec7be7ca8315848034591e3c3a246d5a8dd)
Change-Id: I920445637a6be12169ae7d70295e4460d7f9b26b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102940
Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r-- | sc/inc/detfunc.hxx | 5 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/tdf133688_dont_save_precedents_to_xlsx.ods | bin | 0 -> 11361 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/tool/detfunc.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97rec.cxx | 17 |
5 files changed, 47 insertions, 5 deletions
diff --git a/sc/inc/detfunc.hxx b/sc/inc/detfunc.hxx index 6eb38f669c41..2f97d881a968 100644 --- a/sc/inc/detfunc.hxx +++ b/sc/inc/detfunc.hxx @@ -42,10 +42,11 @@ enum ScDetectiveObjType SC_DETOBJ_ARROW, SC_DETOBJ_FROMOTHERTAB, SC_DETOBJ_TOOTHERTAB, - SC_DETOBJ_CIRCLE + SC_DETOBJ_CIRCLE, + SC_DETOBJ_RECTANGLE }; -class ScDetectiveFunc +class SC_DLLPUBLIC ScDetectiveFunc { static Color nArrowColor; static Color nErrorColor; diff --git a/sc/qa/unit/data/ods/tdf133688_dont_save_precedents_to_xlsx.ods b/sc/qa/unit/data/ods/tdf133688_dont_save_precedents_to_xlsx.ods Binary files differnew file mode 100644 index 000000000000..3dfdee77f143 --- /dev/null +++ b/sc/qa/unit/data/ods/tdf133688_dont_save_precedents_to_xlsx.ods diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 39c5027cc676..184fe083bbfe 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -239,6 +239,7 @@ public: void testHeaderFontStyleXLSX(); void testTdf135828_Shape_Rect(); void testTdf123353(); + void testTdf133688_precedents(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -376,6 +377,7 @@ public: CPPUNIT_TEST(testHeaderFontStyleXLSX); CPPUNIT_TEST(testTdf135828_Shape_Rect); CPPUNIT_TEST(testTdf123353); + CPPUNIT_TEST(testTdf133688_precedents); CPPUNIT_TEST_SUITE_END(); @@ -4743,6 +4745,20 @@ void ScExportTest::testTdf123353() xShell->DoClose(); } +void ScExportTest::testTdf133688_precedents() +{ + // tdf#133688 Check that we do not export detective shapes. + ScDocShellRef xShell = loadDoc("tdf133688_dont_save_precedents_to_xlsx.", FORMAT_ODS); + CPPUNIT_ASSERT(xShell.is()); + + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX); + xmlDocPtr pDrawing = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml"); + CPPUNIT_ASSERT(pDrawing); + + // We do not export any shapes. + assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[1]", 0); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 740a4af583fd..f429f615db7d 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -1597,16 +1597,24 @@ ScDetectiveObjType ScDetectiveFunc::GetDetectiveObjectType( SdrObject* pObject, if ( nObjColor == GetErrorColor() && nObjColor != GetArrowColor() ) rRedLine = true; } - else if ( dynamic_cast<const SdrCircObj*>( pObject) != nullptr ) + else if (dynamic_cast<const SdrCircObj*>(pObject) != nullptr) { - if ( bValidStart ) + if (bValidStart) { // cell position is returned in rPosition - rPosition = pData->maStart; eType = SC_DETOBJ_CIRCLE; } } + else if (dynamic_cast<const SdrRectObj*>(pObject) != nullptr) + { + if (bValidStart) + { + // cell position is returned in rPosition + rPosition = pData->maStart; + eType = SC_DETOBJ_RECTANGLE; + } + } } } diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 17420fe5c69e..b693838f74fe 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -65,6 +65,7 @@ #include <oox/export/shapes.hxx> #include <oox/export/utils.hxx> #include <oox/export/vmlexport.hxx> +#include <detfunc.hxx> #include <memory> @@ -1020,6 +1021,7 @@ ExcBof8_Base::ExcBof8_Base() nRupBuild = 0x0dbb; nRupYear = 0x07cc; } + void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, const Reference< XShape >& rShape, SCTAB nTab ) { sax_fastparser::FSHelperPtr pDrawing = rStrm.GetCurrentStream(); @@ -1199,6 +1201,21 @@ void XclObjAny::SaveXml( XclExpXmlStream& rStrm ) if( !mxShape.is() || mxShape->getShapeType() == "com.sun.star.drawing.GroupShape" ) return; + // Do not output any of the detective shapes and validation circles. + SdrObject* pObject = GetSdrObjectFromXShape(mxShape); + if (pObject) + { + ScDocument& rDoc = rStrm.GetRoot().GetDoc(); + ScDetectiveFunc aDetFunc(&rDoc, mnScTab); + ScAddress aPosition; + ScRange aSourceRange; + bool bRedLine; + ScDetectiveObjType eObjType = aDetFunc.GetDetectiveObjectType(pObject, mnScTab, aPosition, aSourceRange, bRedLine); + + if (eObjType != SC_DETOBJ_NONE) + return; + } + sax_fastparser::FSHelperPtr pDrawing = rStrm.GetCurrentStream(); ShapeExport aDML(XML_xdr, pDrawing, nullptr, &rStrm, drawingml::DOCUMENT_XLSX); |