[Libreoffice-commits] core.git: sc/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 7 17:14:15 UTC 2020


 sc/qa/unit/bugfix-test.cxx        |  145 ++++++++++++++++++++++++++++++++++++++
 sc/qa/unit/data/ods/tdf129789.ods |binary
 2 files changed, 145 insertions(+)

New commits:
commit 8d7b3398fc1aadb5411060b222af330cde40c72c
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Feb 6 17:58:51 2020 +0100
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 7 18:13:40 2020 +0100

    tdf#129789: Add unittest
    
    Extend it to cover all fill styles in shown/hidden comments
    
    Change-Id: I866d1b7f6248a5b5520348b249ed3cda4eec46dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88122
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index a23ba743d829..d0cf10a74b9b 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -7,11 +7,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <postit.hxx>
 #include <validat.hxx>
 #include <tabvwsh.hxx>
 #include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include "helper/qahelper.hxx"
 #include <comphelper/processfactory.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflhtit.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -39,6 +46,7 @@ public:
     void testTdf104310();
     void testTdf31231();
     void testTdf128951();
+    void testTdf129789();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testTdf64229);
@@ -55,6 +63,7 @@ public:
     CPPUNIT_TEST(testTdf104310);
     CPPUNIT_TEST(testTdf31231);
     CPPUNIT_TEST(testTdf128951);
+    CPPUNIT_TEST(testTdf129789);
     CPPUNIT_TEST_SUITE_END();
 private:
     uno::Reference<uno::XInterface> m_xCalcComponent;
@@ -325,6 +334,142 @@ void ScFiltersTest::testTdf128951()
     CPPUNIT_ASSERT_NO_THROW(xDoc->getSheets()->insertByName("mustNotThrow", css::uno::Any(xSheet)));
 }
 
+namespace {
+
+SdrCaptionObj* checkCaption( ScDocument& rDoc, const ScAddress& rAddress, bool bIsShown)
+{
+    ScPostIt *pNote = rDoc.GetNote(rAddress);
+
+    CPPUNIT_ASSERT(pNote);
+    CPPUNIT_ASSERT_EQUAL(pNote->IsCaptionShown(), bIsShown );
+
+    if (!bIsShown)
+        pNote->ShowCaption(rAddress, true);
+
+    SdrCaptionObj* pCaption = pNote->GetCaption();
+    CPPUNIT_ASSERT(pCaption);
+
+    return pCaption;
+}
+}
+
+void ScFiltersTest::testTdf129789()
+{
+
+    ScDocShellRef xDocSh = loadDoc("tdf129789.", FORMAT_ODS, true);
+    CPPUNIT_ASSERT(xDocSh.is());
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    {
+        // Fill: None
+        SdrCaptionObj *const pCaptionB2 = checkCaption(rDoc, ScAddress(1, 1, 0), true);
+
+        const XFillStyleItem& rStyleItemB2 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionB2->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rStyleItemB2.GetValue());
+
+        SdrCaptionObj *const pCaptionB9 = checkCaption(rDoc, ScAddress(1, 8, 0), false);
+
+        const XFillStyleItem& rStyleItemB9 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionB9->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rStyleItemB9.GetValue());
+    }
+
+    {
+        // Fill: Solid
+        SdrCaptionObj *const pCaptionE2 = checkCaption(rDoc, ScAddress(4, 1, 0), true);
+
+        const XFillStyleItem& rStyleItemE2 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionE2->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItemE2.GetValue());
+
+        const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
+            pCaptionE2->GetMergedItem(XATTR_FILLCOLOR));
+        CPPUNIT_ASSERT_EQUAL(Color(0xffffc0), rColorItem.GetColorValue());
+
+        SdrCaptionObj *const pCaptionE9 = checkCaption(rDoc, ScAddress(4, 8, 0), false);
+
+        const XFillStyleItem& rStyleItemE9 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionE9->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItemE9.GetValue());
+
+        const XFillColorItem& rColorItem2 = dynamic_cast<const XFillColorItem&>(
+            pCaptionE9->GetMergedItem(XATTR_FILLCOLOR));
+        CPPUNIT_ASSERT_EQUAL(Color(0xffffc0), rColorItem2.GetColorValue());
+    }
+
+    {
+        // Fill: Gradient
+        SdrCaptionObj *const pCaptionH2 = checkCaption(rDoc, ScAddress(7, 1, 0), true);
+
+        const XFillStyleItem& rStyleItemH2 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionH2->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, rStyleItemH2.GetValue());
+        const XFillGradientItem& rGradientItem = dynamic_cast<const XFillGradientItem&>(
+            pCaptionH2->GetMergedItem(XATTR_FILLGRADIENT));
+        CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), rGradientItem.GetGradientValue().GetStartColor());
+        CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), rGradientItem.GetGradientValue().GetEndColor());
+
+        SdrCaptionObj *const pCaptionH9 = checkCaption(rDoc, ScAddress(7, 8, 0), false);
+
+        const XFillStyleItem& rStyleItemH9 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionH9->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, rStyleItemH9.GetValue());
+        const XFillGradientItem& rGradientItem2 = dynamic_cast<const XFillGradientItem&>(
+            pCaptionH2->GetMergedItem(XATTR_FILLGRADIENT));
+        CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), rGradientItem2.GetGradientValue().GetStartColor());
+        CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), rGradientItem2.GetGradientValue().GetEndColor());
+    }
+
+    {
+        // Fill: Hatch
+        SdrCaptionObj *const pCaptionK2 = checkCaption(rDoc, ScAddress(10, 1, 0), true);
+
+        const XFillStyleItem& rStyleItemK2 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionK2->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, rStyleItemK2.GetValue());
+        const XFillHatchItem& rHatchItem = dynamic_cast<const XFillHatchItem&>(
+            pCaptionK2->GetMergedItem(XATTR_FILLHATCH));
+        CPPUNIT_ASSERT_EQUAL(Color(0x000080), rHatchItem.GetHatchValue().GetColor());
+
+        SdrCaptionObj *const pCaptionK9 = checkCaption(rDoc, ScAddress(10, 8, 0), false);
+
+        const XFillStyleItem& rStyleItemK9 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionK9->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, rStyleItemK9.GetValue());
+        const XFillHatchItem& rHatchItem2 = dynamic_cast<const XFillHatchItem&>(
+            pCaptionK9->GetMergedItem(XATTR_FILLHATCH));
+        CPPUNIT_ASSERT_EQUAL(Color(0x000080), rHatchItem2.GetHatchValue().GetColor());
+    }
+
+    {
+        // Fill: Bitmap
+        SdrCaptionObj *const pCaptionN2 = checkCaption(rDoc, ScAddress(13, 1, 0), true);
+
+        const XFillStyleItem& rStyleItemN2 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionN2->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, rStyleItemN2.GetValue());
+
+        SdrCaptionObj *const pCaptionN9 = checkCaption(rDoc, ScAddress(13, 8, 0), false);
+
+        const XFillStyleItem& rStyleItemN9 = dynamic_cast<const XFillStyleItem&>(
+            pCaptionN9->GetMergedItem(XATTR_FILLSTYLE));
+
+        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, rStyleItemN9.GetValue());
+    }
+
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "sc/qa/unit/data" )
 {
diff --git a/sc/qa/unit/data/ods/tdf129789.ods b/sc/qa/unit/data/ods/tdf129789.ods
new file mode 100644
index 000000000000..49b067b48503
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf129789.ods differ


More information about the Libreoffice-commits mailing list