summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-02-16 20:56:21 +0100
committerMichael Stahl <mstahl@redhat.com>2013-02-18 20:16:06 +0100
commit08dc5de900b2e5cca9d9443fc5d4ea7756842af9 (patch)
tree351ff8863b4c3390fb4086487b069ddbfb509b6b
parent40dc6c3a97c9f40617e2258f0f0cf866bcb13c8a (diff)
fdo#60842: add a unit test
Change-Id: Ie91fe22f2baf0a280e5cf21c2416228ab414f285
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx38
-rw-r--r--sw/qa/extras/odfimport/data/fdo60842.odtbin0 -> 4300 bytes
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx12
3 files changed, 45 insertions, 5 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 8edb76f32bc9..e265e125a703 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -30,6 +30,8 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/table/XCell.hpp>
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
@@ -196,7 +198,7 @@ protected:
}
// Get paragraph (counted from 1), optionally check it contains the given text.
- uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const
+ uno::Reference<text::XTextContent> getParagraphOrTable(int number) const
{
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
@@ -205,10 +207,18 @@ protected:
i < number;
++i )
paraEnum->nextElement();
- uno::Reference< text::XTextRange > paragraph( paraEnum->nextElement(), uno::UNO_QUERY );
+ uno::Reference< text::XTextContent> const xElem(paraEnum->nextElement(),
+ uno::UNO_QUERY_THROW);
+ return xElem;
+ }
+
+ uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const
+ {
+ uno::Reference<text::XTextRange> const xParagraph(
+ getParagraphOrTable(number), uno::UNO_QUERY_THROW);
if( !content.isEmpty())
- CPPUNIT_ASSERT_EQUAL( content, paragraph->getString());
- return paragraph;
+ CPPUNIT_ASSERT_EQUAL( content, xParagraph->getString());
+ return xParagraph;
}
/// Get run (counted from 1) of a paragraph, optionally check it contains the given text.
@@ -233,6 +243,24 @@ protected:
return getProperty<OUString>(getProperty< uno::Reference<beans::XPropertySet> >(xFormula, "Model"), "Formula");
}
+ /// get cell of a table; table can be retrieved with getParagraphOrTable
+ uno::Reference<table::XCell> getCell(
+ uno::Reference<uno::XInterface> const& xTableIfc,
+ OUString const& rCell, OUString const& rContent = OUString())
+ {
+ uno::Reference<text::XTextTable> const xTable(xTableIfc,
+ uno::UNO_QUERY_THROW);
+ uno::Reference<table::XCell> const xCell(
+ xTable->getCellByName(rCell), uno::UNO_SET_THROW);
+ if (!rContent.isEmpty())
+ {
+ uno::Reference<text::XText> const xCellText(xCell,
+ uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(rContent, xCellText->getString());
+ }
+ return xCell;
+ }
+
void header()
{
fprintf(stderr, "File tested,Execution Time (ms)\n");
@@ -246,7 +274,7 @@ protected:
mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument");
calcLayout();
}
-
+
void reload(OUString aFilter)
{
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/extras/odfimport/data/fdo60842.odt b/sw/qa/extras/odfimport/data/fdo60842.odt
new file mode 100644
index 000000000000..dc2bfbeef167
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/fdo60842.odt
Binary files differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index fff0e79849c5..cfeda28b4048 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -42,6 +42,7 @@ public:
void testOdtBorders();
void testPageStyleLayoutDefault();
void testPageStyleLayoutRight();
+ void testFdo60842();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -61,6 +62,7 @@ void Test::run()
{"borders_ooo33.odt", &Test::testOdtBorders},
{"hello.odt", &Test::testPageStyleLayoutDefault},
{"hello.odt", &Test::testPageStyleLayoutRight},
+ {"fdo60842.odt", &Test::testFdo60842},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -291,6 +293,16 @@ void Test::testPageStyleLayoutRight()
xPropertySet->setPropertyValue("PageStyleLayout", uno::makeAny(style::PageStyleLayout_RIGHT));
}
+void Test::testFdo60842()
+{
+ uno::Reference<text::XTextContent> const xTable(getParagraphOrTable(0));
+ getCell(xTable, "A1", "");
+ getCell(xTable, "B1", "18/02/2012");
+ getCell(xTable, "C1", "USD"); // this is the cell with office:string-value
+ getCell(xTable, "D1", "");
+ getCell(xTable, "E1", "01/04/2012");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();