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 721e7c4d5a20797ea2876c89e21cccfe394b36af
Author:     Szabolcs Toth <szabolcs...@gmail.com>
AuthorDate: Tue Sep 1 13:46:38 2020 +0200
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Fri Sep 18 10:32:34 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
    
    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>
    (cherry picked from commit 14b40ec7be7ca8315848034591e3c3a246d5a8dd)
    
    Change-Id: I920445637a6be12169ae7d70295e4460d7f9b26b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102940
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

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
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 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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to