diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-02 22:08:54 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-02 22:10:52 -0400 |
commit | ac0041248bffa53f8da338a84ed6defafcb5435e (patch) | |
tree | 85a0fef88e51420fc7642906167ca1dfd94949ad | |
parent | 7b319cb9c11bb0f0100c16b6268e580a1d6e64aa (diff) |
Add a test that currently fails. We need to fix this bug.
Conflicts:
sc/qa/unit/subsequent_export-test.cxx
Change-Id: Ie09c668d952a6297ffe3c75e348c2a0348176bbe
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/empty.ods | bin | 0 -> 6873 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 64 |
3 files changed, 65 insertions, 1 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 9c30744d5b05..90e014848444 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -817,7 +817,7 @@ public: SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark); SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; - OUString GetString( const ScAddress& rPos ) const; + SC_DLLPUBLIC OUString GetString( const ScAddress& rPos ) const; /** * Return a pointer to the string object stored in string cell. diff --git a/sc/qa/unit/data/ods/empty.ods b/sc/qa/unit/data/ods/empty.ods Binary files differnew file mode 100644 index 000000000000..14b4232189f5 --- /dev/null +++ b/sc/qa/unit/data/ods/empty.ods diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index f881923eccd0..90ced45e8b15 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -28,9 +28,13 @@ #include "cellform.hxx" #include "formulacell.hxx" #include "tokenarray.hxx" +#include "editutil.hxx" #include "svx/svdoole2.hxx" #include "tabprotection.hxx" +#include "editeng/wghtitem.hxx" +#include "editeng/postitem.hxx" +#include "editeng/editdata.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -55,6 +59,7 @@ public: void testDataBarExportXLSX(); void testMiscRowHeightExport(); void testNamedRangeBugfdo62729(); + void testRichTextExportODS(); void testInlineArrayXLS(); void testEmbeddedChartXLS(); @@ -72,6 +77,7 @@ public: CPPUNIT_TEST(testColorScaleExportXLSX); CPPUNIT_TEST(testMiscRowHeightExport); CPPUNIT_TEST(testNamedRangeBugfdo62729); +// CPPUNIT_TEST(testRichTextExportODS); This currently fails. CPPUNIT_TEST(testInlineArrayXLS); CPPUNIT_TEST(testEmbeddedChartXLS); CPPUNIT_TEST(testFormulaReferenceXLS); @@ -334,6 +340,64 @@ void ScExportTest::testNamedRangeBugfdo62729() xDocSh->DoClose(); } +void ScExportTest::testRichTextExportODS() +{ + // Start with an empty document, put one edit text cell, and make sure it + // survives the save and reload. + ScDocShellRef xNewDocSh = loadDoc("empty.", ODS); + ScDocument* pDoc = xNewDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + CPPUNIT_ASSERT_MESSAGE("This document should at least have one sheet.", pDoc->GetTableCount() > 0); + + // Insert an edit text cell. + OUString aCellText("Bold and Italic"); + ScFieldEditEngine& rEE = pDoc->GetEditEngine(); + rEE.SetText(aCellText); + ESelection aSel; + aSel.nStartPara = aSel.nEndPara = 0; + + { + // Set the 'Bold' part bold. + SfxItemSet aItemSet = rEE.GetEmptyItemSet(); + aSel.nStartPos = 0; + aSel.nEndPos = 4; + SvxWeightItem aWeight(WEIGHT_BOLD, ATTR_FONT_WEIGHT); + aItemSet.Put(aWeight); + rEE.QuickSetAttribs(aItemSet, aSel); + } + + { + // Set the 'Italic' part italic. + SfxItemSet aItemSet = rEE.GetEmptyItemSet(); + SvxPostureItem aItalic(ITALIC_NORMAL, ATTR_FONT_POSTURE); + aItemSet.Put(aItalic); + aSel.nStartPos = 9; + aSel.nEndPos = 15; + rEE.QuickSetAttribs(aItemSet, aSel); + } + + // Set this edit text to cell B2. + pDoc->SetEditText(ScAddress(1,1,0), rEE.CreateTextObject()); + const EditTextObject* pEditText = pDoc->GetEditText(ScAddress(1,1,0)); + CPPUNIT_ASSERT_MESSAGE("B2 should be an edit text.", pEditText); + + // Now, save and reload this document. + ScDocShellRef xDocSh = saveAndReload(xNewDocSh, ODS); + xNewDocSh->DoClose(); + CPPUNIT_ASSERT(xDocSh.Is()); + pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + CPPUNIT_ASSERT_MESSAGE("Reloaded document should at least have one sheet.", pDoc->GetTableCount() > 0); + + // Make sure the content of B2 is still intact. + CPPUNIT_ASSERT_EQUAL(aCellText, pDoc->GetString(ScAddress(1,1,0))); + + pEditText = pDoc->GetEditText(ScAddress(1,1,0)); + CPPUNIT_ASSERT_MESSAGE("B2 should be an edit text.", pEditText); + + xDocSh->DoClose(); +} + namespace { void checkMatrixRange(ScDocument& rDoc, const ScRange& rRange) |