Kaydet (Commit) 1ca2a211 authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

tdf#99689 add tests for subscript attribute in ToX

And superscript.

Change-Id: Ia74fe20d3f105d2ce19064742f603d3df75c3581
Reviewed-on: https://gerrit.libreoffice.org/43211Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 2f223410
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
#include <svx/svdview.hxx> #include <svx/svdview.hxx>
#include "svl/itemiter.hxx"
#include <editeng/eeitem.hxx> #include <editeng/eeitem.hxx>
#include <editeng/scripttypeitem.hxx> #include <editeng/scripttypeitem.hxx>
...@@ -276,6 +277,9 @@ public: ...@@ -276,6 +277,9 @@ public:
#endif #endif
void testLinesInSectionInTable(); void testLinesInSectionInTable();
void testParagraphOfTextRange(); void testParagraphOfTextRange();
void testTdf99689TableOfContents();
void testTdf99689TableOfFigures();
void testTdf99689TableOfTables();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceForward);
...@@ -435,6 +439,9 @@ public: ...@@ -435,6 +439,9 @@ public:
#endif #endif
CPPUNIT_TEST(testLinesInSectionInTable); CPPUNIT_TEST(testLinesInSectionInTable);
CPPUNIT_TEST(testParagraphOfTextRange); CPPUNIT_TEST(testParagraphOfTextRange);
CPPUNIT_TEST(testTdf99689TableOfContents);
CPPUNIT_TEST(testTdf99689TableOfFigures);
CPPUNIT_TEST(testTdf99689TableOfTables);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -3165,6 +3172,101 @@ void SwUiWriterTest::testTdf75137() ...@@ -3165,6 +3172,101 @@ void SwUiWriterTest::testTdf75137()
CPPUNIT_ASSERT(firstIndex != secondIndex); CPPUNIT_ASSERT(firstIndex != secondIndex);
} }
namespace
{
sal_Int32 lcl_getAttributeIDFromHints( const SwpHints& hints )
{
for (size_t i = 0; i < hints.Count(); ++i)
{
const SwTextAttr* hint = hints.Get(i);
if( hint->Which() == RES_TXTATR_AUTOFMT )
{
const SwFormatAutoFormat& rFmt = hint->GetAutoFormat();
SfxItemIter aIter( *rFmt.GetStyleHandle() );
return aIter.GetCurItem()->Which();
}
}
return -1;
}
}
void SwUiWriterTest::testTdf99689TableOfContents()
{
SwDoc* pDoc = createDoc("tdf99689.odt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->GotoNextTOXBase();
const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX();
pWrtShell->UpdateTableOf(*pTOXBase);
SwCursorShell * pShell(pDoc->GetEditShell());
SwTextNode* pTitleNode = pShell->GetCursor()->GetNode().GetTextNode();
SwNodeIndex aIdx ( *pTitleNode );
// skip the title
pDoc->GetNodes().GoNext( &aIdx );
// skip the first header. No attributes there.
// next node should contain superscript
SwTextNode* pNext = static_cast<SwTextNode*> (pDoc->GetNodes().GoNext( &aIdx ));
CPPUNIT_ASSERT( pNext->HasHints() );
sal_Int32 nAttrType = lcl_getAttributeIDFromHints( pNext->GetSwpHints() );
CPPUNIT_ASSERT_EQUAL(RES_CHRATR_ESCAPEMENT, static_cast<RES_CHRATR>(nAttrType) );
// next node should contain subscript
pNext = static_cast<SwTextNode*> (pDoc->GetNodes().GoNext( &aIdx ));
CPPUNIT_ASSERT( pNext->HasHints() );
nAttrType = lcl_getAttributeIDFromHints( pNext->GetSwpHints() );
CPPUNIT_ASSERT_EQUAL(RES_CHRATR_ESCAPEMENT, static_cast<RES_CHRATR>(nAttrType) );
}
void SwUiWriterTest::testTdf99689TableOfFigures()
{
SwDoc* pDoc = createDoc("tdf99689_figures.odt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->GotoNextTOXBase();
const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX();
pWrtShell->UpdateTableOf(*pTOXBase);
SwCursorShell * pShell(pDoc->GetEditShell());
SwTextNode* pTitleNode = pShell->GetCursor()->GetNode().GetTextNode();
SwNodeIndex aIdx ( *pTitleNode );
// skip the title
// next node should contain subscript
SwTextNode* pNext = static_cast<SwTextNode*> (pDoc->GetNodes().GoNext( &aIdx ));
CPPUNIT_ASSERT( pNext->HasHints() );
sal_Int32 nAttrType = lcl_getAttributeIDFromHints( pNext->GetSwpHints() );
CPPUNIT_ASSERT_EQUAL(RES_CHRATR_ESCAPEMENT, static_cast<RES_CHRATR>(nAttrType) );
// next node should contain superscript
pNext = static_cast<SwTextNode*> (pDoc->GetNodes().GoNext( &aIdx ));
CPPUNIT_ASSERT( pNext->HasHints() );
nAttrType = lcl_getAttributeIDFromHints( pNext->GetSwpHints() );
CPPUNIT_ASSERT_EQUAL(RES_CHRATR_ESCAPEMENT, static_cast<RES_CHRATR>(nAttrType) );
}
void SwUiWriterTest::testTdf99689TableOfTables()
{
SwDoc* pDoc = createDoc("tdf99689_tables.odt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->GotoNextTOXBase();
const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX();
pWrtShell->UpdateTableOf(*pTOXBase);
SwCursorShell * pShell(pDoc->GetEditShell());
SwTextNode* pTitleNode = pShell->GetCursor()->GetNode().GetTextNode();
SwNodeIndex aIdx ( *pTitleNode );
// skip the title
// next node should contain superscript
SwTextNode* pNext = static_cast<SwTextNode*> (pDoc->GetNodes().GoNext( &aIdx ));
CPPUNIT_ASSERT( pNext->HasHints() );
sal_Int32 nAttrType = lcl_getAttributeIDFromHints( pNext->GetSwpHints() );
CPPUNIT_ASSERT_EQUAL(RES_CHRATR_ESCAPEMENT, static_cast<RES_CHRATR>(nAttrType) );
// next node should contain subscript
pNext = static_cast<SwTextNode*> (pDoc->GetNodes().GoNext( &aIdx ));
CPPUNIT_ASSERT( pNext->HasHints() );
nAttrType = lcl_getAttributeIDFromHints( pNext->GetSwpHints() );
CPPUNIT_ASSERT_EQUAL(RES_CHRATR_ESCAPEMENT, static_cast<RES_CHRATR>(nAttrType) );
}
void SwUiWriterTest::testTdf83798() void SwUiWriterTest::testTdf83798()
{ {
SwDoc* pDoc = createDoc("tdf83798.odt"); SwDoc* pDoc = createDoc("tdf83798.odt");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment