diff options
author | Eike Rathke <erack@redhat.com> | 2013-07-25 15:33:49 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-07-25 16:11:09 +0200 |
commit | 1ecdc7aaf661e97a33cf521f553481d79cd26de2 (patch) | |
tree | 34811d2f9f17691c749622ff61a42b79f1da15d5 /sc/qa | |
parent | bb98778dbf761a0c88c96117add00a66e5cc6c95 (diff) |
resolved fdo#67249 use ScFieldEditEngine to resolve field content
ScEditUtil::GetString() iterated over the paragraphs of an
EditTextObject where GetText() does not resolve field content but
returns the embedded field markers. To resolve field content an
ScFieldEditEngine is needed.
This makes it necessary to pass an ScDocument* to obtain the
ScFieldEditEngine from, or for cases where there is no ScDocument in the
context use a static ScFieldEditEngine which unfortunately is not
capable of resolving document specific fields of course, such as
DOCINFO_TITLE and TABLE.
Also added unit test.
Change-Id: Ife3c23b2fec2514b32303239d276c49869786eb5
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 9 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 79d31c85b524..49ec5fd7b3c8 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -45,6 +45,7 @@ #include "patattr.hxx" #include "scitems.hxx" #include "docsh.hxx" +#include "editutil.hxx" #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XControlShape.hpp> @@ -1582,6 +1583,8 @@ void ScFiltersTest::testRichTextContentODS() aParaText = pEditText->GetText(0); CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("Sheet name is ") == 0); CPPUNIT_ASSERT_MESSAGE("Sheet name field item not found.", pEditText->HasField(text::textfield::Type::TABLE)); + CPPUNIT_ASSERT_EQUAL(OUString("Sheet name is Test."), ScEditUtil::GetString(*pEditText, pDoc)); + CPPUNIT_ASSERT_EQUAL(OUString("Sheet name is ?."), ScEditUtil::GetString(*pEditText, NULL)); // Cell with URL field item. aPos.IncRow(); @@ -1592,6 +1595,8 @@ void ScFiltersTest::testRichTextContentODS() aParaText = pEditText->GetText(0); CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("URL: ") == 0); CPPUNIT_ASSERT_MESSAGE("URL field item not found.", pEditText->HasField(text::textfield::Type::URL)); + CPPUNIT_ASSERT_EQUAL(OUString("URL: http://libreoffice.org"), ScEditUtil::GetString(*pEditText, pDoc)); + CPPUNIT_ASSERT_EQUAL(OUString("URL: http://libreoffice.org"), ScEditUtil::GetString(*pEditText, NULL)); // Cell with Date field item. aPos.IncRow(); @@ -1602,6 +1607,8 @@ void ScFiltersTest::testRichTextContentODS() aParaText = pEditText->GetText(0); CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("Date: ") == 0); CPPUNIT_ASSERT_MESSAGE("Date field item not found.", pEditText->HasField(text::textfield::Type::DATE)); + CPPUNIT_ASSERT_MESSAGE("Date field not resolved with pDoc.", ScEditUtil::GetString(*pEditText, pDoc).indexOf("/20") > 0); + CPPUNIT_ASSERT_MESSAGE("Date field not resolved with NULL.", ScEditUtil::GetString(*pEditText, NULL).indexOf("/20") > 0); // Cell with DocInfo title field item. aPos.IncRow(); @@ -1612,6 +1619,8 @@ void ScFiltersTest::testRichTextContentODS() aParaText = pEditText->GetText(0); CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("Title: ") == 0); CPPUNIT_ASSERT_MESSAGE("DocInfo title field item not found.", pEditText->HasField(text::textfield::Type::DOCINFO_TITLE)); + CPPUNIT_ASSERT_EQUAL(OUString("Title: Test Document"), ScEditUtil::GetString(*pEditText, pDoc)); + CPPUNIT_ASSERT_EQUAL(OUString("Title: ?"), ScEditUtil::GetString(*pEditText, NULL)); // Cell with sentence with both bold and italic sequences. aPos.IncRow(); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 7d081bc1ee1f..5e7213642483 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -621,7 +621,7 @@ bool checkHorizontalIterator(ScDocument* pDoc, const char* pData[][_Size], size_ if (pChecks[i].nRow != nRow) return false; - if (OUString::createFromAscii(pChecks[i].pVal) != pCell->getString()) + if (OUString::createFromAscii(pChecks[i].pVal) != pCell->getString(pDoc)) return false; } |