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

Noel Power noel.power at suse.com
Thu Feb 7 03:35:37 PST 2013


 sc/inc/document.hxx                    |    2 -
 sc/qa/unit/helper/qahelper.hxx         |   15 ++++++++---
 sc/qa/unit/subsequent_filters-test.cxx |   44 +++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 5 deletions(-)

New commits:
commit d387140035547637338175ffdd22b5131a5e8f77
Author: Noel Power <noel.power at suse.com>
Date:   Thu Feb 7 11:11:24 2013 +0000

    another row height ( related to optimalheight and deleting content ) fdo#59193
    
    A cell when modified ( e.g. content deleted ) should have its row height
    recalculated when the optimalheight attribute for that row is set.
    
    Also tweaked the test framework to allow read/write files to be loaded, this
    allows functions that modify the document content to actually work as intended
    
    Change-Id: Ia929a194a96f5c8b870f9a49d1e27d0c34ba9c91

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6483c65..4e10145 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1028,7 +1028,7 @@ public:
 
     void            DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                             const ScMarkData& rMark, sal_uInt16 nDelFlag);
-    void            DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+    SC_DLLPUBLIC void            DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                 SCTAB nTab, sal_uInt16 nDelFlag);
     void            DeleteAreaTab(const ScRange& rRange, sal_uInt16 nDelFlag);
 
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 5d730e9..86275f7 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -129,7 +129,7 @@ class ScBootstrapFixture : public test::BootstrapFixture
 {
 protected:
     OUString m_aBaseString;
-    ScDocShellRef load(
+    ScDocShellRef load( bool bReadWrite,
         const OUString& rURL, const OUString& rFilter, const OUString &rUserData,
         const OUString& rTypeName, unsigned int nFilterFlags, unsigned int nClipboardID,  sal_uIntPtr nFilterVersion = SOFFICE_FILEFORMAT_CURRENT, const OUString* pPassword = NULL )
     {
@@ -141,7 +141,7 @@ protected:
 
         ScDocShellRef xDocShRef = new ScDocShell;
         xDocShRef->GetDocument()->EnableUserInteraction(false);
-        SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
+        SfxMedium* pSrcMed = new SfxMedium(rURL, bReadWrite ? STREAM_STD_READWRITE : STREAM_STD_READ );
         pSrcMed->SetFilter(pFilter);
         pSrcMed->UseInteractionHandler(false);
         if (pPassword)
@@ -160,7 +160,14 @@ protected:
         return xDocShRef;
     }
 
-    ScDocShellRef loadDoc(const OUString& rFileName, sal_Int32 nFormat)
+    ScDocShellRef load(
+        const OUString& rURL, const OUString& rFilter, const OUString &rUserData,
+        const OUString& rTypeName, unsigned int nFilterFlags, unsigned int nClipboardID,  sal_uIntPtr nFilterVersion = SOFFICE_FILEFORMAT_CURRENT, const OUString* pPassword = NULL )
+    {
+        return load( false, rURL, rFilter, rUserData, rTypeName, nFilterFlags, nClipboardID,  nFilterVersion, pPassword );
+    }
+
+    ScDocShellRef loadDoc(const OUString& rFileName, sal_Int32 nFormat, bool bReadWrite = false )
     {
         OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 );
         OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ;
@@ -170,7 +177,7 @@ protected:
         unsigned int nFormatType = aFileFormats[nFormat].nFormatType;
         unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
 
-        return load(aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, nFormatType);
+        return load(bReadWrite, aFileName, aFilterName, OUString(), aFilterType, nFormatType, nClipboardId, nFormatType);
     }
 
 
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 74e3086..ee8a135 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -56,6 +56,8 @@
 #include "dpobject.hxx"
 #include "dpsave.hxx"
 #include "stlsheet.hxx"
+#include "docfunc.hxx"
+#include "markdata.hxx"
 
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -146,6 +148,7 @@ public:
     void testRowHeightODS();
     void testRichTextContentODS();
     void testMiscRowHeights();
+    void testOptimalHeightReset();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testRangeNameXLS);
@@ -205,6 +208,7 @@ public:
     CPPUNIT_TEST(testBugFilesXLSX);
 #endif
     CPPUNIT_TEST(testMiscRowHeights);
+    CPPUNIT_TEST(testOptimalHeightReset);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1896,6 +1900,46 @@ void ScFiltersTest::testMiscRowHeights()
     miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) );
 }
 
+// regression test at least fdo#59193
+// what we want to test here is that when cell contents are deleted
+// and the optimal flag is set for that row that the row is actually resized
+
+void ScFiltersTest::testOptimalHeightReset()
+{
+    ScDocShellRef xDocSh = loadDoc("multilineoptimal.", ODS, true);
+    SCTAB nTab = 0;
+    SCROW nRow = 0;
+    ScDocument* pDoc = xDocSh->GetDocument();
+    pDoc->EnableAdjustHeight( true );
+    // open document in read/write mode ( otherwise optimal height stuff won't
+    // be triggered ) *and* you can't delete cell contents.
+    int nHeight = sc::TwipsToHMM ( pDoc->GetRowHeight(nRow, nTab, false) );
+    CPPUNIT_ASSERT_EQUAL(1263, nHeight);
+
+    ScDocFunc &rFunc = xDocSh->GetDocFunc();
+
+    // delete content of A1
+    ScRange aDelRange(0,0,0,0,0,0);
+    ScMarkData aMark;
+    aMark.SetMarkArea(aDelRange);
+    rFunc.DeleteContents( aMark, -1, false, true );
+
+    // get the new height of A1
+    nHeight =  sc::TwipsToHMM( pDoc->GetRowHeight(nRow, nTab, false) );
+
+    // set optimal height for empty row 2
+    SCCOLROW nRowArr[2];
+    nRowArr[0] = nRowArr[1] = 2;
+    rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, sal_True, sal_True );
+
+    // retrieve optimal height
+    int nOptimalHeight = sc::TwipsToHMM( pDoc->GetRowHeight( nRowArr[0], nTab, false) );
+
+    // check if the new height of A1 ( after delete ) is now the optimal height of an empty cell
+    CPPUNIT_ASSERT_EQUAL(nOptimalHeight, nHeight );
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {


More information about the Libreoffice-commits mailing list