Kaydet (Commit) d3871400 authored tarafından Noel Power's avatar Noel Power

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
üst 12f2baa3
...@@ -1028,7 +1028,7 @@ public: ...@@ -1028,7 +1028,7 @@ public:
void DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, void DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
const ScMarkData& rMark, sal_uInt16 nDelFlag); 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); SCTAB nTab, sal_uInt16 nDelFlag);
void DeleteAreaTab(const ScRange& rRange, sal_uInt16 nDelFlag); void DeleteAreaTab(const ScRange& rRange, sal_uInt16 nDelFlag);
......
...@@ -129,7 +129,7 @@ class ScBootstrapFixture : public test::BootstrapFixture ...@@ -129,7 +129,7 @@ class ScBootstrapFixture : public test::BootstrapFixture
{ {
protected: protected:
OUString m_aBaseString; OUString m_aBaseString;
ScDocShellRef load( ScDocShellRef load( bool bReadWrite,
const OUString& rURL, const OUString& rFilter, const OUString &rUserData, 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 ) const OUString& rTypeName, unsigned int nFilterFlags, unsigned int nClipboardID, sal_uIntPtr nFilterVersion = SOFFICE_FILEFORMAT_CURRENT, const OUString* pPassword = NULL )
{ {
...@@ -141,7 +141,7 @@ protected: ...@@ -141,7 +141,7 @@ protected:
ScDocShellRef xDocShRef = new ScDocShell; ScDocShellRef xDocShRef = new ScDocShell;
xDocShRef->GetDocument()->EnableUserInteraction(false); 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->SetFilter(pFilter);
pSrcMed->UseInteractionHandler(false); pSrcMed->UseInteractionHandler(false);
if (pPassword) if (pPassword)
...@@ -160,7 +160,14 @@ protected: ...@@ -160,7 +160,14 @@ protected:
return xDocShRef; 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 aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 );
OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ;
...@@ -170,7 +177,7 @@ protected: ...@@ -170,7 +177,7 @@ protected:
unsigned int nFormatType = aFileFormats[nFormat].nFormatType; unsigned int nFormatType = aFileFormats[nFormat].nFormatType;
unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; 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);
} }
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
#include "dpobject.hxx" #include "dpobject.hxx"
#include "dpsave.hxx" #include "dpsave.hxx"
#include "stlsheet.hxx" #include "stlsheet.hxx"
#include "docfunc.hxx"
#include "markdata.hxx"
#include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/drawing/XControlShape.hpp>
...@@ -146,6 +148,7 @@ public: ...@@ -146,6 +148,7 @@ public:
void testRowHeightODS(); void testRowHeightODS();
void testRichTextContentODS(); void testRichTextContentODS();
void testMiscRowHeights(); void testMiscRowHeights();
void testOptimalHeightReset();
CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testRangeNameXLS); CPPUNIT_TEST(testRangeNameXLS);
...@@ -205,6 +208,7 @@ public: ...@@ -205,6 +208,7 @@ public:
CPPUNIT_TEST(testBugFilesXLSX); CPPUNIT_TEST(testBugFilesXLSX);
#endif #endif
CPPUNIT_TEST(testMiscRowHeights); CPPUNIT_TEST(testMiscRowHeights);
CPPUNIT_TEST(testOptimalHeightReset);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -1896,6 +1900,46 @@ void ScFiltersTest::testMiscRowHeights() ...@@ -1896,6 +1900,46 @@ void ScFiltersTest::testMiscRowHeights()
miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) ); 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() ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" ) : ScBootstrapFixture( "/sc/qa/unit/data" )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment