summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-07-23 22:58:25 +0200
committerEike Rathke <erack@redhat.com>2013-07-23 23:01:21 +0200
commit038d162b175b62d67a94d4418b3a15a1a382419d (patch)
tree62a1e4d89480c20cc92ea4ad775c31c013abd3a9
parent98608e57f21820ec1d2c6cd77f433b6963e249a6 (diff)
unit test for <text:s> in <text:p> and <text:span>, fdo#67094
Change-Id: I033668dcdcdcc1a5710f2ddacadf9a1a5344638e
-rw-r--r--sc/qa/unit/data/ods/rich-text-cells.odsbin18264 -> 20162 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx57
2 files changed, 49 insertions, 8 deletions
diff --git a/sc/qa/unit/data/ods/rich-text-cells.ods b/sc/qa/unit/data/ods/rich-text-cells.ods
index da3a1edcada3..b039c3781999 100644
--- a/sc/qa/unit/data/ods/rich-text-cells.ods
+++ b/sc/qa/unit/data/ods/rich-text-cells.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 3ed4d6e6930d..79d31c85b524 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1660,18 +1660,20 @@ void ScFiltersTest::testRichTextContentODS()
// first line is bold.
pEditText->GetCharAttribs(0, aAttribs);
- bool bHasBold = false;
- for (it = aAttribs.begin(), itEnd = aAttribs.end(); it != itEnd; ++it)
{
- if (it->pAttr->Which() == EE_CHAR_WEIGHT)
+ bool bHasBold = false;
+ for (it = aAttribs.begin(), itEnd = aAttribs.end(); it != itEnd; ++it)
{
- const SvxWeightItem& rItem = static_cast<const SvxWeightItem&>(*it->pAttr);
- bHasBold = (rItem.GetWeight() == WEIGHT_BOLD);
- if (bHasBold)
- break;
+ if (it->pAttr->Which() == EE_CHAR_WEIGHT)
+ {
+ const SvxWeightItem& rItem = static_cast<const SvxWeightItem&>(*it->pAttr);
+ bHasBold = (rItem.GetWeight() == WEIGHT_BOLD);
+ if (bHasBold)
+ break;
+ }
}
+ CPPUNIT_ASSERT_MESSAGE("First line should be bold.", bHasBold);
}
- CPPUNIT_ASSERT_MESSAGE("First line should be bold.", bHasBold);
// second line is italic.
pEditText->GetCharAttribs(1, aAttribs);
@@ -1738,6 +1740,45 @@ void ScFiltersTest::testRichTextContentODS()
const SvxURLField* pURLData = static_cast<const SvxURLField*>(pData);
CPPUNIT_ASSERT_MESSAGE("URL is not absolute with respect to the file system.", pURLData->GetURL().startsWith("file:///"));
+ // Embedded spaces as <text:s text:c='4' />, normal text
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, pDoc->GetCellType(aPos));
+ CPPUNIT_ASSERT_EQUAL(OUString("one two"), pDoc->GetString(aPos.Col(), aPos.Row(), aPos.Tab()));
+
+ // Leading space as <text:s />.
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, pDoc->GetCellType(aPos));
+ CPPUNIT_ASSERT_EQUAL(OUString(" =3+4"), pDoc->GetString(aPos.Col(), aPos.Row(), aPos.Tab()));
+
+ // Embedded spaces with <text:s text:c='4' /> inside a <text:span>, text
+ // partly bold.
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL(CELLTYPE_EDIT, pDoc->GetCellType(aPos));
+ pEditText = pDoc->GetEditText(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Failed to retrieve edit text object.", pEditText);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), pEditText->GetParagraphCount());
+ aParaText = pEditText->GetText(0);
+ CPPUNIT_ASSERT_EQUAL(OUString("one two"), aParaText);
+ pEditText->GetCharAttribs(0, aAttribs);
+ {
+ bool bHasBold = false;
+ for (it = aAttribs.begin(), itEnd = aAttribs.end(); it != itEnd; ++it)
+ {
+ if (it->pAttr->Which() == EE_CHAR_WEIGHT)
+ {
+ const SvxWeightItem& rItem = static_cast<const SvxWeightItem&>(*it->pAttr);
+ bHasBold = (rItem.GetWeight() == WEIGHT_BOLD);
+ if (bHasBold)
+ {
+ OUString aSeg = aParaText.copy(it->nStart, it->nEnd - it->nStart);
+ CPPUNIT_ASSERT_EQUAL(OUString("e t"), aSeg);
+ break;
+ }
+ }
+ }
+ CPPUNIT_ASSERT_MESSAGE("Expected a bold sequence.", bHasBold);
+ }
+
xDocSh->DoClose();
}