summaryrefslogtreecommitdiff
path: root/sw/qa/extras/inc
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 /sw/qa/extras/inc
parent40dc6c3a97c9f40617e2258f0f0cf866bcb13c8a (diff)
fdo#60842: add a unit test
Change-Id: Ie91fe22f2baf0a280e5cf21c2416228ab414f285
Diffstat (limited to 'sw/qa/extras/inc')
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx38
1 files changed, 33 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);