diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-12-14 18:50:03 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-01-07 11:17:57 +0000 |
commit | 90e07dd6f5d64a0d0041361c1592a6cd93ff2ac0 (patch) | |
tree | 25589e89680256f25c6ffee0a3031e68f40d89e2 /sc | |
parent | ece5cc21aa7814be79016e0d285981c6ced4d9ee (diff) |
tdf#89999 bugfix test
Change-Id: Iaaf7f6b4bdcadb71e805d7d6ac10f700e3fa5846
Reviewed-on: https://gerrit.libreoffice.org/20707
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 475570e73964..73f26c2c73d9 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -54,6 +54,7 @@ #include <editeng/section.hxx> #include <editeng/crossedoutitem.hxx> #include <editeng/borderline.hxx> +#include <editeng/escapementitem.hxx> #include <editeng/fontitem.hxx> #include <editeng/udlnitem.hxx> #include <formula/grammar.hxx> @@ -571,6 +572,19 @@ void setFont( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, sal_Int rEE.QuickSetAttribs(aItemSet, aSel); } +void setEscapement( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, short nEsc, sal_uInt8 nRelSize ) +{ + ESelection aSel; + aSel.nStartPara = aSel.nEndPara = nPara; + aSel.nStartPos = nStart; + aSel.nEndPos = nEnd; + + SfxItemSet aItemSet = rEE.GetEmptyItemSet(); + SvxEscapementItem aItem(nEsc, nRelSize, EE_CHAR_ESCAPEMENT); + aItemSet.Put(aItem); + rEE.QuickSetAttribs(aItemSet, aSel); +} + } void ScExportTest::testNamedRangeBugfdo62729() @@ -704,6 +718,24 @@ void ScExportTest::testRichTextExportODS() return false; } + static bool isEscapement(const editeng::Section& rAttr, short nEsc, sal_uInt8 nRelSize) + { + if (rAttr.maAttributes.empty()) + return false; + + std::vector<const SfxPoolItem*>::const_iterator it = rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end(); + for (; it != itEnd; ++it) + { + const SfxPoolItem* p = *it; + if (p->Which() != EE_CHAR_ESCAPEMENT) + continue; + + const SvxEscapementItem* pItem = static_cast<const SvxEscapementItem*>(p); + return ((pItem->GetEsc() == nEsc) && (pItem->GetProp() == nRelSize)); + } + return false; + } + bool checkB2(const EditTextObject* pText) const { if (!pText) @@ -898,6 +930,42 @@ void ScExportTest::testRichTextExportODS() return true; } + bool checkB9(const EditTextObject* pText) const + { + if (!pText) + return false; + + if (pText->GetParagraphCount() != 1) + return false; + + if (pText->GetText(0) != "Sub and Super") + return false; + + std::vector<editeng::Section> aSecAttrs; + pText->GetAllSections(aSecAttrs); + if (aSecAttrs.size() != 3) + return false; + + // superscript + const editeng::Section* pAttr = &aSecAttrs[0]; + if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 0 || pAttr->mnEnd != 3) + return false; + + if (pAttr->maAttributes.size() != 1 || !isEscapement(*pAttr, 32, 64)) + return false; + + // subscript + pAttr = &aSecAttrs[2]; + if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 8 || pAttr->mnEnd != 13) + return false; + + if (pAttr->maAttributes.size() != 1 || !isEscapement(*pAttr, -32, 66)) + return false; + + return true; + } + + } aCheckFunc; // Start with an empty document, put one edit text cell, and make sure it @@ -989,6 +1057,15 @@ void ScExportTest::testRichTextExportODS() rDoc3.SetEditText(ScAddress(1,7,0), pEE->CreateTextObject()); pEditText = rDoc3.GetEditText(ScAddress(1,7,0)); CPPUNIT_ASSERT_MESSAGE("Incorrect B8 value.", aCheckFunc.checkB8(pEditText)); + + pEE->Clear(); + pEE->SetText("Sub and Super"); + setEscapement(*pEE, 0, 0, 3, 32, 64); + setEscapement(*pEE, 0, 8, 13, -32, 66); + rDoc3.SetEditText(ScAddress(1,8,0), pEE->CreateTextObject()); + pEditText = rDoc3.GetEditText(ScAddress(1,8,0)); + CPPUNIT_ASSERT_MESSAGE("Incorrect B9 value.", aCheckFunc.checkB9(pEditText)); + } // Reload the doc again, and check the content of B2, B4, B6 and B7. |