[Libreoffice-commits] core.git: sw/qa
Tamas Bunth
tamas.bunth at collabora.co.uk
Mon Oct 16 10:24:24 UTC 2017
sw/qa/extras/uiwriter/data/tdf99689.odt |binary
sw/qa/extras/uiwriter/data/tdf99689_figures.odt |binary
sw/qa/extras/uiwriter/data/tdf99689_tables.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 102 ++++++++++++++++++++++++
4 files changed, 102 insertions(+)
New commits:
commit 1ca2a2119ad3e910f848344d51ba9ec173880715
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date: Fri Oct 6 21:23:59 2017 +0200
tdf#99689 add tests for subscript attribute in ToX
And superscript.
Change-Id: Ia74fe20d3f105d2ce19064742f603d3df75c3581
Reviewed-on: https://gerrit.libreoffice.org/43211
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
diff --git a/sw/qa/extras/uiwriter/data/tdf99689.odt b/sw/qa/extras/uiwriter/data/tdf99689.odt
new file mode 100644
index 000000000000..456309a96de4
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf99689.odt differ
diff --git a/sw/qa/extras/uiwriter/data/tdf99689_figures.odt b/sw/qa/extras/uiwriter/data/tdf99689_figures.odt
new file mode 100644
index 000000000000..973e48d39638
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf99689_figures.odt differ
diff --git a/sw/qa/extras/uiwriter/data/tdf99689_tables.odt b/sw/qa/extras/uiwriter/data/tdf99689_tables.odt
new file mode 100644
index 000000000000..15b386eabe28
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf99689_tables.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2b2f04eff480..23c95a805283 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -51,6 +51,7 @@
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
+#include "svl/itemiter.hxx"
#include <editeng/eeitem.hxx>
#include <editeng/scripttypeitem.hxx>
@@ -276,6 +277,9 @@ public:
#endif
void testLinesInSectionInTable();
void testParagraphOfTextRange();
+ void testTdf99689TableOfContents();
+ void testTdf99689TableOfFigures();
+ void testTdf99689TableOfTables();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -435,6 +439,9 @@ public:
#endif
CPPUNIT_TEST(testLinesInSectionInTable);
CPPUNIT_TEST(testParagraphOfTextRange);
+ CPPUNIT_TEST(testTdf99689TableOfContents);
+ CPPUNIT_TEST(testTdf99689TableOfFigures);
+ CPPUNIT_TEST(testTdf99689TableOfTables);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3165,6 +3172,101 @@ void SwUiWriterTest::testTdf75137()
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()
{
SwDoc* pDoc = createDoc("tdf83798.odt");
More information about the Libreoffice-commits
mailing list