diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/copy_paste_test.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/inc/impex.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 6 |
3 files changed, 65 insertions, 4 deletions
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx index 4087b9d48946..adc736553953 100644 --- a/sc/qa/unit/copy_paste_test.cxx +++ b/sc/qa/unit/copy_paste_test.cxx @@ -13,6 +13,7 @@ #include <docsh.hxx> #include <tabvwsh.hxx> +#include <impex.hxx> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XModel2.hpp> @@ -34,12 +35,14 @@ public: void testTdf84411(); void testTdf124565(); void testTdf126421(); + void testTdf107394(); CPPUNIT_TEST_SUITE(ScCopyPasteTest); CPPUNIT_TEST(testCopyPasteXLS); CPPUNIT_TEST(testTdf84411); CPPUNIT_TEST(testTdf124565); CPPUNIT_TEST(testTdf126421); + CPPUNIT_TEST(testTdf107394); CPPUNIT_TEST_SUITE_END(); private: @@ -362,6 +365,62 @@ void ScCopyPasteTest::testTdf126421() xDocSh->DoClose(); } +void ScCopyPasteTest::testTdf107394() +{ + uno::Reference<frame::XDesktop2> xDesktop + = frame::Desktop::create(::comphelper::getProcessComponentContext()); + CPPUNIT_ASSERT(xDesktop.is()); + + uno::Reference<lang::XComponent> xComponent + = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, {}); + CPPUNIT_ASSERT(xComponent.is()); + + auto pModelObj = dynamic_cast<ScModelObj*>(xComponent.get()); + CPPUNIT_ASSERT(pModelObj); + CPPUNIT_ASSERT(pModelObj->GetDocument()); + + ScDocument& rDoc = *pModelObj->GetDocument(); + + sal_uInt16 nFirstRowHeight = rDoc.GetRowHeight(0, 0); + sal_uInt16 nSecondRowHeight = rDoc.GetRowHeight(1, 0); + CPPUNIT_ASSERT_EQUAL(nFirstRowHeight, nSecondRowHeight); + + // Import values to A1:A2. + ScImportExport aObj(&rDoc, ScAddress(0,0,0)); + aObj.SetImportBroadcast(true); + + OString aHTML("<pre>First\nVery long sentence.</pre>"); + SvMemoryStream aStream; + aStream.WriteOString(aHTML); + aStream.Seek(0); + CPPUNIT_ASSERT(aObj.ImportStream(aStream, OUString(), SotClipboardFormatId::HTML)); + + CPPUNIT_ASSERT_EQUAL(OUString("First"), rDoc.GetString(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(OUString("Very long sentence."), rDoc.GetString(ScAddress(0,1,0))); + + nFirstRowHeight = rDoc.GetRowHeight(0, 0); + nSecondRowHeight = rDoc.GetRowHeight(1, 0); + CPPUNIT_ASSERT_GREATER(nFirstRowHeight, nSecondRowHeight); + + // Undo, and check the result. + SfxUndoManager* pUndoMgr = rDoc.GetUndoManager(); + CPPUNIT_ASSERT_MESSAGE("Failed to get the undo manager.", pUndoMgr); + pUndoMgr->Undo(); + + CPPUNIT_ASSERT(rDoc.GetString(ScAddress(0,0,0)).isEmpty()); + CPPUNIT_ASSERT(rDoc.GetString(ScAddress(0,1,0)).isEmpty()); + + nFirstRowHeight = rDoc.GetRowHeight(0, 0); + nSecondRowHeight = rDoc.GetRowHeight(1, 0); + // Without the accompanying fix in place, this test would have failed: + // - Expected: 256 + // - Actual : 477 + // i.e. the increased height of the second row remained after undo. + CPPUNIT_ASSERT_EQUAL(nFirstRowHeight, nSecondRowHeight); + + xComponent->dispose(); +} + ScCopyPasteTest::ScCopyPasteTest() : ScBootstrapFixture( "sc/qa/unit/data" ) { diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx index 1b703d821373..3ddba5d9b89a 100644 --- a/sc/source/ui/inc/impex.hxx +++ b/sc/source/ui/inc/impex.hxx @@ -44,7 +44,7 @@ struct ScExportTextOptions bool mbAddQuotes; }; -class ScImportExport +class SC_DLLPUBLIC ScImportExport { ScDocShell* pDocSh; ScDocument* pDoc; @@ -101,7 +101,7 @@ public: const ScRange& GetRange() const { return aRange; } - SC_DLLPUBLIC static void EmbeddedNullTreatment( OUString & rStr ); + static void EmbeddedNullTreatment( OUString & rStr ); static bool IsFormatSupported( SotClipboardFormatId nFormat ); static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p, diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 15d6a8e3e273..54d50c38ac8c 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1079,6 +1079,8 @@ void ScUndoPaste::DoChange(bool bUndo) { ScRange& rDrawRange = aDrawRanges[i]; rDoc.ExtendMerge(rDrawRange, true); // only needed for single sheet (text/rtf etc.) + ScRangeList aRangeList(rDrawRange); + ScMarkData aData(aRangeList); if (bPaintAll) { rDrawRange.aStart.SetCol(0); @@ -1087,7 +1089,7 @@ void ScUndoPaste::DoChange(bool bUndo) rDrawRange.aEnd.SetRow(MAXROW); nPaint |= PaintPartFlags::Top | PaintPartFlags::Left; if (pViewShell) - pViewShell->AdjustBlockHeight(false); + pViewShell->AdjustBlockHeight(false, &aData); } else { @@ -1101,7 +1103,7 @@ void ScUndoPaste::DoChange(bool bUndo) nPaint |= PaintPartFlags::Left; rDrawRange.aEnd.SetRow(MAXROW); } - if (pViewShell && pViewShell->AdjustBlockHeight(false)) + if (pViewShell && pViewShell->AdjustBlockHeight(false, &aData)) { rDrawRange.aStart.SetCol(0); rDrawRange.aStart.SetRow(0); |