From 93a7ad0b686ec772a3988256a7856f2130cf8ae7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 9 May 2012 12:51:01 +0200 Subject: rtftok test: clean up by introducing getStyles() helper Change-Id: I5759d748efb1ed0aa0376de50eb16ba10e63c280 --- sw/qa/extras/rtftok/rtftok.cxx | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'sw') diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx index e6de8431a34c..8b41569d826a 100644 --- a/sw/qa/extras/rtftok/rtftok.cxx +++ b/sw/qa/extras/rtftok/rtftok.cxx @@ -139,6 +139,7 @@ private: int getLength(); /// Get page count. int getPages(); + uno::Reference getStyles(OUString aFamily); uno::Reference mxComponent; }; @@ -175,6 +176,14 @@ int Test::getPages() return xCursor->getPage(); } +uno::Reference Test::getStyles(OUString aFamily) +{ + uno::Reference xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference xPageStyles(xStyles->getByName(aFamily), uno::UNO_QUERY); + return xPageStyles; +} + void Test::setUp() { test::BootstrapFixture::setUp(); @@ -332,10 +341,7 @@ void Test::testFdo46662() { load("fdo46662.rtf"); - uno::Reference xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); - uno::Reference xNumberingStyles(xStyles->getByName("NumberingStyles"), uno::UNO_QUERY); - uno::Reference xPropertySet(xNumberingStyles->getByName("WWNum3"), uno::UNO_QUERY); + uno::Reference xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY); uno::Reference xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence aProps; xLevels->getByIndex(1) >>= aProps; // 2nd level @@ -487,10 +493,7 @@ void Test::testFdo45394() { load("fdo45394.rtf"); - uno::Reference xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); - uno::Reference xPageStyles(xStyles->getByName("PageStyles"), uno::UNO_QUERY); - uno::Reference xPropertySet(xPageStyles->getByName("Default"), uno::UNO_QUERY); + uno::Reference xPropertySet(getStyles("PageStyles")->getByName("Default"), uno::UNO_QUERY); uno::Reference xHeaderText(xPropertySet->getPropertyValue("HeaderText"), uno::UNO_QUERY); OUString aActual = xHeaderText->getString(); // Encoding in the header was wrong. @@ -512,9 +515,7 @@ void Test::testFdo47107() { load("fdo47107.rtf"); - uno::Reference xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); - uno::Reference xNumberingStyles(xStyles->getByName("NumberingStyles"), uno::UNO_QUERY); + uno::Reference xNumberingStyles(getStyles("NumberingStyles")); // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException xNumberingStyles->getByName("WWNum1"); xNumberingStyles->getByName("WWNum2"); @@ -536,9 +537,7 @@ void Test::testFdo44176() { load("fdo44176.rtf"); - uno::Reference xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); - uno::Reference xPageStyles(xStyles->getByName("PageStyles"), uno::UNO_QUERY); + uno::Reference xPageStyles(getStyles("PageStyles")); uno::Reference xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY); uno::Reference xDefault(xPageStyles->getByName("Default"), uno::UNO_QUERY); sal_Int32 nFirstTop = 0, nDefaultTop = 0, nDefaultHeader = 0; @@ -707,10 +706,7 @@ void Test::testFdo49501() { load("fdo49501.rtf"); - uno::Reference xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); - uno::Reference xPageStyles(xStyles->getByName("PageStyles"), uno::UNO_QUERY); - uno::Reference xStyle(xPageStyles->getByName("Default"), uno::UNO_QUERY); + uno::Reference xStyle(getStyles("PageStyles")->getByName("Default"), uno::UNO_QUERY); sal_Bool bIsLandscape = sal_False; xStyle->getPropertyValue("IsLandscape") >>= bIsLandscape; -- cgit