sc/inc/detfunc.hxx                                             |    5 +-
 sc/qa/unit/data/ods/tdf133688_dont_save_precedents_to_xlsx.ods |binary
 sc/qa/unit/subsequent_export-test.cxx                          |   16 +++++++++
 sc/source/core/tool/detfunc.cxx                                |   14 ++++++--
 sc/source/filter/xcl97/xcl97rec.cxx                            |   17 
++++++++++
 5 files changed, 47 insertions(+), 5 deletions(-)

New commits:
commit 14b40ec7be7ca8315848034591e3c3a246d5a8dd
Author:     Szabolcs Toth <szabolcs...@gmail.com>
AuthorDate: Tue Sep 1 13:46:38 2020 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Sep 14 13:57:30 2020 +0200

    tdf#133688 tdf#125414 XLSX: don't export tracer arrows
    
    (see Tools->Detective) as plain shapes.
    
    Co-authored-by: Balázs Regényi
    
    Change-Id: I920445637a6be12169ae7d70295e4460d7f9b26b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101845
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sc/inc/detfunc.hxx b/sc/inc/detfunc.hxx
index 28394627e913..b8d1d2c0bc81 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
new file mode 100644
index 000000000000..3dfdee77f143
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf133688_dont_save_precedents_to_xlsx.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 451d45d99c84..8df9882b0190 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -268,6 +268,7 @@ public:
     void testHeaderFontStyleXLSX();
     void testTdf135828_Shape_Rect();
     void testTdf123353();
+    void testTdf133688_precedents();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -430,6 +431,7 @@ public:
     CPPUNIT_TEST(testHeaderFontStyleXLSX);
     CPPUNIT_TEST(testTdf135828_Shape_Rect);
     CPPUNIT_TEST(testTdf123353);
+    CPPUNIT_TEST(testTdf133688_precedents);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -5444,6 +5446,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);
+    xmlDocUniquePtr 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 e77313830a17..2df199e2f7dd 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1605,16 +1605,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 6cde8226c0ea..70eb9a7323b7 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -66,6 +66,7 @@
 #include <oox/export/shapes.hxx>
 #include <oox/export/utils.hxx>
 #include <oox/export/vmlexport.hxx>
+#include <detfunc.hxx>
 
 #include <memory>
 
@@ -1089,6 +1090,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();
@@ -1272,6 +1274,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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to