sc/qa/unit/filters-test.cxx |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

New commits:
commit bf5b90e035f2a3107833b3533eab027424093770
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Nov 20 12:27:31 2020 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Nov 20 15:08:00 2020 +0100

    sc: Add unittest to check size of comments
    
    Change-Id: I267f85a2d3394e4b97e294c25cd7a16e28bf8b7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106223
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 3c6e6c7d9bbb..a994297ff2c0 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -29,6 +29,7 @@
 #include <scopetools.hxx>
 #include <scmod.hxx>
 
+#include <svx/svdocapt.hxx>
 #include <svx/svdpage.hxx>
 
 using namespace ::com::sun::star;
@@ -71,6 +72,7 @@ public:
     void testSharedFormulaRefUpdateXLSX();
     void testSheetNamesXLSX();
     void testTdf79998();
+    void testCommentSize();
     void testLegacyCellAnchoredRotatedShape();
     void testEnhancedProtectionXLS();
     void testEnhancedProtectionXLSX();
@@ -98,6 +100,7 @@ public:
     CPPUNIT_TEST(testSharedFormulaRefUpdateXLSX);
     CPPUNIT_TEST(testSheetNamesXLSX);
     CPPUNIT_TEST(testTdf79998);
+    CPPUNIT_TEST(testCommentSize);
     CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
     CPPUNIT_TEST(testEnhancedProtectionXLS);
     CPPUNIT_TEST(testEnhancedProtectionXLSX);
@@ -488,6 +491,39 @@ void ScFiltersTest::testTdf79998()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testCommentSize()
+{
+    ScDocShellRef xDocSh = loadDoc("comment.", FORMAT_ODS);
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    ScAddress aPos(0,0,0);
+    ScPostIt *pNote = rDoc.GetNote(aPos);
+    CPPUNIT_ASSERT(pNote);
+
+    pNote->ShowCaption(aPos, true);
+    CPPUNIT_ASSERT(pNote->IsCaptionShown());
+
+    SdrCaptionObj* pCaption = pNote->GetCaption();
+    CPPUNIT_ASSERT(pCaption);
+
+    const tools::Rectangle& rOldRect = pCaption->GetLogicRect();
+    CPPUNIT_ASSERT_EQUAL(tools::Long(2899), rOldRect.getWidth());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(939), rOldRect.getHeight());
+
+    pNote->SetText(aPos, "first\nsecond\nthird");
+
+    const tools::Rectangle& rNewRect = pCaption->GetLogicRect();
+    CPPUNIT_ASSERT_EQUAL(rOldRect.getWidth(), rNewRect.getWidth());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1605), rNewRect.getHeight());
+
+    rDoc.GetUndoManager()->Undo();
+
+    CPPUNIT_ASSERT_EQUAL(rOldRect.getWidth(), 
pCaption->GetLogicRect().getWidth());
+    CPPUNIT_ASSERT_EQUAL(rOldRect.getHeight(), 
pCaption->GetLogicRect().getHeight());
+
+    xDocSh->DoClose();
+}
+
 static void impl_testLegacyCellAnchoredRotatedShape( ScDocument& rDoc, const 
tools::Rectangle& aRect, const ScDrawObjData& aAnchor, tools::Long TOLERANCE = 
30 /* 30 hmm */ )
 {
     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to